Awesome
CakePHP 4 extension for PHPStan
This extension provides following features:
- Provide correct return type for
Cake\ORM\Locator\LocatorInterface::get()
- Provide correct return type for
Cake\Controller\Controller::loadComponent()
- Provide correct return type for
Cake\Controller\Controller::loadModel()
- Provide correct return type for
Cake\Controller\Component::loadModel()
- Provide correct return type for
Cake\Command\Command::loadModel()
- Provide correct return type for
Cake\Console\Shell::loadModel()
- Provide correct return type for
Cake\Mailer\Mailer::loadModel()
- Provide correct return type for
Cake\View\Cell::loadModel()
- Provide correct return type for
Cake\Controller\Controller::fetchTable()
- Provide correct return type for
Cake\Controller\Component::fetchTable()
- Provide correct return type for
Cake\Command\Command::fetchTable()
- Provide correct return type for
Cake\Console\Shell::fetchTable()
- Provide correct return type for
Cake\Mailer\Mailer::fetchTable()
- Provide correct return type for
Cake\View\Cell::fetchTable()
- Provide correct return type for
Cake\Console\Shell::helper()
- Provide correct return type for
Cake\Console\ConsoleIo::helper()
Installation
To use this extension, require it through Composer:
composer require --dev cakedc/cakephp-phpstan
If you also install phpstan/extension-installer, then you're all set!
<details> <summary>Manual installation</summary>If you don't want to use phpstan/extension-installer
, include extension.neon
in your project's PHPStan config:
includes:
- vendor/cakedc/cakephp-phpstan/extension.neon
</details>
Tips
To make your life easier make sure to have @mixin
and @method
annotations in your table classes.
The @mixin
annotation will help phpstan know you are using methods from behavior, and @method
annotations
will allow it to know the correct return types for methods like Table::get()
, Table::newEntity()
.
You can easily update annotations with the plugin IdeHelper.
Support
For bugs and feature requests, please use the issues section of this repository.
Commercial support is also available, contact us for more information.
Contributing
If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our Contribution Guidelines for detailed instructions.
License
Copyright 2020 Cake Development Corporation (CakeDC). All rights reserved.
Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file