Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ariddlestone/phpstan-cakephp2
An extension to help test CakePHP 2 projects with PHPStan
https://github.com/ariddlestone/phpstan-cakephp2
cakephp2 php php7 phpstan-extension static-analysis static-code-analysis
Last synced: about 1 month ago
JSON representation
An extension to help test CakePHP 2 projects with PHPStan
- Host: GitHub
- URL: https://github.com/ariddlestone/phpstan-cakephp2
- Owner: ariddlestone
- License: mit
- Created: 2022-12-14T21:01:14.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-29T21:14:06.000Z (10 months ago)
- Last Synced: 2024-03-14T22:52:15.189Z (8 months ago)
- Topics: cakephp2, php, php7, phpstan-extension, static-analysis, static-code-analysis
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPStan-CakePHP2
PHPStan extensions to help test CakePHP 2 projects with PHPStan## Requirements
* PHP 7.4
* phpstan/phpstan 1.9+
* cakephp/cakephp 2.x## Installation
Installation is best done through composer:
```shell
composer require --dev ariddlestone/phpstan-cakephp2
```You will need to make sure the extension is included in your phpstan config:
```yaml
# phpstan.neon
includes:
- vendor/ariddlestone/phpstan-cakephp2/extension.neon
```If you have behavior classes in odd locations (perhaps in a vendor directory) you will need to add those locations to
your configuration. For example:
```yaml
# phpstan.neon
parameters:
ModelBehaviorsExtension:
behaviorPaths:
- vendor/my-vendor/my-plugin/src/Model/Behavior/*.php
```
See `extension.neon` for the default list of behavior locations.## Features
The following features are added to PHPStan:
* Treat behavior methods as extra methods on all models (`$model->behaviorMethod()`)
* Treat controller properties named after model classes as instances of those classes (`$controller->Model`)
* Treat controller properties named after component classes as instances of those classes (`$controller->Component`)
* Treat component properties names after component classes as instances of those classes (`$component->Component`)
* Treat `ClassRegistry::init($className)` as returning an instance of `$className` where possible