Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lordsimal/cakephp-psalm
A CakePHP plugin for psalm
https://github.com/lordsimal/cakephp-psalm
cakephp php psalm-plugin
Last synced: 4 months ago
JSON representation
A CakePHP plugin for psalm
- Host: GitHub
- URL: https://github.com/lordsimal/cakephp-psalm
- Owner: LordSimal
- Created: 2021-12-30T21:24:52.000Z (about 3 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-07-28T16:26:34.000Z (7 months ago)
- Last Synced: 2024-09-28T18:37:43.619Z (5 months ago)
- Topics: cakephp, php, psalm-plugin
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Psalm plugin for CakePHP
[![Latest Stable Version](https://poser.pugx.org/lordsimal/cakephp-psalm/v)](https://packagist.org/packages/lordsimal/cakephp-psalm) [![Total Downloads](https://poser.pugx.org/lordsimal/cakephp-psalm/downloads)](https://packagist.org/packages/lordsimal/cakephp-psalm) [![Latest Unstable Version](https://poser.pugx.org/lordsimal/cakephp-psalm/v/unstable)](https://packagist.org/packages/lordsimal/cakephp-psalm) [![License](https://poser.pugx.org/lordsimal/cakephp-psalm/license)](https://packagist.org/packages/lordsimal/cakephp-psalm)
## Overview
This plugin provides correct return types for CakePHP specific methods in psalm.## Quickstart
Please refer to the [full Psalm documentation](https://psalm.dev/quickstart) 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 `psalm.xml`
```bash
composer require --dev vimeo/psalm
./vendor/bin/psalm --init
```Next you will need to require this package and enable it in psalm
```bash
composer require --dev lordsimal/cakephp-psalm
./vendor/bin/psalm-plugin enable lordsimal/cakephp-psalm
```Finally you can try it out
```bash
./vendor/bin/psalm
```## How it works
Currently only the following return types are being corrected:
* `Cake\ORM\Locator\LocatorInterface::get()`
* `Cake\ORM\Locator\LocatorAwareTrait::fetchTable()`The functionality for this can be found in `src/Type/TableLocatorHandler.php`
In there the `getClassLikeNames()` tells psalm on which classes it needs to
change return types.In the `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 `Cake\ORM\Table`.## Help needed
I would definitely appreciate help related to the following aspects of this plugin:
* Testing
* Including more return types like [CakeDC/cakephp-phpstan](https://github.com/CakeDC/cakephp-phpstan) already does for PHPStan