Go to file
azjezz 0fe10f0af9
chore: fix coding standards
Signed-off-by: azjezz <azjezz@protonmail.com>
2022-02-06 19:22:32 +01:00
.github [Fun] calculate expected types per stage for pipe (#6) 2022-01-08 17:25:33 +01:00
src chore: fix coding standards 2022-02-06 19:22:32 +01:00
.editorconfig Initial commit 2021-03-26 10:10:46 +01:00
.gitattributes Initial commit 2021-03-26 10:10:46 +01:00
.gitignore create psalm plugin 2021-03-27 19:33:18 +01:00
.php_cs.dist create psalm plugin 2021-03-27 19:33:18 +01:00
.phpcs.xml create psalm plugin 2021-03-27 19:33:18 +01:00
CHANGELOG.md Initial commit 2021-03-26 10:10:46 +01:00
CODE_OF_CONDUCT.md Initial commit 2021-03-26 10:10:46 +01:00
composer.json chore: add compatibility with psalm 5 2022-02-06 19:20:13 +01:00
LICENSE Initial commit 2021-03-26 10:10:46 +01:00
psalm.xml chore: add compatibility with psalm 5 2022-02-06 19:20:13 +01:00
README.md [Fun] calculate expected types per stage for pipe (#6) 2022-01-08 17:25:33 +01:00
SECURITY.md Initial commit 2021-03-26 10:10:46 +01:00

PSL Psalm Plugin

Static analysis status Type Coverage Total Downloads Latest Stable Version License

Installation

Supported installation method is via composer:

composer require php-standard-library/psalm-plugin --dev

Usage

To enable the plugin, add the Psl\Psalm\Plugin class to your psalm configuration using psalm-plugin binary as follows:

php vendor/bin/psalm-plugin enable php-standard-library/psalm-plugin

Type improvements

Given the following example:

use Psl\Type;

$specification = Type\shape([
  'name' => Type\string(),
  'age' => Type\int(),
  'location' => Type\optional(Type\shape([
    'city' => Type\string(),
    'state' => Type\string(),
    'country' => Type\string(),
  ]))
]);

$input = $specification->coerce($_GET['user']);

/** @psalm-trace $input */

Psalm assumes that $input is of type array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>.

If we enable the php-standard-library/psalm-plugin plugin, you will get a more specific and correct type of array{name: string, age: int, location?: array{city: string, state: string, country: string}}.

Compatibility

PSL Psalm plugin
2.x 2.x
1.x 1.x

Sponsors

Thanks to our sponsors and supporters:

JetBrains

License

The MIT License (MIT). Please see LICENSE for more information.