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 Oct 4, 2024
1 parent 261b19d commit 4f51333
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/Rules/Doctrine/ORM/EntityColumnRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\ParserNodeTypeToPHPStanType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\TypehintHelper;
Expand Down Expand Up @@ -176,7 +175,7 @@ public function processNode(Node $node, Scope $scope): array
}

$phpDocType = $node->getPhpDocType();
$nativeType = $node->getNativeType() !== null ? ParserNodeTypeToPHPStanType::resolve($node->getNativeType(), $scope->getClassReflection()) : new MixedType();
$nativeType = $node->getNativeType() ?? new MixedType();
$propertyType = TypehintHelper::decideType($nativeType, $phpDocType);

if (get_class($propertyType) === MixedType::class || $propertyType instanceof ErrorType || $propertyType instanceof NeverType) {
Expand Down
3 changes: 1 addition & 2 deletions src/Rules/Doctrine/ORM/EntityRelationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\ParserNodeTypeToPHPStanType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\TypehintHelper;
use PHPStan\Type\VerbosityLevel;
Expand Down Expand Up @@ -96,7 +95,7 @@ public function processNode(Node $node, Scope $scope): array
}

$phpDocType = $node->getPhpDocType();
$nativeType = $node->getNativeType() !== null ? ParserNodeTypeToPHPStanType::resolve($node->getNativeType(), $scope->getClassReflection()) : new MixedType();
$nativeType = $node->getNativeType() ?? new MixedType();
$propertyType = TypehintHelper::decideType($nativeType, $phpDocType);

$errors = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class RowCountMethodDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string */
private string $class;

private ObjectMetadataResolver $objectMetadataResolver;
Expand All @@ -24,6 +25,9 @@ class RowCountMethodDynamicReturnTypeExtension implements DynamicMethodReturnTyp

private ReflectionProvider $reflectionProvider;

/**
* @param class-string $class
*/
public function __construct(
string $class,
ObjectMetadataResolver $objectMetadataResolver,
Expand Down
4 changes: 4 additions & 0 deletions src/Type/Doctrine/GetRepositoryDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ class GetRepositoryDynamicReturnTypeExtension implements DynamicMethodReturnType

private ?string $odmRepositoryClass = null;

/** @var class-string */
private string $managerClass;

private ObjectMetadataResolver $metadataResolver;

/**
* @param class-string $managerClass
*/
public function __construct(
ReflectionProvider $reflectionProvider,
?string $repositoryClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnType

private ArgumentsProcessor $argumentsProcessor;

/** @var class-string */
private string $class;

private ReflectionProvider $reflectionProvider;

/**
* @param class-string $class
*/
public function __construct(
ArgumentsProcessor $argumentsProcessor,
string $class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
class QueryBuilderGetDqlDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

/** @var class-string|null */
private ?string $queryBuilderClass = null;

/**
* @param class-string|null $queryBuilderClass
*/
public function __construct(
?string $queryBuilderClass
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class QueryBuilderGetQueryDynamicReturnTypeExtension implements DynamicMethodRet

private ArgumentsProcessor $argumentsProcessor;

/** @var class-string|null */
private ?string $queryBuilderClass = null;

private DescriptorRegistry $descriptorRegistry;
Expand All @@ -67,6 +68,9 @@ class QueryBuilderGetQueryDynamicReturnTypeExtension implements DynamicMethodRet

private DriverDetector $driverDetector;

/**
* @param class-string|null $queryBuilderClass
*/
public function __construct(
ObjectMetadataResolver $objectMetadataResolver,
ArgumentsProcessor $argumentsProcessor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ class QueryBuilderMethodDynamicReturnTypeExtension implements DynamicMethodRetur

private const MAX_COMBINATIONS = 16;

/** @var class-string|null */
private ?string $queryBuilderClass = null;

/**
* @param class-string|null $queryBuilderClass
*/
public function __construct(
?string $queryBuilderClass
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ class QueryBuilderTypeSpecifyingExtension implements MethodTypeSpecifyingExtensi

private const MAX_COMBINATIONS = 16;

/** @var class-string|null */
private ?string $queryBuilderClass = null;

private TypeSpecifier $typeSpecifier;

/**
* @param class-string|null $queryBuilderClass
*/
public function __construct(?string $queryBuilderClass)
{
$this->queryBuilderClass = $queryBuilderClass;
Expand Down
5 changes: 0 additions & 5 deletions stubs/MongoClassMetadataInfo.stub
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class ClassMetadata implements BaseClassMetadata
/** @var string|null */
public $customRepositoryClassName;

/**
* @var class-string<T>
*/
public $name;

/**
* @param class-string<T> $documentName
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class EntityRepositoryDynamicReturnIntegrationTest extends LevelsTestCase
/**
* @return string[][]
*/
public function dataTopics(): array
public static function dataTopics(): array
{
return [
['entityRepositoryDynamicReturn'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class EntityRepositoryWithoutObjectManagerLoaderDynamicReturnIntegrationTe
/**
* @return string[][]
*/
public function dataTopics(): array
public static function dataTopics(): array
{
return [
['entityRepositoryDynamicReturn'],
Expand Down
1 change: 1 addition & 0 deletions tests/Rules/Doctrine/ORM/FakeTestingUuidType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
return null;
}

/** @throws ConversionException */
return (string) $value;
}

Expand Down

0 comments on commit 4f51333

Please sign in to comment.