Skip to content

Commit

Permalink
Fixes after PHPStan update
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 30, 2024
1 parent 493457a commit 261b19d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/Rules/Doctrine/ORM/DqlRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\Doctrine\ObjectMetadataResolver;
use PHPStan\Type\ObjectType;
use PHPStan\Type\TypeUtils;
use function count;
use function sprintf;

Expand Down Expand Up @@ -54,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

$dqls = TypeUtils::getConstantStrings($scope->getType($node->getArgs()[0]->value));
$dqls = $scope->getType($node->getArgs()[0]->value)->getConstantStrings();
if (count($dqls) === 0) {
return [];
}
Expand Down
3 changes: 1 addition & 2 deletions src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPStan\Type\Doctrine\DoctrineTypeUtils;
use PHPStan\Type\Doctrine\ObjectMetadataResolver;
use PHPStan\Type\ObjectType;
use PHPStan\Type\TypeUtils;
use Throwable;
use function array_values;
use function count;
Expand Down Expand Up @@ -81,7 +80,7 @@ public function processNode(Node $node, Scope $scope): array
];
}

$dqls = TypeUtils::getConstantStrings($dqlType);
$dqls = $dqlType->getConstantStrings();
if (count($dqls) === 0) {
if ($this->reportDynamicQueryBuilders) {
return [
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Doctrine/ArgumentsProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function processArgs(
continue;
}

if ($value->isClassStringType()->yes() && count($value->getClassStringObjectType()->getObjectClassNames()) === 1) {
if ($value->isClassString()->yes() && count($value->getClassStringObjectType()->getObjectClassNames()) === 1) {
/** @var class-string $className */
$className = $value->getClassStringObjectType()->getObjectClassNames()[0];
if ($this->objectMetadataResolver->isTransient($className)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getTypeFromMethodCall(
);
}
$argType = $scope->getType($methodCall->getArgs()[0]->value);
if (!$argType->isClassStringType()->yes()) {
if (!$argType->isClassString()->yes()) {
return $this->getDefaultReturnType($scope, $methodCall->getArgs(), $methodReflection, $defaultRepositoryClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getTypeFromMethodCall(
$entityNameExpr = new MethodCall($methodCall->var, new Identifier('getEntityName'));

$entityNameExprType = $scope->getType($entityNameExpr);
if ($entityNameExprType->isClassStringType()->yes() && count($entityNameExprType->getClassStringObjectType()->getObjectClassNames()) === 1) {
if ($entityNameExprType->isClassString()->yes() && count($entityNameExprType->getClassStringObjectType()->getObjectClassNames()) === 1) {
$entityNameExpr = new String_($entityNameExprType->getClassStringObjectType()->getObjectClassNames()[0]);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ protected function getRule(): Rule
new StringType(),
new SimpleArrayType(),
new UuidTypeDescriptor(FakeTestingUuidType::class),
new ReflectionDescriptor(CarbonImmutableType::class, $this->createBroker(), self::getContainer()),
new ReflectionDescriptor(CarbonType::class, $this->createBroker(), self::getContainer()),
new ReflectionDescriptor(CustomType::class, $this->createBroker(), self::getContainer()),
new ReflectionDescriptor(CustomNumericType::class, $this->createBroker(), self::getContainer()),
new ReflectionDescriptor(CarbonImmutableType::class, $this->createReflectionProvider(), self::getContainer()),
new ReflectionDescriptor(CarbonType::class, $this->createReflectionProvider(), self::getContainer()),
new ReflectionDescriptor(CustomType::class, $this->createReflectionProvider(), self::getContainer()),
new ReflectionDescriptor(CustomNumericType::class, $this->createReflectionProvider(), self::getContainer()),
]),
$this->createReflectionProvider(),
true,
Expand Down

0 comments on commit 261b19d

Please sign in to comment.