Update PHPStan to 2.1.6
This commit is contained in:
parent
505faa33ad
commit
b940d9baf1
@ -8,14 +8,13 @@ parameters:
|
|||||||
paths:
|
paths:
|
||||||
- ./upload/
|
- ./upload/
|
||||||
excludePaths:
|
excludePaths:
|
||||||
- ./system/storage/vendor/
|
- ./tools/phpstan/
|
||||||
- ./upload/system/storage/vendor/
|
- ./upload/system/storage/vendor/
|
||||||
- ./upload/system/storage/cache/
|
- ./upload/system/storage/cache/
|
||||||
tmpDir: .cache
|
tmpDir: .cache
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '#^Access to an undefined property Opencart\\System\\Engine\\Proxy<Opencart\\Catalog\\Model\\Checkout\\Cart>::\$getTotals\.$#'
|
- '#^Access to an undefined property Opencart\\System\\Engine\\Proxy<Opencart\\Catalog\\Model\\Checkout\\Cart>::\$getTotals\.$#'
|
||||||
- '# always exists and is not #'
|
- '# always exists and is not #'
|
||||||
- '#^Call to an undefined method object::[a-zA-Z]+\(\)\.$#'
|
|
||||||
- '#^Constant [A-Z_]+ not found\.$#'
|
- '#^Constant [A-Z_]+ not found\.$#'
|
||||||
- '#^Empty array passed to foreach\.$#'
|
- '#^Empty array passed to foreach\.$#'
|
||||||
- '# is always (true|false)\.$#'
|
- '# is always (true|false)\.$#'
|
||||||
|
Binary file not shown.
@ -3,10 +3,10 @@
|
|||||||
namespace Tools\PHPStan;
|
namespace Tools\PHPStan;
|
||||||
|
|
||||||
use Opencart\System\Engine\Registry;
|
use Opencart\System\Engine\Registry;
|
||||||
use PHPStan\Broker\Broker;
|
|
||||||
use PHPStan\Reflection\ClassReflection;
|
use PHPStan\Reflection\ClassReflection;
|
||||||
use PHPStan\Reflection\PropertiesClassReflectionExtension;
|
use PHPStan\Reflection\PropertiesClassReflectionExtension;
|
||||||
use PHPStan\Reflection\PropertyReflection;
|
use PHPStan\Reflection\PropertyReflection;
|
||||||
|
use PHPStan\Reflection\ReflectionProvider;
|
||||||
use PHPStan\Type\Generic\GenericObjectType;
|
use PHPStan\Type\Generic\GenericObjectType;
|
||||||
use PHPStan\Type\NullType;
|
use PHPStan\Type\NullType;
|
||||||
use PHPStan\Type\ObjectType;
|
use PHPStan\Type\ObjectType;
|
||||||
@ -38,6 +38,8 @@ class RegistryPropertyReflectionExtension implements PropertiesClassReflectionEx
|
|||||||
'user' => \Opencart\System\Library\Cart\User::class,
|
'user' => \Opencart\System\Library\Cart\User::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function __construct(private ReflectionProvider $reflectionProvider) {}
|
||||||
|
|
||||||
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool {
|
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool {
|
||||||
if (!$classReflection->is(Registry::class)) {
|
if (!$classReflection->is(Registry::class)) {
|
||||||
return false;
|
return false;
|
||||||
@ -66,14 +68,12 @@ class RegistryPropertyReflectionExtension implements PropertiesClassReflectionEx
|
|||||||
$classType = $this->convertSnakeToStudly($matches[1]);
|
$classType = $this->convertSnakeToStudly($matches[1]);
|
||||||
$commonName = $this->convertSnakeToStudly($matches[2]);
|
$commonName = $this->convertSnakeToStudly($matches[2]);
|
||||||
|
|
||||||
$broker = Broker::getInstance();
|
|
||||||
|
|
||||||
$type = null;
|
$type = null;
|
||||||
foreach (['Admin', 'Catalog', 'Install'] as $domain) {
|
foreach (['Admin', 'Catalog', 'Install'] as $domain) {
|
||||||
$className1 = '\\Opencart\\' . $domain . '\\' . $classType . '\\' . $commonName;
|
$className1 = '\Opencart\\' . $domain . '\\' . $classType . '\\' . $commonName;
|
||||||
$className2 = preg_replace('/\\\\(?=[^\\\\]+$)/', '', $className1, 1);
|
$className2 = preg_replace('/\\\(?=[^\\\]+$)/', '', $className1, 1);
|
||||||
foreach ([$className1, $className2] as $className) {
|
foreach ([$className1, $className2] as $className) {
|
||||||
if ($broker->hasClass($className)) {
|
if ($this->reflectionProvider->hasClass($className)) {
|
||||||
$found = new ObjectType($className);
|
$found = new ObjectType($className);
|
||||||
if ($classType === 'Model') {
|
if ($classType === 'Model') {
|
||||||
$found = new GenericObjectType('\Opencart\System\Engine\Proxy', [$found]);
|
$found = new GenericObjectType('\Opencart\System\Engine\Proxy', [$found]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user