From 49c78bfa059b203714b1b45cbe4cc53631ed74b0 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 7 Nov 2024 17:46:32 +0100 Subject: [PATCH] native types --- src/Analyzer/QueryPlanResult.php | 7 ++----- src/Ast/ExpressionFinder.php | 5 +---- src/Ast/PreviousConnectingVisitor.php | 7 ++----- src/DbSchema/LazySchemaHasher.php | 5 +---- src/DbSchema/SchemaHasherMysql.php | 5 +---- src/Error.php | 5 +---- ...liEscapeStringDynamicReturnTypeExtension.php | 5 +---- .../MysqliQueryDynamicReturnTypeExtension.php | 5 +---- .../PdoPrepareDynamicReturnTypeExtension.php | 5 +---- .../PdoQueryDynamicReturnTypeExtension.php | 5 +---- .../PdoQuoteDynamicReturnTypeExtension.php | 5 +---- ...oStatementExecuteTypeSpecifyingExtension.php | 5 +---- ...StatementFetchDynamicReturnTypeExtension.php | 12 +++--------- ...entFetchObjectDynamicReturnTypeExtension.php | 5 +---- ...ementSetFetchModeTypeSpecifyingExtension.php | 5 +---- src/QueryReflection/BasePdoQueryReflector.php | 9 +++------ src/QueryReflection/ChainedReflector.php | 2 +- src/QueryReflection/LazyQueryReflector.php | 10 ++-------- src/QueryReflection/Parameter.php | 17 ++++------------- src/QueryReflection/QueryReflection.php | 15 +++------------ src/QueryReflection/RecordingQueryReflector.php | 12 +++--------- 21 files changed, 35 insertions(+), 116 deletions(-) diff --git a/src/Analyzer/QueryPlanResult.php b/src/Analyzer/QueryPlanResult.php index c7562292a..36e5b05a5 100644 --- a/src/Analyzer/QueryPlanResult.php +++ b/src/Analyzer/QueryPlanResult.php @@ -15,12 +15,9 @@ final class QueryPlanResult /** * @var array */ - private $result = []; + private array $result = []; - /** - * @var string - */ - private $simulatedQuery; + private string $simulatedQuery; public function __construct(string $simulatedQuery) { diff --git a/src/Ast/ExpressionFinder.php b/src/Ast/ExpressionFinder.php index 00b5aa0e4..d24ec7187 100644 --- a/src/Ast/ExpressionFinder.php +++ b/src/Ast/ExpressionFinder.php @@ -16,10 +16,7 @@ final class ExpressionFinder { - /** - * @var NodeFinder - */ - private $nodeFinder; + private NodeFinder $nodeFinder; public function __construct() { diff --git a/src/Ast/PreviousConnectingVisitor.php b/src/Ast/PreviousConnectingVisitor.php index 99bce29b5..21a5a7e66 100644 --- a/src/Ast/PreviousConnectingVisitor.php +++ b/src/Ast/PreviousConnectingVisitor.php @@ -17,12 +17,9 @@ final class PreviousConnectingVisitor extends NodeVisitorAbstract /** * @var list */ - private $stack = []; + private array $stack = []; - /** - * @var ?Node - */ - private $previous; + private ?Node $previous; public function beforeTraverse(array $nodes) { diff --git a/src/DbSchema/LazySchemaHasher.php b/src/DbSchema/LazySchemaHasher.php index 66ab22ae0..c97bf7003 100644 --- a/src/DbSchema/LazySchemaHasher.php +++ b/src/DbSchema/LazySchemaHasher.php @@ -11,10 +11,7 @@ class LazySchemaHasher implements SchemaHasher */ private $schemaHasherFactory; - /** - * @var SchemaHasher|null - */ - private $schemaHasher; + private ?SchemaHasher $schemaHasher; /** * @param callable():SchemaHasher $schemaHasherFactory diff --git a/src/DbSchema/SchemaHasherMysql.php b/src/DbSchema/SchemaHasherMysql.php index dbeac5660..677055184 100644 --- a/src/DbSchema/SchemaHasherMysql.php +++ b/src/DbSchema/SchemaHasherMysql.php @@ -15,10 +15,7 @@ final class SchemaHasherMysql implements SchemaHasher */ private $connection; - /** - * @var string|null - */ - private $hash = null; + private ?string $hash = null; /** * @param PDO|mysqli $connection diff --git a/src/Error.php b/src/Error.php index ba380d857..2854b4280 100644 --- a/src/Error.php +++ b/src/Error.php @@ -15,10 +15,7 @@ */ final class Error { - /** - * @var string - */ - private $message; + private string $message; /** * @var ErrorCodes diff --git a/src/Extensions/MysqliEscapeStringDynamicReturnTypeExtension.php b/src/Extensions/MysqliEscapeStringDynamicReturnTypeExtension.php index 914112702..422489b32 100644 --- a/src/Extensions/MysqliEscapeStringDynamicReturnTypeExtension.php +++ b/src/Extensions/MysqliEscapeStringDynamicReturnTypeExtension.php @@ -25,10 +25,7 @@ final class MysqliEscapeStringDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension, DynamicFunctionReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; + private PhpVersion $phpVersion; public function __construct(PhpVersion $phpVersion) { diff --git a/src/Extensions/MysqliQueryDynamicReturnTypeExtension.php b/src/Extensions/MysqliQueryDynamicReturnTypeExtension.php index 1b1718b6a..7bf71249e 100644 --- a/src/Extensions/MysqliQueryDynamicReturnTypeExtension.php +++ b/src/Extensions/MysqliQueryDynamicReturnTypeExtension.php @@ -26,10 +26,7 @@ final class MysqliQueryDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension, DynamicFunctionReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; + private PhpVersion $phpVersion; public function __construct(PhpVersion $phpVersion) { diff --git a/src/Extensions/PdoPrepareDynamicReturnTypeExtension.php b/src/Extensions/PdoPrepareDynamicReturnTypeExtension.php index f26780038..e57e9164d 100644 --- a/src/Extensions/PdoPrepareDynamicReturnTypeExtension.php +++ b/src/Extensions/PdoPrepareDynamicReturnTypeExtension.php @@ -22,10 +22,7 @@ final class PdoPrepareDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; + private PhpVersion $phpVersion; public function __construct(PhpVersion $phpVersion) { diff --git a/src/Extensions/PdoQueryDynamicReturnTypeExtension.php b/src/Extensions/PdoQueryDynamicReturnTypeExtension.php index d96c74d85..bb6a487ab 100644 --- a/src/Extensions/PdoQueryDynamicReturnTypeExtension.php +++ b/src/Extensions/PdoQueryDynamicReturnTypeExtension.php @@ -24,10 +24,7 @@ final class PdoQueryDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; + private PhpVersion $phpVersion; public function __construct(PhpVersion $phpVersion) { diff --git a/src/Extensions/PdoQuoteDynamicReturnTypeExtension.php b/src/Extensions/PdoQuoteDynamicReturnTypeExtension.php index 27f67c76d..1a4cf50f5 100644 --- a/src/Extensions/PdoQuoteDynamicReturnTypeExtension.php +++ b/src/Extensions/PdoQuoteDynamicReturnTypeExtension.php @@ -24,10 +24,7 @@ final class PdoQuoteDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; + private PhpVersion $phpVersion; public function __construct(PhpVersion $phpVersion) { diff --git a/src/Extensions/PdoStatementExecuteTypeSpecifyingExtension.php b/src/Extensions/PdoStatementExecuteTypeSpecifyingExtension.php index 2eb961a47..1418390b3 100644 --- a/src/Extensions/PdoStatementExecuteTypeSpecifyingExtension.php +++ b/src/Extensions/PdoStatementExecuteTypeSpecifyingExtension.php @@ -20,10 +20,7 @@ final class PdoStatementExecuteTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { - /** - * @var TypeSpecifier - */ - private $typeSpecifier; + private TypeSpecifier $typeSpecifier; public function getClass(): string { diff --git a/src/Extensions/PdoStatementFetchDynamicReturnTypeExtension.php b/src/Extensions/PdoStatementFetchDynamicReturnTypeExtension.php index 3cb635976..64178009a 100644 --- a/src/Extensions/PdoStatementFetchDynamicReturnTypeExtension.php +++ b/src/Extensions/PdoStatementFetchDynamicReturnTypeExtension.php @@ -26,15 +26,9 @@ final class PdoStatementFetchDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** - * @var PhpVersion - */ - private $phpVersion; - - /** - * @var ReflectionProvider - */ - private $reflectionProvider; + private PhpVersion $phpVersion; + + private ReflectionProvider $reflectionProvider; public function __construct(PhpVersion $phpVersion, ReflectionProvider $reflectionProvider) { diff --git a/src/Extensions/PdoStatementFetchObjectDynamicReturnTypeExtension.php b/src/Extensions/PdoStatementFetchObjectDynamicReturnTypeExtension.php index e0c1517bb..c95fbdb88 100644 --- a/src/Extensions/PdoStatementFetchObjectDynamicReturnTypeExtension.php +++ b/src/Extensions/PdoStatementFetchObjectDynamicReturnTypeExtension.php @@ -18,10 +18,7 @@ final class PdoStatementFetchObjectDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** - * @var ReflectionProvider - */ - private $reflectionProvider; + private ReflectionProvider $reflectionProvider; public function __construct(ReflectionProvider $reflectionProvider) { diff --git a/src/Extensions/PdoStatementSetFetchModeTypeSpecifyingExtension.php b/src/Extensions/PdoStatementSetFetchModeTypeSpecifyingExtension.php index c4101b5cc..724f5a7c9 100644 --- a/src/Extensions/PdoStatementSetFetchModeTypeSpecifyingExtension.php +++ b/src/Extensions/PdoStatementSetFetchModeTypeSpecifyingExtension.php @@ -18,10 +18,7 @@ final class PdoStatementSetFetchModeTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { - /** - * @var TypeSpecifier - */ - private $typeSpecifier; + private TypeSpecifier $typeSpecifier; public function getClass(): string { diff --git a/src/QueryReflection/BasePdoQueryReflector.php b/src/QueryReflection/BasePdoQueryReflector.php index 434978e0e..2a21375df 100644 --- a/src/QueryReflection/BasePdoQueryReflector.php +++ b/src/QueryReflection/BasePdoQueryReflector.php @@ -55,7 +55,7 @@ abstract class BasePdoQueryReflector implements QueryReflector, RecordingReflect /** * @var array|null> */ - protected $cache = []; + protected array $cache = []; /** * @var TypeMapper @@ -71,12 +71,9 @@ abstract class BasePdoQueryReflector implements QueryReflector, RecordingReflect /** * @var array>> */ - protected $emulatedFlags = []; + protected array $emulatedFlags = []; - /** - * @var PDO - */ - protected $pdo; + protected PDO $pdo; public function __construct(PDO $pdo) { diff --git a/src/QueryReflection/ChainedReflector.php b/src/QueryReflection/ChainedReflector.php index 3b0b95f1d..535ab8edf 100644 --- a/src/QueryReflection/ChainedReflector.php +++ b/src/QueryReflection/ChainedReflector.php @@ -12,7 +12,7 @@ final class ChainedReflector implements QueryReflector /** * @var QueryReflector[] */ - private $reflectors; + private array $reflectors; /** * @param QueryReflector ...$reflectors diff --git a/src/QueryReflection/LazyQueryReflector.php b/src/QueryReflection/LazyQueryReflector.php index d0d0933d7..c3522d66c 100644 --- a/src/QueryReflection/LazyQueryReflector.php +++ b/src/QueryReflection/LazyQueryReflector.php @@ -14,15 +14,9 @@ final class LazyQueryReflector implements QueryReflector, RecordingReflector */ private $reflectorFactory; - /** - * @var QueryReflector|null - */ - private $reflector; + private ?QueryReflector $reflector; - /** - * @var DbaApi|null - */ - private $dbaApi; + private ?DbaApi $dbaApi; /** * @param callable():QueryReflector $reflectorFactory diff --git a/src/QueryReflection/Parameter.php b/src/QueryReflection/Parameter.php index 502b5ebb2..57b2102d4 100644 --- a/src/QueryReflection/Parameter.php +++ b/src/QueryReflection/Parameter.php @@ -14,22 +14,13 @@ final class Parameter /** * @var non-empty-string|null */ - public $name; + public ?string $name = null; - /** - * @var Type - */ - public $type; + public Type $type; - /** - * @var ?string - */ - public $simulatedValue; + public ?string $simulatedValue = null; - /** - * @var bool - */ - public $isOptional; + public bool $isOptional; /** * @param non-empty-string|null $name diff --git a/src/QueryReflection/QueryReflection.php b/src/QueryReflection/QueryReflection.php index 1f3f06e96..05c06288c 100644 --- a/src/QueryReflection/QueryReflection.php +++ b/src/QueryReflection/QueryReflection.php @@ -44,20 +44,11 @@ final class QueryReflection private const REGEX_NAMED_PLACEHOLDER = '{(["\'])((?:(?!\1)(?s:.))*\1)|(' . self::NAMED_PATTERN . ')}'; - /** - * @var QueryReflector|null - */ - private static $reflector; + private static ?QueryReflector $reflector = null; - /** - * @var RuntimeConfiguration|null - */ - private static $runtimeConfiguration; + private static ?RuntimeConfiguration $runtimeConfiguration = null; - /** - * @var SchemaReflection - */ - private $schemaReflection; + private ?SchemaReflection $schemaReflection = null; public function __construct(?DbaApi $dbaApi = null) { diff --git a/src/QueryReflection/RecordingQueryReflector.php b/src/QueryReflection/RecordingQueryReflector.php index 197560966..4ff9ea4b5 100644 --- a/src/QueryReflection/RecordingQueryReflector.php +++ b/src/QueryReflection/RecordingQueryReflector.php @@ -9,15 +9,9 @@ final class RecordingQueryReflector implements QueryReflector, RecordingReflector { - /** - * @var ReflectionCache - */ - private $reflectionCache; - - /** - * @var QueryReflector - */ - private $reflector; + private ReflectionCache $reflectionCache; + + private QueryReflector $reflector; public function __construct(ReflectionCache $cache, QueryReflector $wrappedReflector) {