Download the PHP package fp4php/functional-psalm-plugin without Composer
On this page you can find all versions of the php package fp4php/functional-psalm-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package functional-psalm-plugin
fp4php/functional psalm plugin
Installation
Supported installation method is via composer:
Usage
To enable the plugin, add the Fp\PsalmPlugin\FunctionalPlugin
class to your psalm configuration using psalm-plugin
binary as follows:
Features
-
filter
Plugin add type narrowing for filtering.
Fp\Functional\Option\Option::filter
:
Fp\Collections\ArrayList::filter
(and other collections with
filter
method):
Fp\Functional\Either\Either::filterOrElse
:
Fp\Collection\filter
:
Fp\Collection\first
and Fp\Collection\last
:
For all cases above you can use first-class callable syntax:
-
fold
Is too difficult to make the fold function using type system of
psalm. Without plugin Fp\Collection\fold
and collections fold
method has some edge cases. For example:
https://psalm.dev/r/b0a99c4912
Plugin can fix that problem.
-
ctor
PHP 8.1 brings feature called first-class
callable. But
that feature cannot be used for class constructor.
Fp\Callable\ctor
can simulate this feature for class constructors,
but requires plugin for static analysis.
-
sequence
Plugin brings structural type inference for sequence functions:
-
assertion
Unfortunately @psalm-assert-if-true
/@psalm-assert-if-false
works
incorrectly for Option/Either assertion methods:
https://psalm.dev/r/408248f46f
Plugin implements workaround for this bug.
-
N-combinators
Psalm plugin will prevent calling *N combinator in non-valid cases:
-
proveTrue
Implementation assertion effect for Fp\Evidence\proveTrue
(like
for builtin assert
function):
-
toEither
Inference for Fp\Functional\Separated\Separated::toEither
:
-
partitionT
Plugin infers each list
type from predicates of partitionT
:
-
filterNotNull
Plugin turns all nullable keys to possibly undefined keys:
All versions of functional-psalm-plugin with dependencies
ext-simplexml Version *