diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 32786e4..666ffc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,3 +1,4 @@ +--- name: Tests on: @@ -7,11 +8,6 @@ on: - 'docs/**' branches: - "**" - pull_request: - types: [ready_for_review, synchronize, opened] - paths-ignore: - - "**.md" - - 'docs/**' jobs: tests: diff --git a/composer.json b/composer.json index da042fa..ef7a801 100644 --- a/composer.json +++ b/composer.json @@ -48,10 +48,12 @@ "minimum-stability": "dev", "prefer-stable": true, "scripts": { - "test:phpstan": "phpstan analyze --ansi", + "test:phpstan:src": "phpstan analyze --ansi", + "test:phpstan:integration": "phpstan analyze --ansi -c tests/phpstan-tests.neon", "test:phpunit": "phpunit --colors=always", "test": [ - "@test:phpstan", + "@test:phpstan:src", + "@test:phpstan:integration", "@test:phpunit" ] } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 776ccd8..a1c637a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,4 @@ parameters: - level: max - paths: - - src + level: max + paths: + - src diff --git a/src/Properties/ComputedPropertyExtension.php b/src/Properties/ComputedPropertyExtension.php index beca766..481b644 100644 --- a/src/Properties/ComputedPropertyExtension.php +++ b/src/Properties/ComputedPropertyExtension.php @@ -20,10 +20,6 @@ public function hasProperty(ClassReflection $classReflection, string $propertyNa return false; } - if ($classReflection->isAbstract()) { - return false; - } - if ($classReflection->hasNativeMethod($this->getterPropertyName($propertyName))) { return true; } diff --git a/tests/Fixtures/AbstractBaseComponent.php b/tests/Fixtures/AbstractBaseComponent.php new file mode 100644 index 0000000..8bf95ec --- /dev/null +++ b/tests/Fixtures/AbstractBaseComponent.php @@ -0,0 +1,20 @@ +traitMethod + .$this->trait_method + .$this->traitGetter + .$this->trait_getter; + } +} diff --git a/tests/stubs/TestComponentWithComputedProperties.php b/tests/Fixtures/TestComponentWithComputedProperties.php similarity index 55% rename from tests/stubs/TestComponentWithComputedProperties.php rename to tests/Fixtures/TestComponentWithComputedProperties.php index 4d2ccc2..16e4a8d 100644 --- a/tests/stubs/TestComponentWithComputedProperties.php +++ b/tests/Fixtures/TestComponentWithComputedProperties.php @@ -2,15 +2,12 @@ declare(strict_types=1); -namespace CalebDW\LarastanLivewire\Tests\stubs; +namespace CalebDW\LarastanLivewire\Tests\Fixtures; use Livewire\Attributes\Computed; -use Livewire\Component; -final class TestComponentWithComputedProperties extends Component +class TestComponentWithComputedProperties extends AbstractBaseComponent { - use TraitWithComputedProperties; - public function notAComputedProperty(): bool { return true; @@ -25,6 +22,8 @@ private function privateMethod(): bool #[Computed] protected function protectedMethod(): bool { + $this->privateMethod(); + return true; } @@ -73,4 +72,27 @@ public function getGetterStyleProperty(): array { return ['foo', 'bar']; } + + public function testIntegration(): string + { + return $this->privateMethod + .$this->private_method + .$this->protectedMethod + .$this->protected_method + .$this->property + .$this->propertyWithComments + .$this->property_with_comments + .$this->deprecatedProperty + .$this->deprecated_property + .$this->deprecatedPropertyWithDescription + .$this->deprecated_property_with_description + .$this->propertyWithGenerics[0] + .$this->property_with_generics[0] + .$this->getterStyle[0] + .$this->getter_style[0] + .$this->traitMethod + .$this->trait_method + .$this->traitGetter + .$this->trait_getter; + } } diff --git a/tests/stubs/TraitWithComputedProperties.php b/tests/Fixtures/TraitWithComputedProperties.php similarity index 53% rename from tests/stubs/TraitWithComputedProperties.php rename to tests/Fixtures/TraitWithComputedProperties.php index fac3118..7b228b3 100644 --- a/tests/stubs/TraitWithComputedProperties.php +++ b/tests/Fixtures/TraitWithComputedProperties.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace CalebDW\LarastanLivewire\Tests\stubs; +namespace CalebDW\LarastanLivewire\Tests\Fixtures; use Livewire\Attributes\Computed; @@ -18,4 +18,12 @@ public function getTraitGetterProperty(): bool { return true; } + + public function testIntegration(): string + { + return $this->traitMethod + .$this->trait_method + .$this->traitGetter + .$this->trait_getter; + } } diff --git a/tests/Properties/ComputedPropertyExtensionTest.php b/tests/Properties/ComputedPropertyExtensionTest.php index d81b49c..e9a2886 100644 --- a/tests/Properties/ComputedPropertyExtensionTest.php +++ b/tests/Properties/ComputedPropertyExtensionTest.php @@ -5,7 +5,7 @@ namespace CalebDW\LarastanLivewire\Tests\Properties; use CalebDW\LarastanLivewire\Properties\ComputedPropertyExtension; -use CalebDW\LarastanLivewire\Tests\stubs\TestComponentWithComputedProperties; +use CalebDW\LarastanLivewire\Tests\Fixtures\TestComponentWithComputedProperties; use PHPStan\Reflection\ClassReflection; use PHPStan\Testing\PHPStanTestCase; use PHPStan\Type\VerbosityLevel; diff --git a/tests/phpstan-tests.neon b/tests/phpstan-tests.neon new file mode 100644 index 0000000..51658c5 --- /dev/null +++ b/tests/phpstan-tests.neon @@ -0,0 +1,6 @@ +includes: + - ../extension.neon +parameters: + level: max + paths: + - Fixtures