From 8741be85384e709486af933f8ef7935366cffaee Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Fri, 10 Jun 2022 13:59:59 +0200 Subject: [PATCH] Better README --- README.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 72f28e5..8c96143 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ # PHPStan PSL extension +[![Build](https://github.com/php-standard-library/phpstan-extension/workflows/Build/badge.svg)](https://github.com/php-standard-library/phpstan-extension/actions) +[![Latest Stable Version](https://poser.pugx.org/php-standard-library/phpstan-extension/v/stable)](https://packagist.org/packages/php-standard-library/phpstan-extension) +[![License](https://poser.pugx.org/php-standard-library/phpstan-extension/license)](https://packagist.org/packages/php-standard-library/phpstan-extension) + +* [PHPStan](https://phpstan.org/) +* [PSL](https://github.com/azjezz/psl) + ## Description -The main scope of this extension is to help phpstan to detect the types after using `Psl\Type\shape`. -Its intended to produce the same output as the [psalm plugin](https://github.com/php-standard-library/psalm-plugin). +The main goal of this extension is to help PHPStan to detect the types after using `Psl\Type\shape`. + Given the following example: ```php @@ -22,6 +29,29 @@ $specification = Type\shape([ $input = $specification->coerce($_GET['user']); ``` -PhpStan assumes that `$input` is of type `array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>`. +PHPStan assumes that `$input` is of type `array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>`. If we enable the extension, you will get a more specific and correct type of `array{name: string, age: int, location?: array{city: string, state: string, country: string}}`. + +Besides coerce, this extension also supports `matches()` and `assert()` methods. + +## Installation + +To use this extension, require it in [Composer](https://getcomposer.org/): + +``` +composer require --dev php-standard-library/phpstan-extension +``` + +If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set! + +
+ Manual installation + +If you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config: + +``` +includes: + - vendor/php-standard-library/phpstan-extension/extension.neon +``` +