Download the PHP package cakedc/cakephp-phpstan without Composer

On this page you can find all versions of the php package cakedc/cakephp-phpstan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cakephp-phpstan

CakePHP extension for PHPStan

Build Status Downloads Latest Version

Provide services and rules for a better PHPStan analyze on CakePHP applications, includes services to resolve types (Table, Helpers, Behaviors, etc) and multiple rules.

Installation

To use this extension, require it through Composer:

If you also install phpstan/extension-installer, then you're all set!

Manual installation If you don't want to use `phpstan/extension-installer`, include `extension.neon` in your project's PHPStan config:

General class load|fetch extensions

Features included:

  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::fetchTable()
  4. Provide correct return type for Cake\Controller\Component::fetchTable()
  5. Provide correct return type for Cake\Command\Command::fetchTable()
  6. Provide correct return type for Cake\Mailer\Mailer::fetchTable()
  7. Provide correct return type for Cake\View\Cell::fetchTable()
  8. Provide correct return type for Cake\Console\ConsoleIo::helper()

Table class return type extensions

TableEntityDynamicReturnTypeExtension

  1. Provide correct return type for Cake\ORM\Table::get based on your table class name
  2. Provide correct return type for Cake\ORM\Table::newEntity based on your table class name
  3. Provide correct return type for Cake\ORM\Table::newEntities based on your table class name
  4. Provide correct return type for Cake\ORM\Table::newEmptyEntity based on your table class name
  5. Provide correct return type for Cake\ORM\Table::findOrCreate based on your table class name
Examples:

TableFirstArgIsTheReturnTypeExtension

  1. Provide correct return type for Cake\ORM\Table::patchEntity based on the first argument passed
  2. Provide correct return type for Cake\ORM\Table::patchEntities based on the first argument passed
  3. Provide correct return type for Cake\ORM\Table::save based on the first argument passed
  4. Provide correct return type for Cake\ORM\Table::saveOrFail based on the first argument passed
  5. Provide correct return type for Cake\ORM\Table::saveMany based on the first argument passed
  6. Provide correct return type for Cake\ORM\Table::saveManyOrFail based on the first argument passed
  7. Provide correct return type for Cake\ORM\Table::deleteMany based on the first argument passed
  8. Provide correct return type for Cake\ORM\Table::deleteManyOrFail based on the first argument passed
  9. Provide correct return type for Cake\ORM\Locator\LocatorAwareTrait::fetchTable based on the first argument passed
  10. Provide correct return type for Cake\Mailer\MailerAwareTrait::getMailer based on the first argument passed
Examples:

Rules

All rules provided by this library are included in rules.neon and are enabled by default:

AddAssociationExistsTableClassRule

This rule check if the target association has a valid table class when calling to Table::belongsTo, Table::hasMany, Table::belongsToMany, Table::hasOne and AssociationCollection::load.

AddAssociationMatchOptionsTypesRule

This rule check if association options are valid option types based on what each class expects. This cover calls to Table::belongsTo, Table::hasMany, Table::belongsToMany, Table::hasOne and AssociationCollection::load.

AddBehaviorExistsClassRule

This rule check if the target behavior has a valid class when calling to Table::addBehavior and BehaviorRegistry::load.

DisallowEntityArrayAccessRule

This rule disallow array access to entity in favor of object notation, is easier to detect a wrong property and to refactor code.

GetMailerExistsClassRule

This rule check if the target mailer is a valid class when calling to Cake\Mailer\MailerAwareTrait::getMailer.

LoadComponentExistsClassRule

This rule check if the target component has a valid class when calling to Controller::loadComponent and ComponentRegistry::load.

OrmSelectQueryFindMatchOptionsTypesRule

This rule check if the options (args) passed to Table::find and SelectQuery are valid find options types.

TableGetMatchOptionsTypesRule

This rule check if the options (args) passed to Table::get are valid find options types.

To enable this rule update your phpstan.neon with:

How to disable a rule

Each rule has a parameter in cakeDC 'namespace' to enable or disable, it is the same name of the rule with first letter in lowercase. For example to disable the rule AddAssociationExistsTableClassRule you should have

PHPDoc Extensions

TableAssociationTypeNodeResolverExtension

Fix intersection association phpDoc to correct generic object type, ex:

Change \Cake\ORM\Association\BelongsTo&\App\Model\Table\UsersTable to \Cake\ORM\Association\BelongsTo<\App\Model\Table\UsersTable>

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.


All versions of cakephp-phpstan with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
phpstan/phpstan Version ^2.0
cakephp/cakephp Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cakedc/cakephp-phpstan contains the following files

Loading the files please wait ....