A psalm-plugin for CakePHP
Installs: 1 939
Open Issues: 0
- ext-simplexml: *
- cakephp/cakephp: ^4.0.0
- vimeo/psalm: ^4.16|^5.0
- codeception/codeception: ^4.1
- phpunit/phpunit: ^9.5.5
- psalm/plugin-phpunit: ^0.16.0
- squizlabs/php_codesniffer: ^3.3
- weirdan/codeception-psalm-module: ^0.13.1
- weirdan/prophecy-shim: ^2.0
This package is auto-updated.
Last update: 2023-05-26 10:42:25 UTC
This plugin provides correct return types for CakePHP specific methods in psalm.
Please refer to the full Psalm documentation for a more detailed guide on how to use Psalm in your project.
First you need to install the psalm base package and create a
composer require --dev vimeo/psalm ./vendor/bin/psalm --init
Next you will need to require this package and enable it in psalm
composer require --dev lordsimal/cakephp-psalm @dev ./vendor/bin/psalm-plugin enable lordsimal/cakephp-psalm
Finally you can try it out
How it works
Currently only the following return types are being corrected:
The functionality for this can be found in
In there the
getClassLikeNames() tells psalm on which classes it needs to
change return types.
getMethodReturnType() we check which method is currently called and
get the first argument value from that call.
With that value we get the "real" FQCN of the table which is returned in runtime
and tell psalm to use that instead of the default
I would definitely appreciate help related to the following aspects of this plugin:
- Including more return types like CakeDC/cakephp-phpstan already does for PHPStan