Home

Awesome

CakePHP 4 extension for PHPStan

Build Status Downloads Latest Version License

This extension provides following features:

  1. Provide correct return type for Cake\ORM\Locator\LocatorInterface::get()
  2. Provide correct return type for Cake\Controller\Controller::loadComponent()
  3. Provide correct return type for Cake\Controller\Controller::loadModel()
  4. Provide correct return type for Cake\Controller\Component::loadModel()
  5. Provide correct return type for Cake\Command\Command::loadModel()
  6. Provide correct return type for Cake\Console\Shell::loadModel()
  7. Provide correct return type for Cake\Mailer\Mailer::loadModel()
  8. Provide correct return type for Cake\View\Cell::loadModel()
  9. Provide correct return type for Cake\Controller\Controller::fetchTable()
  10. Provide correct return type for Cake\Controller\Component::fetchTable()
  11. Provide correct return type for Cake\Command\Command::fetchTable()
  12. Provide correct return type for Cake\Console\Shell::fetchTable()
  13. Provide correct return type for Cake\Mailer\Mailer::fetchTable()
  14. Provide correct return type for Cake\View\Cell::fetchTable()
  15. Provide correct return type for Cake\Console\Shell::helper()
  16. 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