From 65026a8d28cb9d6c88ac639364aa2fb9f9d69348 Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 23 Aug 2024 11:35:36 +0200 Subject: [PATCH] [Fix] Remaining undefined property fix --- phpstan.neon.dist | 8 ++- tests/PHPStan/CustomPropertyReflection.php | 69 +++++++++++++++++++ ...UserPropertiesClassReflectionExtension.php | 22 ++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 tests/PHPStan/CustomPropertyReflection.php create mode 100644 tests/PHPStan/UserPropertiesClassReflectionExtension.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a91953b..7804321 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -8,7 +8,9 @@ parameters: - config - database tmpDir: build/phpstan - checkOctaneCompatibility: true - checkModelProperties: true - checkMissingIterableValueType: false +services: + - + class: Vormkracht10\TwoFactorAuth\Tests\PHPStan\UserPropertiesClassReflectionExtension + tags: + - phpstan.broker.propertiesClassReflectionExtension \ No newline at end of file diff --git a/tests/PHPStan/CustomPropertyReflection.php b/tests/PHPStan/CustomPropertyReflection.php new file mode 100644 index 0000000..c178e3c --- /dev/null +++ b/tests/PHPStan/CustomPropertyReflection.php @@ -0,0 +1,69 @@ +declaringClass = $declaringClass; + $this->type = $type; + } + + public function getDeclaringClass(): ClassReflection + { + return $this->declaringClass; + } + + public function getType(): Type + { + return $this->type; + } + + public function isStatic(): bool + { + return false; + } + + public function isPrivate(): bool + { + return false; + } + + public function isPublic(): bool + { + return true; + } + + public function isDeprecated(): bool + { + return false; + } + + public function getDeprecatedDescription(): ?string + { + return null; + } + + public function isInternal(): bool + { + return false; + } + + public function getDocComment(): ?string + { + return null; + } + + public function isReadOnly(): bool + { + return false; + } +} \ No newline at end of file diff --git a/tests/PHPStan/UserPropertiesClassReflectionExtension.php b/tests/PHPStan/UserPropertiesClassReflectionExtension.php new file mode 100644 index 0000000..91e612e --- /dev/null +++ b/tests/PHPStan/UserPropertiesClassReflectionExtension.php @@ -0,0 +1,22 @@ +getName() === 'Illuminate\Foundation\Auth\User' && $propertyName === 'two_factor_confirmed_at'; + } + + public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection + { + $type = new ObjectType('Carbon\Carbon'); + return new CustomPropertyReflection($classReflection, $type); + } +} \ No newline at end of file