looglecz/phpstan-magento2-extension
最新稳定版本:v0.1.8
Composer 安装命令:
composer require looglecz/phpstan-magento2-extension
包简介
Get best of PHPStan with respect to some Magento2 specialities
README 文档
README
This repository contains set of rule and exclusions for PHPStan in order to be able to get best of the PHPStan static analysis with respect to some nasty things Magento does.
Exclusion of errors
- Missing type in interceptor method
- Since you need to copy part of the original method's signature, you are sometimes forced to use not-well typed arguments. This extension will ignore such errors.
Stubs
Various stubs for different classes that are vaguely typed or there is error in the type hint.
Collection templates
Magneto 2 collections offers you a way how to manipulate with objects in bulk. However, PHPStan cannot interfere specific type of item from the collection itself. In this extension, there are stubs for the Collection classes that allows you to have properly typed collection items that can help you with static analysis.
Stubs are available for following classes:
\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection\Magento\Framework\Data\Collection\AbstractDb\Magento\Framework\Data\Collection
Usage
All you need to do is include @extends AbstractCollection<\Vendor\Module\Model\Element> in class-level PHPDoc. For example:
<?php declare(strict_types=1); namespace Vendor\Module\Model\ResourceModel\Element; use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; /** * @extends AbstractCollection<\Vendor\Module\Model\Element> */ class Collection extends AbstractCollection { protected function _construct() { $this->_init( \Vendor\Module\Model\Element::class, \Vendor\Module\Model\ResourceModel\Element::class ); } }
If you do not work with DB collection, you will use similar annotation for other collection classes.
统计信息
- 总下载量: 464
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-01-15