ariddlestone / phpstan-cakephp2 Goto Github PK
View Code? Open in Web Editor NEWAn extension to help test CakePHP 2 projects with PHPStan
License: MIT License
An extension to help test CakePHP 2 projects with PHPStan
License: MIT License
Components can themselves have components using the $components
property. We should add a property reflection extension to support this.
$event
in before()
and after()
Apply to all files which extend CakeSchema
.
composer.json
says that PHP versions 7.2-8.x should work, but there are issues running it on versions other than 7.4:
composer install
fails, with required libraries not being compatible with PHP < 7.4composer phpstan
fails because a ReflectionEnum
class we use is not compatible with PHP < 7.4 (due to phpstan bundling its dependencies, but not updating its requirements to match)Create a stub to correct the return type of ShellDispatcher::run()
from void
to 1|0
.
Console commands can have task properties, named after the task.
When checking whether a model exists (determining the types of controller properties, for example), check app/Config/schema.php if it exists, to get tables which don't have models. If it does, return a generic Model type.
Feature Request to handle Loading components on the fly
Models can have other models as properties, through relationships.
The properties are named after the relationship name, which is not necessarily the same as the model name.
Some people are trying to get CakePHP 2 running on PHP8...
They're mad, but we'll let them use this package to help.
If we allow PHP8, the require-dev list will still prevent development of this package, as the cakephp/cakephp ^2.10.24 requirement won't allow it.
Hi.
Thanks for this brilliant extension first of all.
I'm working with project where all Models don't have Model
suffix. Like described in the official documentation (https://book.cakephp.org/2/en/models.html#understanding-models)
So in case we have Component and Model with the same name it leads to Call to an undefined method BasicComponent::some_method
.
Code sample:
<?php
class BasicComponent extends Component {}
<?php
class Basic extends Model
{
public function some_method()
{
}
}
<?php
class FakeController extends Controller
{
public $uses = [
'Basic',
];
public function add_smth()
{
$this->Basic->some_method();
}
}
As I can see component service is setup first so probably it found BasicComponent
and tries to look method inside of it only and doesn't take into account that models is also exists.
We should add the following details to the README.md file:
Console Commands can have model properties, named after the model name (like controllers).
Several of the functions in basics.php have the wrong return type. We should fix that.
ClassRegistry::init()
generally returns an instance of the class name provided. We should add a stub to indicate this.
Add stubs and/or extensions to handle things like
find('count')
returning int|false
(not array
)findByX
findAllByX
Controller component properties do not include the "Component" suffix. The test should be changed as follows:
From:
/** @var BasicController $controller */
$component = $controller->BasicComponent;
assertType('BasicComponent', $component);
to:
/** @var BasicController $controller */
$component = $controller->Basic;
assertType('BasicComponent', $component);
FlashComponent::_call($name, $args)
renders the message using app/View/Element/Flash/$name.ctp
.
For example, $controller->Flash->success('My message')
would render the message using app/View/Element/success.ctp
.
We should check for the template's existence, and then provide the correct types etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.