[PHPStan] Update to PHPStan ^1.7.0 (#2354)

* [PHPStan] Update to PHPStan ^1.7.0

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* already 1.7.1

* skip pull from PHPStan PhpPropertyReflection

* rename fixture

* debug

* Fixed 🎉

* keep mysqli object use case

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2022-05-24 19:55:12 +07:00 committed by GitHub
parent a14bd26655
commit dc9189280f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 49 deletions

View File

@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "1.6.9"
"phpstan/phpstan": "^1.7.1"
},
"autoload": {
"files": [

View File

@ -22,7 +22,7 @@
"nikic/php-parser": "^4.13.2",
"ondram/ci-detector": "^4.1",
"phpstan/phpdoc-parser": "^1.5.1",
"phpstan/phpstan": "1.6.9",
"phpstan/phpstan": "^1.7.1",
"phpstan/phpstan-phpunit": "^1.0",
"psr/log": "^2.0",
"react/child-process": "^0.6.4",

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector\Fixture;
use PHPStan\Reflection\Php\PhpPropertyReflection;
class PullFromPHPStanReflection
{
public function get(PhpPropertyReflection $phpPropertyReflection)
{
$reflectionProperty = $phpPropertyReflection->getNativeReflection();
return is_array($reflectionProperty->getDefaultValue());
}
}
?>
-----
<?php
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector\Fixture;
use PHPStan\Reflection\Php\PhpPropertyReflection;
class PullFromPHPStanReflection
{
public function get(PhpPropertyReflection $phpPropertyReflection)
{
$reflectionProperty = $phpPropertyReflection->getNativeReflection();
return is_array($reflectionProperty->getDeclaringClass()->getDefaultProperties()[$reflectionProperty->getName()] ?? null);
}
}
?>

View File

@ -0,0 +1,14 @@
<?php
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector\Fixture;
use PHPStan\Reflection\Php\PhpPropertyReflection;
class SkipPullFromPHPStanReflection
{
public function get(PhpPropertyReflection $phpPropertyReflection)
{
$reflectionProperty = $phpPropertyReflection->getNativeReflection();
return is_array($reflectionProperty->getDefaultValue());
}
}

View File

@ -16,10 +16,6 @@ final class SetTest extends AbstractRectorTestCase
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->markTestSkipped(
'@todo update rules to handle both rename + argumentt adding at the same time; otherwise lost during scope update'
);
$this->doTestFileInfo($fileInfo);
}

View File

@ -193,14 +193,14 @@ CODE_SAMPLE
return null;
}
$reflectionClass = $classReflection->getNativeReflection();
$nativeReflection = $classReflection->getNativeReflection();
if (! $reflectionClass->hasMethod($methodName)) {
if (! $nativeReflection->hasMethod($methodName)) {
return null;
}
// Find the param we're looking for
return $reflectionClass->getMethod($methodName);
return $nativeReflection->getMethod($methodName);
}
private function getDifferentParamTypeFromReflectionMethod(

View File

@ -185,7 +185,11 @@ CODE_SAMPLE
return false;
}
return $this->isObjectType($node->expr, new ObjectType('mysqli'));
if ($this->isObjectType($node->expr, new ObjectType('mysqli'))) {
return true;
}
return $node->expr instanceof FuncCall && $this->nodeNameResolver->isName($node->expr, 'mysqli_connect');
});
if (! $connectionAssign instanceof Assign) {

View File

@ -179,9 +179,9 @@ CODE_SAMPLE
}
$classReflection = $this->reflectionProvider->getClass($className);
$reflectionClass = $classReflection->getNativeReflection();
$nativeReflection = $classReflection->getNativeReflection();
$reflectionMethod = $reflectionClass->getConstructor();
$reflectionMethod = $nativeReflection->getConstructor();
if (! $reflectionMethod instanceof ReflectionMethod) {
return true;
}

View File

@ -32,9 +32,9 @@ final class ClassConstantsResolver
}
$classReflection = $this->reflectionProvider->getClass($classWithConstants);
$reflectionClass = $classReflection->getNativeReflection();
$nativeReflection = $classReflection->getNativeReflection();
$constantNamesToValues = $reflectionClass->getConstants();
$constantNamesToValues = $nativeReflection->getConstants();
$this->cachedConstantNamesToValues = $constantNamesToValues;
return $constantNamesToValues;

View File

@ -149,8 +149,8 @@ final class PropertyPresenceChecker
{
$propertyNames = [];
$reflectionClass = $classReflection->getNativeReflection();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
$nativeReflection = $classReflection->getNativeReflection();
foreach ($nativeReflection->getProperties() as $reflectionProperty) {
if ($reflectionProperty->isPrivate()) {
continue;
}