Skip to content

Commit

Permalink
[PHPStan] Update to PHPStan ^1.7.0 (#2354)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
samsonasik and actions-user committed May 24, 2022
1 parent a14bd26 commit dc91892
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 49 deletions.
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "1.6.9"
"phpstan/phpstan": "^1.7.1"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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());
}
}
4 changes: 0 additions & 4 deletions rules-tests/MysqlToMysqli/SetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ private function resolveParentReflectionMethod(
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ private function findConnectionVariable(FuncCall $funcCall): ?Expr
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ private function isInstantiable(string $className): bool
}

$classReflection = $this->reflectionProvider->getClass($className);
$reflectionClass = $classReflection->getNativeReflection();
$nativeReflection = $classReflection->getNativeReflection();

$reflectionMethod = $reflectionClass->getConstructor();
$reflectionMethod = $nativeReflection->getConstructor();
if (! $reflectionMethod instanceof ReflectionMethod) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions rules/Privatization/Reflection/ClassConstantsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function getClassConstantNamesToValues(string $classWithConstants): array
}

$classReflection = $this->reflectionProvider->getClass($classWithConstants);
$reflectionClass = $classReflection->getNativeReflection();
$nativeReflection = $classReflection->getNativeReflection();

$constantNamesToValues = $reflectionClass->getConstants();
$constantNamesToValues = $nativeReflection->getConstants();
$this->cachedConstantNamesToValues = $constantNamesToValues;

return $constantNamesToValues;
Expand Down
4 changes: 2 additions & 2 deletions src/NodeAnalyzer/PropertyPresenceChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ private function resolveNonPrivatePropertyNames(ClassReflection $classReflection
{
$propertyNames = [];

$reflectionClass = $classReflection->getNativeReflection();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
$nativeReflection = $classReflection->getNativeReflection();
foreach ($nativeReflection->getProperties() as $reflectionProperty) {
if ($reflectionProperty->isPrivate()) {
continue;
}
Expand Down

0 comments on commit dc91892

Please sign in to comment.