From 29bc6e87adf1ce76930ab8dbed5161ffa7e554ba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 29 Oct 2024 20:01:32 +0000 Subject: [PATCH] :package: ci: php-8.1 downgraded v0.3.1 --- .changeset/README.md | 8 - .changeset/config.json | 11 -- .gitattributes | 37 ----- .github/ISSUE_TEMPLATE/1_Bug_report.md | 35 ----- .github/ISSUE_TEMPLATE/2_Feature_request.md | 13 -- .github/ISSUE_TEMPLATE/config.yml | 5 - .github/PULL_REQUEST_TEMPLATE.md | 15 -- .github/workflows/lint.yml | 28 ---- .github/workflows/publish.yml | 38 ----- .github/workflows/release.yml | 70 --------- .github/workflows/test.yml | 28 ---- .gitignore | 30 ---- .husky/commit-msg | 4 - .husky/pre-commit | 4 - .node-version | 1 - CHANGELOG.md | 37 ----- CONTRIBUTING.md | 60 -------- build/composer-php-81.json | 49 ------ build/rector-downgrade-php-81.php | 10 -- commitlint.config.js | 4 - composer-dependency-analyser.php | 29 ---- composer.json | 139 ++++++------------ ecs.php | 39 ----- lint-staged.config.js | 10 -- package.json | 21 --- .../rule-doc-generator/custom-rule-docs.patch | 35 ----- phpstan.neon.dist | 32 ---- phpunit.xml.dist | 30 ---- rector.php | 47 ------ .../ConfigurationPropertiesExtension.php | 6 +- .../DataObjectTypeNodeResolverExtension.php | 4 +- .../ViewableDataClassReflectionExtension.php | 4 +- ...lectionInterfaceGetReturnTypeExtension.php | 8 +- .../ConfigForClassGetReturnTypeExtension.php | 8 +- .../DataObjectDbObjectReturnTypeExtension.php | 6 +- .../Type/InjectorGetReturnTypeExtension.php | 6 +- src/Reflection/ExtensibleMethodReflection.php | 18 +-- .../ExtensibleParameterReflection.php | 14 +- .../ExtensiblePropertyReflection.php | 8 +- .../ViewableDataPropertyReflection.php | 8 +- src/ReflectionResolver/ReflectionResolver.php | 8 +- ...ncyInjectionPropertyReflectionResolver.php | 6 +- ...riaComparisonsMethodReflectionResolver.php | 4 +- .../ExtensionMethodReflectionResolver.php | 10 +- ...SimpleRelationMethodReflectionResolver.php | 8 +- ...mpleRelationPropertyReflectionResolver.php | 8 +- .../ReflectionResolverRegistry.php | 6 +- ...rridingOfConfigurationPropertyTypeRule.php | 8 +- ...sallowMethodCallOnUnsafeDataObjectRule.php | 4 +- .../DisallowNewInstanceOnInjectableRule.php | 6 +- ...allowPropertyFetchOnConfigForClassRule.php | 2 +- ...lowPropertyFetchOnUnsafeDataObjectRule.php | 2 +- ...opertyFetchOnConfigurationPropertyRule.php | 6 +- src/TypeResolver/TypeResolver.php | 12 +- .../SimpleRelationPropertyTypeResolver.php | 6 +- src/TypeResolver/TypeResolverRegistry.php | 6 +- src/ValueObject/ClassParentMethodCall.php | 8 +- src/ValueObject/ClassRequiredProperty.php | 6 +- .../ConfigurationPropertiesExtensionTest.php | 64 -------- .../Fixture/ConfigurableClass.php | 20 --- .../Fixture/ConfigurableExtension.php | 18 --- ...sionOwnerTypeNodeResolverExtensionTest.php | 34 ----- .../PhpDoc/Fixture/ExtensionTypes.php | 46 ------ .../ComplexIntersectionExtension.php | 15 -- .../PhpDoc/Source/Extension/DNFExtension.php | 15 -- .../Source/Extension/SimpleExtension.php | 14 -- .../Extension/SimpleIntersectionExtension.php | 14 -- .../Source/Extension/UnionExtension.php | 15 -- tests/Extension/PhpDoc/Source/Model/Bar.php | 14 -- tests/Extension/PhpDoc/Source/Model/Foo.php | 14 -- ...ExtensibleClassReflectionExtensionTest.php | 41 ------ .../Fixture/DBPropertyReflections.php | 52 ------- ...DependencyInjectionPropertyReflections.php | 12 -- .../Fixture/DisplayLogicMethodReflections.php | 39 ----- .../Fixture/ExtensionMethodReflections.php | 14 -- .../Fixture/ExtensionPropertyReflections.php | 13 -- .../Fixture/ManyRelationMethodReflections.php | 41 ------ .../SimpleRelationMethodReflections.php | 15 -- .../SimpleRelationPropertyReflections.php | 14 -- .../ViewableDataPropertyReflections.php | 20 --- .../Source/Extension/FooExtension.php | 36 ----- .../Extension/Reflection/Source/Model/Bar.php | 9 -- .../Extension/Reflection/Source/Model/Foo.php | 79 ---------- ...ewableDataClassReflectionExtensionTest.php | 34 ----- ...ionInterfaceGetReturnTypeExtensionTest.php | 34 ----- ...nfigForClassGetReturnTypeExtensionTest.php | 34 ----- ...aObjectDbObjectReturnTypeExtensionTest.php | 34 ----- ...asExtensionTypeSpecifyingExtensionTest.php | 34 ----- ...leHasMethodTypeSpecifyingExtensionTest.php | 34 ----- ...ConfigCollectionInterfacePropertyTypes.php | 22 --- .../Fixture/ConfigForClassPropertyTypes.php | 21 --- .../Type/Fixture/DataObjectDbObjectTypes.php | 33 ----- .../Fixture/ExtensibleHasExtensionTypes.php | 19 --- .../Type/Fixture/ExtensibleHasMethodTypes.php | 18 --- .../Type/Fixture/InjectorGetTypes.php | 40 ----- .../Fixture/ViewableDataHasFieldTypes.php | 27 ---- .../InjectorGetReturnTypeExtensionTest.php | 34 ----- .../Type/Source/ConfigurableClass.php | 45 ------ .../Type/Source/Extension/FooExtension.php | 17 --- tests/Extension/Type/Source/Model/Foo.php | 27 ---- ...ataHasFieldTypeSpecifyingExtensionTest.php | 34 ----- .../ClassMethod/Fixture/DataObjectWrite.php | 26 ---- ...ireParentCallInOverridenMethodRuleTest.php | 56 ------- ...ingOfConfigurationPropertyTypeRuleTest.php | 48 ------ .../Fixture/DisallowOverridingName.php | 13 -- .../InClassNode/Fixture/RequireTableName.php | 10 -- ...eConfigurationPropertyOverrideRuleTest.php | 38 ----- ...owMethodCallOnUnsafeDataObjectRuleTest.php | 51 ------- .../Fixture/DisallowMethodCallDataObject.php | 27 ---- tests/Rule/MethodCall/Source/Model/Foo.php | 30 ---- ...isallowNewInstanceOnInjectableRuleTest.php | 45 ------ .../Rule/New_/Fixture/DisallowNewInstance.php | 17 --- tests/Rule/New_/Source/InjectableClass.php | 11 -- tests/Rule/New_/Source/NonInjectableClass.php | 7 - ...wPropertyFetchOnConfigForClassRuleTest.php | 40 ----- ...ropertyFetchOnUnsafeDataObjectRuleTest.php | 51 ------- .../Fixture/DisallowPropertyFetch.php | 19 --- .../DisallowPropertyFetchDataObject.php | 26 ---- tests/Rule/PropertyFetch/Source/Model/Foo.php | 25 ---- ...tyFetchOnConfigurationPropertyRuleTest.php | 46 ------ .../Fixture/DisallowStaticPropertyFetch.php | 27 ---- tests/Type/Fixture/ArrayListTypes.php | 31 ---- tests/Type/Fixture/DataListTypes.php | 22 --- tests/Type/Fixture/PageTypes.php | 14 -- tests/Type/ListTypeTest.php | 35 ----- tests/Type/PageTypeTest.php | 34 ----- tests/Type/Source/Model/Foo.php | 10 -- tests/Type/Source/MyPage.php | 10 -- tests/Type/Source/MyPageController.php | 10 -- tests/_config/test.yml | 6 - tests/tests.neon | 5 - 131 files changed, 148 insertions(+), 2926 deletions(-) delete mode 100644 .changeset/README.md delete mode 100644 .changeset/config.json delete mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE/1_Bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/2_Feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .gitignore delete mode 100755 .husky/commit-msg delete mode 100755 .husky/pre-commit delete mode 100644 .node-version delete mode 100644 CHANGELOG.md delete mode 100644 CONTRIBUTING.md delete mode 100644 build/composer-php-81.json delete mode 100644 build/rector-downgrade-php-81.php delete mode 100644 commitlint.config.js delete mode 100644 composer-dependency-analyser.php delete mode 100644 ecs.php delete mode 100644 lint-staged.config.js delete mode 100644 package.json delete mode 100644 patches/symplify/rule-doc-generator/custom-rule-docs.patch delete mode 100644 phpstan.neon.dist delete mode 100644 phpunit.xml.dist delete mode 100644 rector.php delete mode 100644 tests/Extension/ClassPropertiesNode/ConfigurationPropertiesExtensionTest.php delete mode 100644 tests/Extension/ClassPropertiesNode/Fixture/ConfigurableClass.php delete mode 100644 tests/Extension/ClassPropertiesNode/Fixture/ConfigurableExtension.php delete mode 100644 tests/Extension/PhpDoc/ExtensionOwnerTypeNodeResolverExtensionTest.php delete mode 100644 tests/Extension/PhpDoc/Fixture/ExtensionTypes.php delete mode 100644 tests/Extension/PhpDoc/Source/Extension/ComplexIntersectionExtension.php delete mode 100644 tests/Extension/PhpDoc/Source/Extension/DNFExtension.php delete mode 100644 tests/Extension/PhpDoc/Source/Extension/SimpleExtension.php delete mode 100644 tests/Extension/PhpDoc/Source/Extension/SimpleIntersectionExtension.php delete mode 100644 tests/Extension/PhpDoc/Source/Extension/UnionExtension.php delete mode 100644 tests/Extension/PhpDoc/Source/Model/Bar.php delete mode 100644 tests/Extension/PhpDoc/Source/Model/Foo.php delete mode 100644 tests/Extension/Reflection/ExtensibleClassReflectionExtensionTest.php delete mode 100644 tests/Extension/Reflection/Fixture/DBPropertyReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/DependencyInjectionPropertyReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/DisplayLogicMethodReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/ExtensionMethodReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/ExtensionPropertyReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/ManyRelationMethodReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/SimpleRelationMethodReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/SimpleRelationPropertyReflections.php delete mode 100644 tests/Extension/Reflection/Fixture/ViewableDataPropertyReflections.php delete mode 100644 tests/Extension/Reflection/Source/Extension/FooExtension.php delete mode 100644 tests/Extension/Reflection/Source/Model/Bar.php delete mode 100644 tests/Extension/Reflection/Source/Model/Foo.php delete mode 100644 tests/Extension/Reflection/ViewableDataClassReflectionExtensionTest.php delete mode 100644 tests/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtensionTest.php delete mode 100644 tests/Extension/Type/ConfigForClassGetReturnTypeExtensionTest.php delete mode 100644 tests/Extension/Type/DataObjectDbObjectReturnTypeExtensionTest.php delete mode 100644 tests/Extension/Type/ExtensibleHasExtensionTypeSpecifyingExtensionTest.php delete mode 100644 tests/Extension/Type/ExtensibleHasMethodTypeSpecifyingExtensionTest.php delete mode 100644 tests/Extension/Type/Fixture/ConfigCollectionInterfacePropertyTypes.php delete mode 100644 tests/Extension/Type/Fixture/ConfigForClassPropertyTypes.php delete mode 100644 tests/Extension/Type/Fixture/DataObjectDbObjectTypes.php delete mode 100644 tests/Extension/Type/Fixture/ExtensibleHasExtensionTypes.php delete mode 100644 tests/Extension/Type/Fixture/ExtensibleHasMethodTypes.php delete mode 100644 tests/Extension/Type/Fixture/InjectorGetTypes.php delete mode 100644 tests/Extension/Type/Fixture/ViewableDataHasFieldTypes.php delete mode 100644 tests/Extension/Type/InjectorGetReturnTypeExtensionTest.php delete mode 100644 tests/Extension/Type/Source/ConfigurableClass.php delete mode 100644 tests/Extension/Type/Source/Extension/FooExtension.php delete mode 100644 tests/Extension/Type/Source/Model/Foo.php delete mode 100644 tests/Extension/Type/ViewableDataHasFieldTypeSpecifyingExtensionTest.php delete mode 100644 tests/Rule/ClassMethod/Fixture/DataObjectWrite.php delete mode 100644 tests/Rule/ClassMethod/RequireParentCallInOverridenMethodRuleTest.php delete mode 100755 tests/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRuleTest.php delete mode 100755 tests/Rule/ClassPropertyNode/Fixture/DisallowOverridingName.php delete mode 100755 tests/Rule/InClassNode/Fixture/RequireTableName.php delete mode 100755 tests/Rule/InClassNode/RequireConfigurationPropertyOverrideRuleTest.php delete mode 100644 tests/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRuleTest.php delete mode 100644 tests/Rule/MethodCall/Fixture/DisallowMethodCallDataObject.php delete mode 100644 tests/Rule/MethodCall/Source/Model/Foo.php delete mode 100755 tests/Rule/New_/DisallowNewInstanceOnInjectableRuleTest.php delete mode 100755 tests/Rule/New_/Fixture/DisallowNewInstance.php delete mode 100644 tests/Rule/New_/Source/InjectableClass.php delete mode 100644 tests/Rule/New_/Source/NonInjectableClass.php delete mode 100755 tests/Rule/PropertyFetch/DisallowPropertyFetchOnConfigForClassRuleTest.php delete mode 100755 tests/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRuleTest.php delete mode 100755 tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetch.php delete mode 100644 tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetchDataObject.php delete mode 100644 tests/Rule/PropertyFetch/Source/Model/Foo.php delete mode 100755 tests/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest.php delete mode 100755 tests/Rule/StaticPropertyFetch/Fixture/DisallowStaticPropertyFetch.php delete mode 100644 tests/Type/Fixture/ArrayListTypes.php delete mode 100644 tests/Type/Fixture/DataListTypes.php delete mode 100644 tests/Type/Fixture/PageTypes.php delete mode 100644 tests/Type/ListTypeTest.php delete mode 100644 tests/Type/PageTypeTest.php delete mode 100644 tests/Type/Source/Model/Foo.php delete mode 100644 tests/Type/Source/MyPage.php delete mode 100644 tests/Type/Source/MyPageController.php delete mode 100644 tests/_config/test.yml delete mode 100644 tests/tests.neon diff --git a/.changeset/README.md b/.changeset/README.md deleted file mode 100644 index e5b6d8d..0000000 --- a/.changeset/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Changesets - -Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works -with multi-package repos, or single-package repos to help you version and publish your code. You can -find the full documentation for it [in our repository](https://github.com/changesets/changesets) - -We have a quick list of common questions to get you started engaging with this project in -[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json deleted file mode 100644 index 91b6a95..0000000 --- a/.changeset/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, - "fixed": [], - "linked": [], - "access": "restricted", - "baseBranch": "main", - "updateInternalDependencies": "patch", - "ignore": [] -} diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index efaa521..0000000 --- a/.gitattributes +++ /dev/null @@ -1,37 +0,0 @@ -# IDE -.editorconfig export-ignore - -# Git -.gitattributes export-ignore -.gitignore export-ignore -.github export-ignore - -# Quality tools -.changeset export-ignore -.husky export-ignore -commitlint.config.js export-ignore -lint-staged.config.js export-ignore - -# Tests -phpunit.xml.dist export-ignore -tests export-ignore - -# Coding standards -ecs.php export-ignore -composer-dependency-analyser.php export-ignore -phpstan.neon.dist export-ignore -phpstan-baseline.neon export-ignore -rector.php export-ignore - -# Build -build export-ignore -patches export-ignore - -# Documentation -CHANGELOG.md -CONTRIBUTING.md - -# Extra -package.json -.nvmrc -src/Playground diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md deleted file mode 100644 index 5bc20e7..0000000 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: "Bug report \U0001F41B" -about: "If something isn't working as expected \U0001F914." -title: '' -labels: 'i: bug' -assignees: '' ---- - -## Bug report 🐛 - - - -| Subject | Details | -| :------------- | :--------------------------------------------------------------------------------| -| Version | e.g. v1.0.0 (invoke `composer show cambis/silverstan \| grep versions`) | - - - -### Minimal affected code 🚨 - - -```php -``` - -### Current behaviour 😢 - - -```php -``` - -### Expected behaviour 🙂 - - -```php -``` diff --git a/.github/ISSUE_TEMPLATE/2_Feature_request.md b/.github/ISSUE_TEMPLATE/2_Feature_request.md deleted file mode 100644 index 42496a1..0000000 --- a/.github/ISSUE_TEMPLATE/2_Feature_request.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: "Feature request \U00002728" -about: "I have a suggestion (and may want to implement it \U0001F642)!" -title: '' -labels: 'i: enhancement' -assignees: '' ---- - -## Feature request ✨ - - - - diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index c752494..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Support question 🙋 - url: https://github.com/Cambis/silverstan/discussions/new - about: Please ask and answer questions here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 41b9222..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,15 +0,0 @@ -## Description ✍️ - - - -## Fixes 🐛 - -- Link to github issue(s) here. - -## DoD checklist ✅ - -- [ ] I have performed a self-review of my code -- [ ] My code adheres to the [coding standards](../CONTRIBUTING.md#coding-standards-️) -- [ ] My commit messages adhere to the [commit standards](../CONTRIBUTING.md#commit-standards-️). -- [ ] My code has been [tested](../CONTRIBUTING.md#testing-). -- [ ] I have added a [changeset](../CONTRIBUTING.md#making-a-pull-request-). diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index ac6ef2d..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Lint 👮 - -on: - pull_request: - branches: - - main - push: - branches: - - main - -env: - # see https://github.com/composer/composer/issues/9368#issuecomment-718112361 - COMPOSER_ROOT_VERSION: dev-main - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - coverage: none - - - uses: ramsey/composer-install@v2 - - - run: composer lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index ac0191c..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Publish 🔖 -on: - workflow_run: - workflows: - - lint - - test - branches: - - main - types: - - completed - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -permissions: - contents: write - pull-requests: write - -jobs: - publish: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - - run: yarn install - - - name: Create release pull request or publish - id: changesets - uses: changesets/action@v1 - with: - commit: ":memo: ci: update changelog" - title: ":memo: ci: update changelog" - publish: "echo 'versioned'" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 15753dc..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Release 🚀 - -# https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/ -# https://github.com/TomasVotruba/cognitive-complexity/blob/main/.github/workflows/downgraded_release.yaml -# https://github.com/symplify/config-transformer/blob/main/.github/workflows/downgraded_release.yaml -# https://github.com/driftingly/rector-laravel/blob/main/.github/workflows/downgraded_release.yaml - -on: - push: - tags: - - "*" - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - coverage: none - - - uses: ramsey/composer-install@v2 - - # Downgrade to PHP 7.4 - - run: vendor/bin/rector process config rules src --config build/rector-downgrade-php-81.php --ansi - - # Copy composer - - run: cp build/composer-php-81.json composer.json - - # Clear the dev files - - run: | - rm -rf \ - .editorconfig \ - .gitattributes \ - .gitignore \ - .github \ - .changeset \ - .husky \ - commitlint.config.js \ - lint-staged.config.js \ - phpunit.xml.dist \ - tests \ - composer-dependency-analyser.php \ - ecs.php \ - phpstan.neon.dist \ - phpstan-baseline.neon \ - rector.php \ - build \ - patches \ - package.json \ - .node-version \ - CHANGELOG.md \ - CONTRIBUTING.md - - # Setup git bot user - - run: | - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - - # Publish to the same repository with a new tag - - name: Tag downgraded code - run: | - git commit -a -m ":package: ci: php-8.1 downgraded ${GITHUB_REF#refs/tags/}" - - # Force push tag, so there is only a single version - git tag "${GITHUB_REF#refs/tags/}" --force - git push origin "${GITHUB_REF#refs/tags/}" --force diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 8a85987..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Test 🧑‍🔬 - -on: - pull_request: - branches: - - main - push: - branches: - - main - -env: - # see https://github.com/composer/composer/issues/9368#issuecomment-718112361 - COMPOSER_ROOT_VERSION: dev-main - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - coverage: none - - - uses: ramsey/composer-install@v2 - - - run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8be493d..0000000 --- a/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -# OS -.DS_Store - -# IDE -.idea -.vscode - -# Docker -docker/ -docker-compose.yml -compose.yml - -# Silverstripe -public/ -app/ - -# Dependencies -node_modules/ -vendor/ -composer.lock -yarn-error.log -yarn.lock -phpstan.phar - -# Tests -.phpunit.cache -coverage/ - -# Playground -src/Playground diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index a8e9dde..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no --commitlint --edit "$1" diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index d24fdfc..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx lint-staged diff --git a/.node-version b/.node-version deleted file mode 100644 index 2bd5a0a..0000000 --- a/.node-version +++ /dev/null @@ -1 +0,0 @@ -22 diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index cead09b..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# @cambis/silverstan - -## 0.3.1 - -### Patch Changes - -- 69e1025: Accept parent and subclasses of `SilverStripe\View\ViewableData` in ViewableDataClassReflectionExtension - -## 0.3.0 - -### Minor Changes - -- baa4268: - - Add InjectorGetReturnTypeExtension - - Add SingletonReturnTypeExtension - - Add DataObjectDbObjectReturnTypeExtension - -## 0.2.0 - -### Minor Changes - -- 1c0601a: - - Clean up resolvers and factory implementation - - Update README with more information on custom analysis -- e5b764a: Add support for unclecheese/display-logic - -## 0.1.1 - -### Patch Changes - -- Don't check for native configuration property when resolving all types - -## 0.1.0 - -### Minor Changes - -- Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 20baa74..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,60 +0,0 @@ -# Contributing 🤩 - -Kia ora! Would you like to contribute? That's awesome, thank you so much for your interest in this project! - -Before you go committing your amazing contribution please read the following guidelines. - -## Getting started 🐤 - -Here are some things to know before you start coding. - -We use the following dependencies for development: - -- php 8.3 -- composer -- node 22 - -We use a number of quality of life tools to streamline development, install them via the command line. - -```sh -composer install -yarn install -``` - -## Coding standards 👮‍♂️ - -To keep the codebase tidy, use the following script to clean each commit. - -```sh -composer lint -``` - -## Commit standards 👮‍♀️ - -This project uses the [gitmoji config for commitlint](https://www.npmjs.com/package/commitlint-config-gitmoji#structure). - -Each commit should adhere to the following structure. - -```sh -:gitmoji: type(scope?): subject -body? -footer? -``` - -## Testing 🧑‍🔬 - -Be sure to run the test suite regularly. New tests should be added for new features. - -```sh -vendor/bin/phpunit -``` - -## Making a pull request ✨ - -This project uses [changesets](https://github.com/changesets/changesets). This tool helps us to streamline our changelog. - -When making a pull request, be sure to add a changeset if there has been a change to the project. - -```sh -npx changeset -``` diff --git a/build/composer-php-81.json b/build/composer-php-81.json deleted file mode 100644 index feb940d..0000000 --- a/build/composer-php-81.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "cambis/silverstan", - "description": "PHPStan extensions and rules for Silverstripe.", - "license": "MIT", - "type": "phpstan-extension", - "keywords": [ - "silverstripe", - "phpstan", - "static analysis" - ], - "authors": [ - { - "name": "Cameron Bryers" - } - ], - "require": { - "php": "^8.1", - "phpstan/phpstan": "^1.12", - "silverstripe/config": "^2.0", - "silverstripe/framework": "^5.2", - "symplify/rule-doc-generator-contracts": "^11.1" - }, - "suggest": { - "silverstripe/standards": "Verifies annotations inside of Silverstripe classes." - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Cambis\\Silverstan\\": [ - "src/" - ] - } - }, - "config": { - "allow-plugins": { - "composer/installers": true, - "phpstan/extension-installer": true - }, - "sort-packages": true - }, - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - } - } -} diff --git a/build/rector-downgrade-php-81.php b/build/rector-downgrade-php-81.php deleted file mode 100644 index 3a28d4e..0000000 --- a/build/rector-downgrade-php-81.php +++ /dev/null @@ -1,10 +0,0 @@ -withImportNames(removeUnusedImports: true) - ->withSets([DowngradeLevelSetList::DOWN_TO_PHP_81]); diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 2addcf2..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('@commitlint/types').UserConfig}*/ -module.exports = { - extends: ["gitmoji"], -}; diff --git a/composer-dependency-analyser.php b/composer-dependency-analyser.php deleted file mode 100644 index d735bc8..0000000 --- a/composer-dependency-analyser.php +++ /dev/null @@ -1,29 +0,0 @@ -addPathToScan(__DIR__ . '/bootstrap.php', false) - ->ignoreUnknownFunctions(['PHPStan\Testing\assertType']) - ->ignoreUnknownClasses(['Page', 'PageController']) - ->ignoreErrorsOnPackagesAndPaths( - [ - // Bundled with phpstan/phpstan - 'nikic/php-parser', - 'phpstan/phpdoc-parser', - 'symfony/finder', - ], - [__DIR__ . '/src'], - [ErrorType::SHADOW_DEPENDENCY] - ) - ->ignoreErrorsOnPackagesAndPaths( - [ - // Bundled with phpstan/phpstan - 'nikic/php-parser', - ], - [__DIR__ . '/tests'], - [ErrorType::SHADOW_DEPENDENCY] - ); diff --git a/composer.json b/composer.json index 2818e2a..feb940d 100644 --- a/composer.json +++ b/composer.json @@ -1,98 +1,49 @@ { - "name": "cambis/silverstan", - "description": "PHPStan extensions and rules for Silverstripe.", - "license": "MIT", - "type": "phpstan-extension", - "keywords": [ - "silverstripe", - "phpstan", - "static analysis" - ], - "authors": [ - { - "name": "Cameron Bryers" - } - ], - "require": { - "php": "^8.3", - "phpstan/phpstan": "^1.12", - "silverstripe/config": "^2.0", - "silverstripe/framework": "^5.2", - "symplify/rule-doc-generator-contracts": "^11.1" - }, - "require-dev": { - "cweagans/composer-patches": "^1.7", - "ergebnis/composer-normalize": "^2.41", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.2", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "^9.6", - "rector/rector": "^1.2", - "shipmonk/composer-dependency-analyser": "^1.7", - "silverstripe/cms": "^5.2", - "silverstripe/versioned": "^2.2", - "silverstripe/versioned-admin": "^2.2", - "slevomat/coding-standard": "^8.14", - "symplify/easy-coding-standard": "^12.0", - "symplify/phpstan-rules": "^12.4", - "symplify/rule-doc-generator": "^11.0", - "tomasvotruba/unused-public": "^0.4", - "unclecheese/display-logic": "^3.0" - }, - "suggest": { - "silverstripe/standards": "Verifies annotations inside of Silverstripe classes." - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Cambis\\Silverstan\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Cambis\\Silverstan\\Tests\\": "tests/" - } - }, - "config": { - "allow-plugins": { - "composer/installers": true, - "cweagans/composer-patches": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "ergebnis/composer-normalize": true, - "phpstan/extension-installer": true, - "silverstripe/vendor-plugin": true - }, - "sort-packages": true - }, - "extra": { - "composer-exit-on-patch-failure": true, - "patches": { - "symplify/rule-doc-generator": { - "Custom rule docs": "patches/symplify/rule-doc-generator/custom-rule-docs.patch" - } - }, - "phpstan": { - "includes": [ - "extension.neon" - ] - }, - "phpstan/extension-installer": { - "ignore": [ - "symplify/phpstan-rules" - ] - } + "name": "cambis/silverstan", + "description": "PHPStan extensions and rules for Silverstripe.", + "license": "MIT", + "type": "phpstan-extension", + "keywords": [ + "silverstripe", + "phpstan", + "static analysis" + ], + "authors": [ + { + "name": "Cameron Bryers" + } + ], + "require": { + "php": "^8.1", + "phpstan/phpstan": "^1.12", + "silverstripe/config": "^2.0", + "silverstripe/framework": "^5.2", + "symplify/rule-doc-generator-contracts": "^11.1" + }, + "suggest": { + "silverstripe/standards": "Verifies annotations inside of Silverstripe classes." + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Cambis\\Silverstan\\": [ + "src/" + ] + } + }, + "config": { + "allow-plugins": { + "composer/installers": true, + "phpstan/extension-installer": true }, - "scripts": { - "docs": "vendor/bin/rule-doc-generator generate src/Rule --output-file docs/rules_overview.md --ansi", - "lint": [ - "vendor/bin/parallel-lint src tests --colors --blame", - "vendor/bin/ecs check --ansi", - "vendor/bin/phpstan analyse --ansi --memory-limit=-1" - ], - "lint:fix": "vendor/bin/ecs check --fix", - "rector": "vendor/bin/rector process --dry-run --ansi" + "sort-packages": true + }, + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] } + } } diff --git a/ecs.php b/ecs.php deleted file mode 100644 index 9e72ddc..0000000 --- a/ecs.php +++ /dev/null @@ -1,39 +0,0 @@ -withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withConfiguredRule( - NewWithParenthesesFixer::class, - [ - 'anonymous_class' => false, - ] - ) - ->withConfiguredRule( - ReferenceUsedNamesOnlySniff::class, - [ - 'allowFallbackGlobalFunctions' => false, - 'allowFallbackGlobalConstants' => false, - ] - ) - ->withPreparedSets( - common: true, - psr12: true, - ) - ->withSkip([ - NotOperatorWithSuccessorSpaceFixer::class, - ReferenceUsedNamesOnlySniff::class => [ - __DIR__ . '/bootstrap.php', - __DIR__ . '/stubs/Page.php', - __DIR__ . '/stubs/PageController.php', - ], - ]); diff --git a/lint-staged.config.js b/lint-staged.config.js deleted file mode 100644 index 519bbf5..0000000 --- a/lint-staged.config.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @type {import('lint-staged').Config} */ -module.exports = { - '*.php': [ - 'php vendor/bin/parallel-lint --colors --blame', - 'php vendor/bin/ecs check --fix --ansi', - ], - 'composer.json': [ - 'composer normalize --ansi' - ], -}; diff --git a/package.json b/package.json deleted file mode 100644 index 88baffc..0000000 --- a/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@cambis/silverstan", - "version": "0.3.1", - "description": "PHPStan rules for Silverstripe.", - "author": "Cameron Bryers", - "license": "MIT", - "private": true, - "devDependencies": { - "@commitlint/cli": "^18.4.3", - "@commitlint/types": "^18.4.3", - "commitlint-config-gitmoji": "^2.3.1", - "husky": "^8.0.3", - "lint-staged": "^15.2.0" - }, - "dependencies": { - "@changesets/cli": "^2.27.1" - }, - "scripts": { - "prepare": "husky install" - } -} diff --git a/patches/symplify/rule-doc-generator/custom-rule-docs.patch b/patches/symplify/rule-doc-generator/custom-rule-docs.patch deleted file mode 100644 index 6be9144..0000000 --- a/patches/symplify/rule-doc-generator/custom-rule-docs.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/src/RuleCodeSamplePrinter/PHPStanRuleCodeSamplePrinter.php b/src/RuleCodeSamplePrinter/PHPStanRuleCodeSamplePrinter.php -index 7b825cd..b14c5b2 100644 ---- a/src/RuleCodeSamplePrinter/PHPStanRuleCodeSamplePrinter.php -+++ b/src/RuleCodeSamplePrinter/PHPStanRuleCodeSamplePrinter.php -@@ -4,6 +4,8 @@ declare(strict_types=1); - - namespace Symplify\RuleDocGenerator\RuleCodeSamplePrinter; - -+use Nette\Utils\Strings; -+use ReflectionClass; - use Symplify\RuleDocGenerator\Contract\CodeSampleInterface; - use Symplify\RuleDocGenerator\Contract\RuleCodeSamplePrinterInterface; - use Symplify\RuleDocGenerator\Printer\CodeSamplePrinter\BadGoodCodeSamplePrinter; -@@ -46,15 +48,14 @@ final class PHPStanRuleCodeSamplePrinter implements RuleCodeSamplePrinterInterfa - RuleDefinition $ruleDefinition - ): array { - $lines = []; -+ $ruleName = Strings::firstLower((new ReflectionClass($ruleDefinition->getRuleClass()))->getShortName()); - - $phpStanNeon = [ -- 'services' => [ -- [ -- 'class' => $ruleDefinition->getRuleClass(), -- 'tags' => ['phpstan.rules.rule'], -- 'arguments' => $configuredCodeSample->getConfiguration(), -- ], -- ], -+ 'parameters' => [ -+ 'silverstan' => [ -+ explode('Rule', $ruleName)[0] => $configuredCodeSample->getConfiguration(), -+ ] -+ ], - ]; - - $printedNeon = $this->neonPrinter->printNeon($phpStanNeon); diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index 386f202..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,32 +0,0 @@ -includes: - - extension.neon - - phar://phpstan.phar/conf/bleedingEdge.neon -parameters: - level: 9 - paths: - - src - - tests - excludePaths: - - ecs.php - - rector.php - - '*/Fixture/*' - - '*/Source/*' -services: - - - class: Symplify\PHPStanRules\Naming\ClassToSuffixResolver - - - class: Symplify\PHPStanRules\PhpDoc\PhpDocResolver - - - class: Symplify\PHPStanRules\PhpDoc\SeePhpDocTagNodesFinder - - - class: Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule - tags: [phpstan.rules.rule] - arguments: - parentClasses: - - PHPStan\Rules\Rule - - - class: Symplify\PHPStanRules\Rules\SeeAnnotationToTestRule - tags: [phpstan.rules.rule] - arguments: - requiredSeeTypes: - - PHPStan\Rules\Rule diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 00a646b..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - tests - - - - - - src - - - diff --git a/rector.php b/rector.php deleted file mode 100644 index 44c0dd0..0000000 --- a/rector.php +++ /dev/null @@ -1,47 +0,0 @@ -withImportNames(removeUnusedImports: true) - ->withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withPhpSets( - php83: true - ) - ->withPreparedSets( - codeQuality: true, - codingStyle: true, - deadCode: true, - earlyReturn: true, - privatization: true - ) - ->withRules([ - DeclareStrictTypesRector::class, - ]) - ->withSets([ - PHPUnitSetList::PHPUNIT_90, - ]) - ->withSkip([ - '*/Fixture/*', - '*/Source/*', - AddTypeToConstRector::class, - DeclareStrictTypesRector::class => [ - __DIR__ . '/src/Playground', - ], - ClosureToArrowFunctionRector::class, - StringClassNameToClassConstantRector::class, - UseClassKeywordForClassNameResolutionRector::class => [ - __DIR__ . '/tests', - ], - ]); diff --git a/src/Extension/ClassPropertiesNode/ConfigurationPropertiesExtension.php b/src/Extension/ClassPropertiesNode/ConfigurationPropertiesExtension.php index 2e9a0eb..232cd4d 100644 --- a/src/Extension/ClassPropertiesNode/ConfigurationPropertiesExtension.php +++ b/src/Extension/ClassPropertiesNode/ConfigurationPropertiesExtension.php @@ -16,11 +16,11 @@ * @see \Cambis\Silverstan\Tests\Extension\ClassPropertiesNode\ConfigurationPropertiesExtensionTest * @see https://phpstan.org/developing-extensions/always-read-written-properties */ -final readonly class ConfigurationPropertiesExtension implements ReadWritePropertiesExtension +final class ConfigurationPropertiesExtension implements ReadWritePropertiesExtension { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private PropertyReflectionAnalyser $propertyReflectionAnalyser + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly PropertyReflectionAnalyser $propertyReflectionAnalyser ) { } diff --git a/src/Extension/PhpDoc/DataObjectTypeNodeResolverExtension.php b/src/Extension/PhpDoc/DataObjectTypeNodeResolverExtension.php index b6cb4d9..95d40bf 100644 --- a/src/Extension/PhpDoc/DataObjectTypeNodeResolverExtension.php +++ b/src/Extension/PhpDoc/DataObjectTypeNodeResolverExtension.php @@ -18,10 +18,10 @@ * * @see \Cambis\Silverstan\Tests\Rule\PropertyFetch\DisallowPropertyFetchOnUnsafeDataObjectRuleTest */ -final readonly class DataObjectTypeNodeResolverExtension implements TypeNodeResolverExtension +final class DataObjectTypeNodeResolverExtension implements TypeNodeResolverExtension { public function __construct( - private ReflectionProvider $reflectionProvider, + private readonly ReflectionProvider $reflectionProvider, ) { } diff --git a/src/Extension/Reflection/ViewableDataClassReflectionExtension.php b/src/Extension/Reflection/ViewableDataClassReflectionExtension.php index 9354f3b..3f387e9 100644 --- a/src/Extension/Reflection/ViewableDataClassReflectionExtension.php +++ b/src/Extension/Reflection/ViewableDataClassReflectionExtension.php @@ -15,10 +15,10 @@ * * @see \Cambis\Silverstan\Tests\Extension\Reflection\ViewableDataClassReflectionExtensionTest */ -final readonly class ViewableDataClassReflectionExtension implements PropertiesClassReflectionExtension +final class ViewableDataClassReflectionExtension implements PropertiesClassReflectionExtension { public function __construct( - private AnnotationClassReflectionExtension $annotationClassReflectionExtension + private readonly AnnotationClassReflectionExtension $annotationClassReflectionExtension ) { } diff --git a/src/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtension.php b/src/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtension.php index 109520e..629e871 100644 --- a/src/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtension.php +++ b/src/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtension.php @@ -24,7 +24,7 @@ * * @see \Cambis\Silverstan\Tests\Extension\Type\ConfigCollectionInterfaceGetReturnTypeExtensionTest */ -final readonly class ConfigCollectionInterfaceGetReturnTypeExtension implements DynamicMethodReturnTypeExtension +final class ConfigCollectionInterfaceGetReturnTypeExtension implements DynamicMethodReturnTypeExtension { /** * @var string[] @@ -34,9 +34,9 @@ ]; public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private TypeResolver $configurationPropertyTypeResolver, - private ReflectionProvider $reflectionProvider + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly TypeResolver $configurationPropertyTypeResolver, + private readonly ReflectionProvider $reflectionProvider ) { } diff --git a/src/Extension/Type/ConfigForClassGetReturnTypeExtension.php b/src/Extension/Type/ConfigForClassGetReturnTypeExtension.php index e4910c5..4194328 100644 --- a/src/Extension/Type/ConfigForClassGetReturnTypeExtension.php +++ b/src/Extension/Type/ConfigForClassGetReturnTypeExtension.php @@ -23,7 +23,7 @@ * * @see \Cambis\Silverstan\Tests\Extension\Type\ConfigForClassGetReturnTypeExtensionTest */ -final readonly class ConfigForClassGetReturnTypeExtension implements DynamicMethodReturnTypeExtension +final class ConfigForClassGetReturnTypeExtension implements DynamicMethodReturnTypeExtension { /** * @var string[] @@ -34,9 +34,9 @@ ]; public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private TypeResolver $configurationPropertyTypeResolver, - private ReflectionProvider $reflectionProvider + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly TypeResolver $configurationPropertyTypeResolver, + private readonly ReflectionProvider $reflectionProvider ) { } diff --git a/src/Extension/Type/DataObjectDbObjectReturnTypeExtension.php b/src/Extension/Type/DataObjectDbObjectReturnTypeExtension.php index f1959e7..d6d57ea 100644 --- a/src/Extension/Type/DataObjectDbObjectReturnTypeExtension.php +++ b/src/Extension/Type/DataObjectDbObjectReturnTypeExtension.php @@ -23,7 +23,7 @@ * * @see \Cambis\Silverstan\Tests\Extension\Type\DataObjectDbObjectReturnTypeExtensionTest */ -final readonly class DataObjectDbObjectReturnTypeExtension implements DynamicMethodReturnTypeExtension +final class DataObjectDbObjectReturnTypeExtension implements DynamicMethodReturnTypeExtension { /** * @var string[] @@ -33,8 +33,8 @@ ]; public function __construct( - private ConfigurationResolver $configurationResolver, - private ReflectionProvider $reflectionProvider + private readonly ConfigurationResolver $configurationResolver, + private readonly ReflectionProvider $reflectionProvider ) { } diff --git a/src/Extension/Type/InjectorGetReturnTypeExtension.php b/src/Extension/Type/InjectorGetReturnTypeExtension.php index 3651c1c..88d5125 100644 --- a/src/Extension/Type/InjectorGetReturnTypeExtension.php +++ b/src/Extension/Type/InjectorGetReturnTypeExtension.php @@ -20,7 +20,7 @@ * * @see \Cambis\Silverstan\Tests\Type\InjectorGetReturnTypeExtensionTest */ -final readonly class InjectorGetReturnTypeExtension implements DynamicMethodReturnTypeExtension +final class InjectorGetReturnTypeExtension implements DynamicMethodReturnTypeExtension { /** * @var string[] @@ -32,8 +32,8 @@ ]; public function __construct( - private ConfigurationResolver $configurationResolver, - private ReflectionProvider $reflectionProvider + private readonly ConfigurationResolver $configurationResolver, + private readonly ReflectionProvider $reflectionProvider ) { } diff --git a/src/Reflection/ExtensibleMethodReflection.php b/src/Reflection/ExtensibleMethodReflection.php index 73792d8..07b1000 100644 --- a/src/Reflection/ExtensibleMethodReflection.php +++ b/src/Reflection/ExtensibleMethodReflection.php @@ -15,20 +15,20 @@ use PHPStan\Type\Generic\TemplateTypeMap; use PHPStan\Type\Type; -final readonly class ExtensibleMethodReflection implements MethodReflection +final class ExtensibleMethodReflection implements MethodReflection { /** * @param ParameterReflection[] $parameters */ public function __construct( - private string $name, - private ClassReflection $declaringClass, - private Type $returnType, - private array $parameters, - private bool $isStatic, - private bool $isVariadic, - private ?Type $throwType, - private TemplateTypeMap $templateTypeMap, + private readonly string $name, + private readonly ClassReflection $declaringClass, + private readonly Type $returnType, + private readonly array $parameters, + private readonly bool $isStatic, + private readonly bool $isVariadic, + private readonly ?Type $throwType, + private readonly TemplateTypeMap $templateTypeMap, ) { } diff --git a/src/Reflection/ExtensibleParameterReflection.php b/src/Reflection/ExtensibleParameterReflection.php index 191502c..bd0a8b7 100644 --- a/src/Reflection/ExtensibleParameterReflection.php +++ b/src/Reflection/ExtensibleParameterReflection.php @@ -9,15 +9,15 @@ use PHPStan\Reflection\PassedByReference; use PHPStan\Type\Type; -final readonly class ExtensibleParameterReflection implements ParameterReflection +final class ExtensibleParameterReflection implements ParameterReflection { public function __construct( - private string $name, - private Type $type, - private PassedByReference $passedByReference, - private bool $isOptional, - private bool $isVariadic, - private ?Type $defaultValue + private readonly string $name, + private readonly Type $type, + private readonly PassedByReference $passedByReference, + private readonly bool $isOptional, + private readonly bool $isVariadic, + private readonly ?Type $defaultValue ) { } diff --git a/src/Reflection/ExtensiblePropertyReflection.php b/src/Reflection/ExtensiblePropertyReflection.php index 6ca9d90..f68f3ea 100644 --- a/src/Reflection/ExtensiblePropertyReflection.php +++ b/src/Reflection/ExtensiblePropertyReflection.php @@ -10,12 +10,12 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\Type; -final readonly class ExtensiblePropertyReflection implements PropertyReflection +final class ExtensiblePropertyReflection implements PropertyReflection { public function __construct( - private ClassReflection $classReflection, - private Type $readableType, - private Type $writableType, + private readonly ClassReflection $classReflection, + private readonly Type $readableType, + private readonly Type $writableType, ) { } diff --git a/src/Reflection/ViewableDataPropertyReflection.php b/src/Reflection/ViewableDataPropertyReflection.php index 9025f3e..e750c80 100644 --- a/src/Reflection/ViewableDataPropertyReflection.php +++ b/src/Reflection/ViewableDataPropertyReflection.php @@ -10,12 +10,12 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\Type; -final readonly class ViewableDataPropertyReflection implements PropertyReflection +final class ViewableDataPropertyReflection implements PropertyReflection { public function __construct( - private ClassReflection $classReflection, - private Type $readableType, - private Type $writableType, + private readonly ClassReflection $classReflection, + private readonly Type $readableType, + private readonly Type $writableType, ) { } diff --git a/src/ReflectionResolver/ReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver.php index ba43777..e7274ae 100644 --- a/src/ReflectionResolver/ReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver.php @@ -17,12 +17,12 @@ use PHPStan\Type\Type; use function array_key_exists; -final readonly class ReflectionResolver +final class ReflectionResolver { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private PropertyReflectionAnalyser $propertyReflectionAnalyser, - private ReflectionResolverRegistryProviderInterface $reflectionResolverRegistryProvider + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly PropertyReflectionAnalyser $propertyReflectionAnalyser, + private readonly ReflectionResolverRegistryProviderInterface $reflectionResolverRegistryProvider ) { } diff --git a/src/ReflectionResolver/ReflectionResolver/DependencyInjectionPropertyReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/DependencyInjectionPropertyReflectionResolver.php index 3cc5c78..87b8d22 100644 --- a/src/ReflectionResolver/ReflectionResolver/DependencyInjectionPropertyReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/DependencyInjectionPropertyReflectionResolver.php @@ -11,11 +11,11 @@ use Override; use PHPStan\Reflection\ClassReflection; -final readonly class DependencyInjectionPropertyReflectionResolver implements PropertyReflectionResolverInterface +final class DependencyInjectionPropertyReflectionResolver implements PropertyReflectionResolverInterface { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private TypeResolver $typeResolver + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly TypeResolver $typeResolver ) { } diff --git a/src/ReflectionResolver/ReflectionResolver/DisplayLogicCriteriaComparisonsMethodReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/DisplayLogicCriteriaComparisonsMethodReflectionResolver.php index 9211df8..021dd60 100644 --- a/src/ReflectionResolver/ReflectionResolver/DisplayLogicCriteriaComparisonsMethodReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/DisplayLogicCriteriaComparisonsMethodReflectionResolver.php @@ -22,10 +22,10 @@ * * @see \Cambis\Silverstan\Tests\Extension\Reflection\ExtensibleClassReflectionExtensionTest */ -final readonly class DisplayLogicCriteriaComparisonsMethodReflectionResolver implements MethodReflectionResolverInterface +final class DisplayLogicCriteriaComparisonsMethodReflectionResolver implements MethodReflectionResolverInterface { public function __construct( - private ConfigurationResolver $configurationResolver + private readonly ConfigurationResolver $configurationResolver ) { } diff --git a/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php index f74c2ca..20960e8 100644 --- a/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php @@ -17,13 +17,13 @@ use function array_unique; use function is_array; -final readonly class ExtensionMethodReflectionResolver implements MethodReflectionResolverInterface +final class ExtensionMethodReflectionResolver implements MethodReflectionResolverInterface { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private ConfigurationResolver $configurationResolver, - private ReflectionProvider $reflectionProvider, - private TypeResolver $typeResolver + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly ConfigurationResolver $configurationResolver, + private readonly ReflectionProvider $reflectionProvider, + private readonly TypeResolver $typeResolver ) { } diff --git a/src/ReflectionResolver/ReflectionResolver/SimpleRelationMethodReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/SimpleRelationMethodReflectionResolver.php index 2259550..53acd45 100644 --- a/src/ReflectionResolver/ReflectionResolver/SimpleRelationMethodReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/SimpleRelationMethodReflectionResolver.php @@ -12,12 +12,12 @@ use PHPStan\Reflection\ClassReflection; use PHPStan\Type\Generic\TemplateTypeMap; -final readonly class SimpleRelationMethodReflectionResolver implements MethodReflectionResolverInterface +final class SimpleRelationMethodReflectionResolver implements MethodReflectionResolverInterface { public function __construct( - private string $configurationPropertyName, - private ClassReflectionAnalyser $classReflectionAnalyser, - private TypeResolver $typeResolver + private readonly string $configurationPropertyName, + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly TypeResolver $typeResolver ) { } diff --git a/src/ReflectionResolver/ReflectionResolver/SimpleRelationPropertyReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/SimpleRelationPropertyReflectionResolver.php index 5f5192d..4a2ded6 100644 --- a/src/ReflectionResolver/ReflectionResolver/SimpleRelationPropertyReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/SimpleRelationPropertyReflectionResolver.php @@ -11,12 +11,12 @@ use Override; use PHPStan\Reflection\ClassReflection; -final readonly class SimpleRelationPropertyReflectionResolver implements PropertyReflectionResolverInterface +final class SimpleRelationPropertyReflectionResolver implements PropertyReflectionResolverInterface { public function __construct( - private string $configurationPropertyName, - private ClassReflectionAnalyser $classReflectionAnalyser, - private TypeResolver $typeResolver + private readonly string $configurationPropertyName, + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly TypeResolver $typeResolver ) { } diff --git a/src/ReflectionResolver/ReflectionResolverRegistry.php b/src/ReflectionResolver/ReflectionResolverRegistry.php index 8f3cf2f..e47c9a0 100644 --- a/src/ReflectionResolver/ReflectionResolverRegistry.php +++ b/src/ReflectionResolver/ReflectionResolverRegistry.php @@ -9,17 +9,17 @@ use Cambis\Silverstan\ReflectionResolver\Contract\ReflectionResolverRegistryInterface; use Override; -final readonly class ReflectionResolverRegistry implements ReflectionResolverRegistryInterface +final class ReflectionResolverRegistry implements ReflectionResolverRegistryInterface { public function __construct( /** * @var PropertyReflectionResolverInterface[] */ - private array $propertyReflectionResolvers, + private readonly array $propertyReflectionResolvers, /** * @var MethodReflectionResolverInterface[] */ - private array $methodReflectionTypeResolvers + private readonly array $methodReflectionTypeResolvers ) { } diff --git a/src/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRule.php b/src/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRule.php index 1fdd38c..821b6aa 100644 --- a/src/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRule.php +++ b/src/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRule.php @@ -23,12 +23,12 @@ * @implements SilverstanRuleInterface * @see \Cambis\Silverstan\Tests\Rule\ClassPropertyNode\DisallowOverridingOfConfigurationPropertyTypeRuleTest */ -final readonly class DisallowOverridingOfConfigurationPropertyTypeRule implements SilverstanRuleInterface +final class DisallowOverridingOfConfigurationPropertyTypeRule implements SilverstanRuleInterface { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private PropertyReflectionAnalyser $propertyReflectionAnalyser, - private ReflectionResolver $reflectionResolver + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly PropertyReflectionAnalyser $propertyReflectionAnalyser, + private readonly ReflectionResolver $reflectionResolver ) { } diff --git a/src/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRule.php b/src/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRule.php index 18db084..761254a 100644 --- a/src/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRule.php +++ b/src/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRule.php @@ -27,7 +27,7 @@ * * @see \Cambis\Silverstan\Tests\Rule\MethodCall\DisallowMethodCallOnUnsafeDataObjectRuleTest */ -final readonly class DisallowMethodCallOnUnsafeDataObjectRule implements SilverstanRuleInterface +final class DisallowMethodCallOnUnsafeDataObjectRule implements SilverstanRuleInterface { /** * @var string[] @@ -40,7 +40,7 @@ public function __construct( /** @var string[] */ - private array $allowedMethodCalls = [] + private readonly array $allowedMethodCalls = [] ) { } diff --git a/src/Rule/New_/DisallowNewInstanceOnInjectableRule.php b/src/Rule/New_/DisallowNewInstanceOnInjectableRule.php index a4d853b..5d24262 100644 --- a/src/Rule/New_/DisallowNewInstanceOnInjectableRule.php +++ b/src/Rule/New_/DisallowNewInstanceOnInjectableRule.php @@ -21,11 +21,11 @@ * @implements SilverstanRuleInterface * @see \Cambis\Silverstan\Tests\Rule\New_\DisallowNewInstanceOnInjectableRuleTest */ -final readonly class DisallowNewInstanceOnInjectableRule implements SilverstanRuleInterface +final class DisallowNewInstanceOnInjectableRule implements SilverstanRuleInterface { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private ReflectionProvider $reflectionProvider + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly ReflectionProvider $reflectionProvider ) { } diff --git a/src/Rule/PropertyFetch/DisallowPropertyFetchOnConfigForClassRule.php b/src/Rule/PropertyFetch/DisallowPropertyFetchOnConfigForClassRule.php index d96024f..8765e8e 100755 --- a/src/Rule/PropertyFetch/DisallowPropertyFetchOnConfigForClassRule.php +++ b/src/Rule/PropertyFetch/DisallowPropertyFetchOnConfigForClassRule.php @@ -22,7 +22,7 @@ * @implements SilverstanRuleInterface * @see \Cambis\Silverstan\Tests\Rule\PropertyFetch\DisallowPropertyFetchOnConfigForClassRuleTest */ -final readonly class DisallowPropertyFetchOnConfigForClassRule implements SilverstanRuleInterface +final class DisallowPropertyFetchOnConfigForClassRule implements SilverstanRuleInterface { #[Override] public function getRuleDefinition(): RuleDefinition diff --git a/src/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRule.php b/src/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRule.php index 55fc3ce..ca88c5b 100644 --- a/src/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRule.php +++ b/src/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRule.php @@ -25,7 +25,7 @@ * * @see \Cambis\Silverstan\Tests\Rule\PropertyFetch\DisallowPropertyFetchOnUnsafeDataObjectRuleTest */ -final readonly class DisallowPropertyFetchOnUnsafeDataObjectRule implements SilverstanRuleInterface +final class DisallowPropertyFetchOnUnsafeDataObjectRule implements SilverstanRuleInterface { #[Override] public function getRuleDefinition(): RuleDefinition diff --git a/src/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRule.php b/src/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRule.php index 633e386..b6fba87 100755 --- a/src/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRule.php +++ b/src/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRule.php @@ -23,11 +23,11 @@ * @implements SilverstanRuleInterface * @see \Cambis\Silverstan\Tests\Rule\StaticPropertyFetch\DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest */ -final readonly class DisallowStaticPropertyFetchOnConfigurationPropertyRule implements SilverstanRuleInterface +final class DisallowStaticPropertyFetchOnConfigurationPropertyRule implements SilverstanRuleInterface { public function __construct( - private ClassReflectionAnalyser $classReflectionAnalyser, - private PropertyReflectionAnalyser $propertyReflectionAnalyser, + private readonly ClassReflectionAnalyser $classReflectionAnalyser, + private readonly PropertyReflectionAnalyser $propertyReflectionAnalyser, ) { } diff --git a/src/TypeResolver/TypeResolver.php b/src/TypeResolver/TypeResolver.php index 41ff19a..5bfc592 100644 --- a/src/TypeResolver/TypeResolver.php +++ b/src/TypeResolver/TypeResolver.php @@ -30,7 +30,7 @@ use function strtok; use function substr; -final readonly class TypeResolver +final class TypeResolver { /** * @var array @@ -43,11 +43,11 @@ ]; public function __construct( - private ConfigurationResolver $configurationResolver, - private ReflectionProvider $reflectionProvider, - private ReflectionResolver $reflectionResolver, - private TypeFactory $typeFactory, - private TypeResolverRegistryProviderInterface $typeResolverRegistryProvider + private readonly ConfigurationResolver $configurationResolver, + private readonly ReflectionProvider $reflectionProvider, + private readonly ReflectionResolver $reflectionResolver, + private readonly TypeFactory $typeFactory, + private readonly TypeResolverRegistryProviderInterface $typeResolverRegistryProvider ) { } diff --git a/src/TypeResolver/TypeResolver/SimpleRelationPropertyTypeResolver.php b/src/TypeResolver/TypeResolver/SimpleRelationPropertyTypeResolver.php index a6cc566..696c7c3 100644 --- a/src/TypeResolver/TypeResolver/SimpleRelationPropertyTypeResolver.php +++ b/src/TypeResolver/TypeResolver/SimpleRelationPropertyTypeResolver.php @@ -12,11 +12,11 @@ use function array_keys; use function is_array; -final readonly class SimpleRelationPropertyTypeResolver implements PropertyTypeResolverInterface +final class SimpleRelationPropertyTypeResolver implements PropertyTypeResolverInterface { public function __construct( - private string $configurationPropertyName, - private ConfigurationResolver $configurationResolver, + private readonly string $configurationPropertyName, + private readonly ConfigurationResolver $configurationResolver, ) { } diff --git a/src/TypeResolver/TypeResolverRegistry.php b/src/TypeResolver/TypeResolverRegistry.php index dfbf6d9..03af2d3 100644 --- a/src/TypeResolver/TypeResolverRegistry.php +++ b/src/TypeResolver/TypeResolverRegistry.php @@ -10,18 +10,18 @@ use Cambis\Silverstan\TypeResolver\Contract\TypeResolverRegistryInterface; use Override; -final readonly class TypeResolverRegistry implements TypeResolverRegistryInterface +final class TypeResolverRegistry implements TypeResolverRegistryInterface { public function __construct( TypeResolver $typeResolver, /** * @var PropertyTypeResolverInterface[] */ - private array $propertyTypeResolvers, + private readonly array $propertyTypeResolvers, /** * @var MethodTypeResolverInterface[] */ - private array $methodTypeResolvers + private readonly array $methodTypeResolvers ) { foreach ($propertyTypeResolvers as $propertyTypeResolver) { if (!$propertyTypeResolver instanceof TypeResolverAwareInterface) { diff --git a/src/ValueObject/ClassParentMethodCall.php b/src/ValueObject/ClassParentMethodCall.php index bf09310..11f7fe2 100644 --- a/src/ValueObject/ClassParentMethodCall.php +++ b/src/ValueObject/ClassParentMethodCall.php @@ -4,15 +4,15 @@ namespace Cambis\Silverstan\ValueObject; -final readonly class ClassParentMethodCall +final class ClassParentMethodCall { public function __construct( /** * @var class-string */ - public string $className, - public string $methodName, - public bool $isFirstCall = false + public readonly string $className, + public readonly string $methodName, + public readonly bool $isFirstCall = false ) { } } diff --git a/src/ValueObject/ClassRequiredProperty.php b/src/ValueObject/ClassRequiredProperty.php index e31d2ed..079d51f 100644 --- a/src/ValueObject/ClassRequiredProperty.php +++ b/src/ValueObject/ClassRequiredProperty.php @@ -4,17 +4,17 @@ namespace Cambis\Silverstan\ValueObject; -final readonly class ClassRequiredProperty +final class ClassRequiredProperty { public function __construct( /** * @var class-string */ - public string $className, + public readonly string $className, /** * @var string[] */ - public array $properties + public readonly array $properties ) { } } diff --git a/tests/Extension/ClassPropertiesNode/ConfigurationPropertiesExtensionTest.php b/tests/Extension/ClassPropertiesNode/ConfigurationPropertiesExtensionTest.php deleted file mode 100644 index 6563145..0000000 --- a/tests/Extension/ClassPropertiesNode/ConfigurationPropertiesExtensionTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -final class ConfigurationPropertiesExtensionTest extends RuleTestCase -{ - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } - - public function testRuleConfigurableClass(): void - { - $this->analyse([__DIR__ . '/Fixture/ConfigurableClass.php'], [ - [ - 'Property Cambis\Silverstan\Tests\Extension\ClassPropertiesNode\Fixture\ConfigurableClass::$unconfigurable_property is never read, only written.', - 14, - 'See: https://phpstan.org/developing-extensions/always-read-written-properties', - ], - [ - 'Static property Cambis\Silverstan\Tests\Extension\ClassPropertiesNode\Fixture\ConfigurableClass::$blocklisted_property is never read, only written.', - 19, - 'See: https://phpstan.org/developing-extensions/always-read-written-properties', - ], - ]); - } - - public function testRuleConfigurableExtension(): void - { - $this->analyse([__DIR__ . '/Fixture/ConfigurableExtension.php'], [ - [ - 'Property Cambis\Silverstan\Tests\Extension\ClassPropertiesNode\Fixture\ConfigurableExtension::$unconfigurable_property is never read, only written.', - 12, - 'See: https://phpstan.org/developing-extensions/always-read-written-properties', - ], - [ - 'Static property Cambis\Silverstan\Tests\Extension\ClassPropertiesNode\Fixture\ConfigurableExtension::$blocklisted_property is never read, only written.', - 17, - 'See: https://phpstan.org/developing-extensions/always-read-written-properties', - ], - ]); - } - - #[Override] - protected function getRule(): Rule - { - /** @phpstan-ignore-next-line phpstanApi.classConstant */ - return self::getContainer()->getByType(UnusedPrivatePropertyRule::class); - } -} diff --git a/tests/Extension/ClassPropertiesNode/Fixture/ConfigurableClass.php b/tests/Extension/ClassPropertiesNode/Fixture/ConfigurableClass.php deleted file mode 100644 index 6db13f5..0000000 --- a/tests/Extension/ClassPropertiesNode/Fixture/ConfigurableClass.php +++ /dev/null @@ -1,20 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ExtensionTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/PhpDoc/Fixture/ExtensionTypes.php b/tests/Extension/PhpDoc/Fixture/ExtensionTypes.php deleted file mode 100644 index c0e596d..0000000 --- a/tests/Extension/PhpDoc/Fixture/ExtensionTypes.php +++ /dev/null @@ -1,46 +0,0 @@ -getOwner()); - -assertType( - Bar::class . '|' . Foo::class, - (new UnionExtension())->getOwner() -); - -assertType( - sprintf('%s&static(%s)', Foo::class, SimpleIntersectionExtension::class), - (new SimpleIntersectionExtension())->getOwner() -); - -assertType( - sprintf( - '%s&%s&static(%s)', - Bar::class, - Foo::class, - ComplexIntersectionExtension::class - ), - (new ComplexIntersectionExtension())->getOwner() -); - -assertType( - sprintf( - '(%s&static(%s))|(%s&static(%s))', - Bar::class, - DNFExtension::class, - Foo::class, - DNFExtension::class - ), - (new DNFExtension())->getOwner() -); diff --git a/tests/Extension/PhpDoc/Source/Extension/ComplexIntersectionExtension.php b/tests/Extension/PhpDoc/Source/Extension/ComplexIntersectionExtension.php deleted file mode 100644 index 04f50a3..0000000 --- a/tests/Extension/PhpDoc/Source/Extension/ComplexIntersectionExtension.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -final class ComplexIntersectionExtension extends Extension implements TestOnly -{ -} diff --git a/tests/Extension/PhpDoc/Source/Extension/DNFExtension.php b/tests/Extension/PhpDoc/Source/Extension/DNFExtension.php deleted file mode 100644 index 3904a77..0000000 --- a/tests/Extension/PhpDoc/Source/Extension/DNFExtension.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -final class DNFExtension extends Extension implements TestOnly -{ -} diff --git a/tests/Extension/PhpDoc/Source/Extension/SimpleExtension.php b/tests/Extension/PhpDoc/Source/Extension/SimpleExtension.php deleted file mode 100644 index 610aac7..0000000 --- a/tests/Extension/PhpDoc/Source/Extension/SimpleExtension.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -final class SimpleExtension extends Extension implements TestOnly -{ -} diff --git a/tests/Extension/PhpDoc/Source/Extension/SimpleIntersectionExtension.php b/tests/Extension/PhpDoc/Source/Extension/SimpleIntersectionExtension.php deleted file mode 100644 index 1b0049c..0000000 --- a/tests/Extension/PhpDoc/Source/Extension/SimpleIntersectionExtension.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -final class SimpleIntersectionExtension extends Extension implements TestOnly -{ -} diff --git a/tests/Extension/PhpDoc/Source/Extension/UnionExtension.php b/tests/Extension/PhpDoc/Source/Extension/UnionExtension.php deleted file mode 100644 index 1dbc26d..0000000 --- a/tests/Extension/PhpDoc/Source/Extension/UnionExtension.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -final class UnionExtension extends Extension implements TestOnly -{ -} diff --git a/tests/Extension/PhpDoc/Source/Model/Bar.php b/tests/Extension/PhpDoc/Source/Model/Bar.php deleted file mode 100644 index fcb347a..0000000 --- a/tests/Extension/PhpDoc/Source/Model/Bar.php +++ /dev/null @@ -1,14 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/DBPropertyReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/DependencyInjectionPropertyReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/DisplayLogicMethodReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/ExtensionMethodReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/ExtensionPropertyReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/SimpleRelationMethodReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/SimpleRelationPropertyReflections.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/ManyRelationMethodReflections.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Reflection/Fixture/DBPropertyReflections.php b/tests/Extension/Reflection/Fixture/DBPropertyReflections.php deleted file mode 100644 index 3f570ed..0000000 --- a/tests/Extension/Reflection/Fixture/DBPropertyReflections.php +++ /dev/null @@ -1,52 +0,0 @@ -ID); -assertType('int', $foo->OldID); -assertType('string', $foo->Title); -assertType(sprintf('class-string<%s>', Foo::class), $foo->ClassName); -assertType('string', $foo->LastEdited); -assertType('string', $foo->Created); -assertType(sprintf('class-string<%s>|null', Foo::class), $foo->ObsoleteClassName); - -// Basic fields -assertType('bool', $foo->Boolean); -assertType('float', $foo->Currency); -assertType('string|null', $foo->Date); -assertType('float', $foo->Decimal); -assertType('string|null', $foo->Enum); -assertType('string|null', $foo->HTMLText); -assertType('string|null', $foo->HTMLVarchar); -assertType('int', $foo->Int); -assertType('float', $foo->Percentage); -assertType('string|null', $foo->Datetime); -assertType('string|null', $foo->Text); -assertType('string|null', $foo->Time); -assertType('string|null', $foo->Varchar); -assertType('string', $foo->TypehintedField); - -// Inherited fields -assertType('bool', $bar->Boolean); -assertType('float', $bar->Currency); -assertType('string|null', $bar->Date); -assertType('float', $bar->Decimal); -assertType('string|null', $bar->Enum); -assertType('string|null', $bar->HTMLText); -assertType('string|null', $bar->HTMLVarchar); -assertType('int', $bar->Int); -assertType('float', $bar->Percentage); -assertType('string|null', $bar->Datetime); -assertType('string|null', $bar->Text); -assertType('string|null', $bar->Time); -assertType('string|null', $bar->Varchar); -assertType('string', $bar->TypehintedField); diff --git a/tests/Extension/Reflection/Fixture/DependencyInjectionPropertyReflections.php b/tests/Extension/Reflection/Fixture/DependencyInjectionPropertyReflections.php deleted file mode 100644 index 693537b..0000000 --- a/tests/Extension/Reflection/Fixture/DependencyInjectionPropertyReflections.php +++ /dev/null @@ -1,12 +0,0 @@ -diObject); -assertType('array', $foo->diArray); -assertType('array<' . Foo::class . '>', $foo->typedDiArray); diff --git a/tests/Extension/Reflection/Fixture/DisplayLogicMethodReflections.php b/tests/Extension/Reflection/Fixture/DisplayLogicMethodReflections.php deleted file mode 100644 index 2c766c6..0000000 --- a/tests/Extension/Reflection/Fixture/DisplayLogicMethodReflections.php +++ /dev/null @@ -1,39 +0,0 @@ -displayIf('HasProducts')->isChecked() -); - -assertType( - Criteria::class, - $sizes->hideUnless('ProductType')->isEqualTo('t-shirt') - ->andIf('Price')->isGreaterThan(10) -); - -assertType( - Criteria::class, - $payment->hideIf('Price')->isEqualTo(0) -); - -assertType( - FormField::class, - $shipping->displayIf('ProductType') - ->isEqualTo('furniture') - ->andIf() - ->group() - ->orIf('RushShipping')->isChecked() - ->orIf('ShippingAddress')->isNotEmpty() - ->end() -); diff --git a/tests/Extension/Reflection/Fixture/ExtensionMethodReflections.php b/tests/Extension/Reflection/Fixture/ExtensionMethodReflections.php deleted file mode 100644 index 9cb029c..0000000 --- a/tests/Extension/Reflection/Fixture/ExtensionMethodReflections.php +++ /dev/null @@ -1,14 +0,0 @@ -publicMethod(true)); -assertType('bool', $foo->protectedMethod(true)); -assertType('*ERROR*', $foo->privateMethod(true)); - -assertType('Cambis\Silverstan\Tests\Extension\Reflection\Source\Model\Foo', $foo->ExtensionHasOne()); diff --git a/tests/Extension/Reflection/Fixture/ExtensionPropertyReflections.php b/tests/Extension/Reflection/Fixture/ExtensionPropertyReflections.php deleted file mode 100644 index 653636e..0000000 --- a/tests/Extension/Reflection/Fixture/ExtensionPropertyReflections.php +++ /dev/null @@ -1,13 +0,0 @@ -ExtensionField); -assertType('string|null', $bar->ExtensionField); diff --git a/tests/Extension/Reflection/Fixture/ManyRelationMethodReflections.php b/tests/Extension/Reflection/Fixture/ManyRelationMethodReflections.php deleted file mode 100644 index 1be3b58..0000000 --- a/tests/Extension/Reflection/Fixture/ManyRelationMethodReflections.php +++ /dev/null @@ -1,41 +0,0 @@ -', ManyManyList::class, Foo::class), - $foo->Ancestors() -); - -// has_many -assertType( - sprintf('%s<%s>', HasManyList::class, Foo::class), - $foo->Siblings() -); - -assertType( - sprintf('%s<%s>', HasManyList::class, Foo::class), - $foo->TypehintedHasMany() -); - -// many_many -assertType( - sprintf('%s<%s>', ManyManyList::class, Foo::class), - $foo->Family() -); - -// many_many_through -assertType( - sprintf('%s<%s>', ManyManyThroughList::class, Foo::class), - $foo->ExtendedFamily() -); diff --git a/tests/Extension/Reflection/Fixture/SimpleRelationMethodReflections.php b/tests/Extension/Reflection/Fixture/SimpleRelationMethodReflections.php deleted file mode 100644 index da14af6..0000000 --- a/tests/Extension/Reflection/Fixture/SimpleRelationMethodReflections.php +++ /dev/null @@ -1,15 +0,0 @@ -Parent()); - -// has_one -assertType(Foo::class, $foo->Child()); -assertType(Foo::class, $foo->TypehintedHasOne()); diff --git a/tests/Extension/Reflection/Fixture/SimpleRelationPropertyReflections.php b/tests/Extension/Reflection/Fixture/SimpleRelationPropertyReflections.php deleted file mode 100644 index 7bcce8d..0000000 --- a/tests/Extension/Reflection/Fixture/SimpleRelationPropertyReflections.php +++ /dev/null @@ -1,14 +0,0 @@ -ParentID); - -// has_one -assertType('int', $foo->ChildID); diff --git a/tests/Extension/Reflection/Fixture/ViewableDataPropertyReflections.php b/tests/Extension/Reflection/Fixture/ViewableDataPropertyReflections.php deleted file mode 100644 index 4667d30..0000000 --- a/tests/Extension/Reflection/Fixture/ViewableDataPropertyReflections.php +++ /dev/null @@ -1,20 +0,0 @@ -Bar); - -if ($foo->Bar instanceof Bar) { - assertType(Bar::class, $foo->Bar); -} - -$foo->Baz = 'baz'; - -assertType("'baz'", $foo->Baz); diff --git a/tests/Extension/Reflection/Source/Extension/FooExtension.php b/tests/Extension/Reflection/Source/Extension/FooExtension.php deleted file mode 100644 index c7c4218..0000000 --- a/tests/Extension/Reflection/Source/Extension/FooExtension.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -final class FooExtension extends Extension implements TestOnly -{ - private static array $db = [ - 'ExtensionField' => 'Varchar(255)', - ]; - - private static array $has_one = [ - 'ExtensionHasOne' => Foo::class . '.extension', - ]; - - public function publicMethod(bool $arg): bool - { - return $arg; - } - - protected function protectedMethod(bool $arg): bool - { - return $arg; - } - - private function privateMethod(bool $arg): bool - { - return $arg; - } -} diff --git a/tests/Extension/Reflection/Source/Model/Bar.php b/tests/Extension/Reflection/Source/Model/Bar.php deleted file mode 100644 index 892b872..0000000 --- a/tests/Extension/Reflection/Source/Model/Bar.php +++ /dev/null @@ -1,9 +0,0 @@ - TypehintedHasMany() - */ - -class Foo extends DataObject implements TestOnly -{ - /** - * @var self[] - */ - public array $typedDiArray; - - private static array $db = [ - 'Boolean' => 'Boolean', - 'Currency' => 'Currency', - 'Date' => 'Date', - 'Decimal' => 'Decimal', - 'Enum' => 'Enum', - 'HTMLText' => 'HTMLText', - 'HTMLVarchar' => 'HTMLVarchar', - 'Int' => 'Int', - 'Percentage' => 'Percentage', - 'Datetime' => 'Datetime', - 'Text' => 'Text', - 'Time' => 'Time', - 'Varchar' => 'Varchar(255)', - 'RequiredField' => 'Varchar(255)', - 'TypehintedField' => 'Varchar(255)', - ]; - - private static array $belongs_many_many = [ - 'Ancestors' => self::class, - ]; - - private static array $belongs_to = [ - 'Parent' => self::class . '.Parent', - ]; - - private static array $has_one = [ - 'Child' => self::class . '.Child', - ]; - - private static array $has_many = [ - 'Siblings' => self::class, - ]; - - private static array $many_many = [ - 'Family' => self::class, - 'ExtendedFamily' => [ - 'through' => self::class, - 'from' => 'Me', - 'to' => 'You', - ], - ]; - - private static array $extensions = [ - FooExtension::class, - ]; - - private static array $dependencies = [ - 'diObject' => '%$' . self::class, - 'diArray' => [ - '%$' . self::class, - ], - 'typedDiArray' => [ - '%$' . self::class, - ], - ]; -} diff --git a/tests/Extension/Reflection/ViewableDataClassReflectionExtensionTest.php b/tests/Extension/Reflection/ViewableDataClassReflectionExtensionTest.php deleted file mode 100644 index 9a97030..0000000 --- a/tests/Extension/Reflection/ViewableDataClassReflectionExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ViewableDataPropertyReflections.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtensionTest.php b/tests/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtensionTest.php deleted file mode 100644 index 405b2ff..0000000 --- a/tests/Extension/Type/ConfigCollectionInterfaceGetReturnTypeExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ConfigCollectionInterfacePropertyTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/ConfigForClassGetReturnTypeExtensionTest.php b/tests/Extension/Type/ConfigForClassGetReturnTypeExtensionTest.php deleted file mode 100644 index 567bf3c..0000000 --- a/tests/Extension/Type/ConfigForClassGetReturnTypeExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ConfigForClassPropertyTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/DataObjectDbObjectReturnTypeExtensionTest.php b/tests/Extension/Type/DataObjectDbObjectReturnTypeExtensionTest.php deleted file mode 100644 index af1099b..0000000 --- a/tests/Extension/Type/DataObjectDbObjectReturnTypeExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/DataObjectDbObjectTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/ExtensibleHasExtensionTypeSpecifyingExtensionTest.php b/tests/Extension/Type/ExtensibleHasExtensionTypeSpecifyingExtensionTest.php deleted file mode 100644 index 6c48d43..0000000 --- a/tests/Extension/Type/ExtensibleHasExtensionTypeSpecifyingExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ExtensibleHasExtensionTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/ExtensibleHasMethodTypeSpecifyingExtensionTest.php b/tests/Extension/Type/ExtensibleHasMethodTypeSpecifyingExtensionTest.php deleted file mode 100644 index 5040d22..0000000 --- a/tests/Extension/Type/ExtensibleHasMethodTypeSpecifyingExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ExtensibleHasMethodTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/Fixture/ConfigCollectionInterfacePropertyTypes.php b/tests/Extension/Type/Fixture/ConfigCollectionInterfacePropertyTypes.php deleted file mode 100644 index 68ed20b..0000000 --- a/tests/Extension/Type/Fixture/ConfigCollectionInterfacePropertyTypes.php +++ /dev/null @@ -1,22 +0,0 @@ -get(ConfigurableClass::class, 'native_array')); -assertType('array', Config::inst()->get(ConfigurableClass::class, 'phpdoc_array')); -assertType('array', Config::inst()->get(ConfigurableClass::class, 'iterable_typed_array')); - -assertType('bool', Config::inst()->get(ConfigurableClass::class, 'native_boolean')); -assertType('bool', Config::inst()->get(ConfigurableClass::class, 'phpdoc_boolean')); - -assertType('int', Config::inst()->get(ConfigurableClass::class, 'native_integer')); -assertType('int', Config::inst()->get(ConfigurableClass::class, 'phpdoc_integer')); - -assertType('string', Config::inst()->get(ConfigurableClass::class, 'native_string')); -assertType('string', Config::inst()->get(ConfigurableClass::class, 'phpdoc_string')); - -assertType('mixed', Config::inst()->get(ConfigurableClass::class, 'mixed')); diff --git a/tests/Extension/Type/Fixture/ConfigForClassPropertyTypes.php b/tests/Extension/Type/Fixture/ConfigForClassPropertyTypes.php deleted file mode 100644 index 61f97f9..0000000 --- a/tests/Extension/Type/Fixture/ConfigForClassPropertyTypes.php +++ /dev/null @@ -1,21 +0,0 @@ -get('native_array')); -assertType('array', ConfigurableClass::config()->get('phpdoc_array')); -assertType('array', ConfigurableClass::config()->get('iterable_typed_array')); - -assertType('bool', ConfigurableClass::config()->get('native_boolean')); -assertType('bool', ConfigurableClass::config()->get('phpdoc_boolean')); - -assertType('int', ConfigurableClass::config()->get('native_integer')); -assertType('int', ConfigurableClass::config()->get('phpdoc_integer')); - -assertType('string', ConfigurableClass::config()->get('native_string')); -assertType('string', ConfigurableClass::config()->get('phpdoc_string')); - -assertType('mixed', ConfigurableClass::config()->get('mixed')); diff --git a/tests/Extension/Type/Fixture/DataObjectDbObjectTypes.php b/tests/Extension/Type/Fixture/DataObjectDbObjectTypes.php deleted file mode 100644 index a1a16bd..0000000 --- a/tests/Extension/Type/Fixture/DataObjectDbObjectTypes.php +++ /dev/null @@ -1,33 +0,0 @@ -dbObject('Boolean')); -assertType(DBCurrency::class, $foo->dbObject('Currency')); -assertType(DBDate::class, $foo->dbObject('Date')); -assertType(DBDecimal::class, $foo->dbObject('Decimal')); -assertType(DBEnum::class, $foo->dbObject('Enum')); -assertType(DBHTMLText::class, $foo->dbObject('HTMLText')); -assertType(DBHTMLVarchar::class, $foo->dbObject('HTMLVarchar')); -assertType(DBInt::class, $foo->dbObject('Int')); -assertType(DBPercentage::class, $foo->dbObject('Percentage')); -assertType(DBText::class, $foo->dbObject('Text')); -assertType(DBTime::class, $foo->dbObject('Time')); -assertType(DBVarchar::class, $foo->dbObject('Varchar')); diff --git a/tests/Extension/Type/Fixture/ExtensibleHasExtensionTypes.php b/tests/Extension/Type/Fixture/ExtensibleHasExtensionTypes.php deleted file mode 100644 index d4f58d5..0000000 --- a/tests/Extension/Type/Fixture/ExtensibleHasExtensionTypes.php +++ /dev/null @@ -1,19 +0,0 @@ -hasExtension(FooExtension::class)) { - assertType( - sprintf('%s&%s', FooExtension::class, Foo::class), - $foo - ); - - assertType('bool', $foo->doSomething()); -} diff --git a/tests/Extension/Type/Fixture/ExtensibleHasMethodTypes.php b/tests/Extension/Type/Fixture/ExtensibleHasMethodTypes.php deleted file mode 100644 index 1718b78..0000000 --- a/tests/Extension/Type/Fixture/ExtensibleHasMethodTypes.php +++ /dev/null @@ -1,18 +0,0 @@ -hasMethod('doSomething')) { - assertType( - sprintf('%s&hasMethod(%s)', Foo::class, 'doSomething'), - $foo - ); - - assertType('mixed', $foo->doSomething()); -} diff --git a/tests/Extension/Type/Fixture/InjectorGetTypes.php b/tests/Extension/Type/Fixture/InjectorGetTypes.php deleted file mode 100644 index 1b45782..0000000 --- a/tests/Extension/Type/Fixture/InjectorGetTypes.php +++ /dev/null @@ -1,40 +0,0 @@ -get('Foo') -); - -assertType( - Foo::class, - Injector::inst()->get(Foo::class) -); - -assertType( - Foo::class, - singleton('Foo') -); - -assertType( - Foo::class, - singleton(Foo::class) -); - -assertType( - Foo::class, - Injector::inst()->create(Foo::class) -); - -assertType( - Foo::class, - Injector::inst()->createWithArgs(Foo::class, [ - 'Title' => 'Bar', - ]) -); diff --git a/tests/Extension/Type/Fixture/ViewableDataHasFieldTypes.php b/tests/Extension/Type/Fixture/ViewableDataHasFieldTypes.php deleted file mode 100644 index a3cb7e0..0000000 --- a/tests/Extension/Type/Fixture/ViewableDataHasFieldTypes.php +++ /dev/null @@ -1,27 +0,0 @@ -hasField('Bar')) { - assertType('null', $foo->Bar); -} - -if ($foo->hasField('Bar')) { - assertType('mixed', $foo->Bar); -} - -$bar = ViewableData::create(); - -if (!$bar->hasField('Baz')) { - assertType('null', $bar->Baz); -} - -if ($bar->hasField('Baz')) { - assertType('mixed', $bar->Baz); -} diff --git a/tests/Extension/Type/InjectorGetReturnTypeExtensionTest.php b/tests/Extension/Type/InjectorGetReturnTypeExtensionTest.php deleted file mode 100644 index 2a0e334..0000000 --- a/tests/Extension/Type/InjectorGetReturnTypeExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/InjectorGetTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Extension/Type/Source/ConfigurableClass.php b/tests/Extension/Type/Source/ConfigurableClass.php deleted file mode 100644 index bfb3c7a..0000000 --- a/tests/Extension/Type/Source/ConfigurableClass.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -final class FooExtension extends Extension -{ - protected function doSomething(): bool - { - return true; - } -} diff --git a/tests/Extension/Type/Source/Model/Foo.php b/tests/Extension/Type/Source/Model/Foo.php deleted file mode 100644 index 40f49f7..0000000 --- a/tests/Extension/Type/Source/Model/Foo.php +++ /dev/null @@ -1,27 +0,0 @@ - 'Boolean', - 'Currency' => 'Currency', - 'Date' => 'Date', - 'Decimal' => 'Decimal', - 'Enum' => 'Enum', - 'HTMLText' => 'HTMLText', - 'HTMLVarchar' => 'HTMLVarchar', - 'Int' => 'Int', - 'Percentage' => 'Percentage', - 'Datetime' => 'Datetime', - 'Text' => 'Text', - 'Time' => 'Time', - 'Varchar' => 'Varchar(255)', - ]; -} diff --git a/tests/Extension/Type/ViewableDataHasFieldTypeSpecifyingExtensionTest.php b/tests/Extension/Type/ViewableDataHasFieldTypeSpecifyingExtensionTest.php deleted file mode 100644 index 7aca45c..0000000 --- a/tests/Extension/Type/ViewableDataHasFieldTypeSpecifyingExtensionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ViewableDataHasFieldTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../tests.neon']; - } -} diff --git a/tests/Rule/ClassMethod/Fixture/DataObjectWrite.php b/tests/Rule/ClassMethod/Fixture/DataObjectWrite.php deleted file mode 100644 index bb78343..0000000 --- a/tests/Rule/ClassMethod/Fixture/DataObjectWrite.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -final class RequireParentCallInOverridenMethodRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DataObjectWrite.php'], [ - [ - 'Class method Cambis\Silverstan\Tests\Rule\ClassMethod\Fixture\DataObjectWrite::requireDefaultRecords() should call parent::requireDefaultRecords() first.', - 10, - ], - [ - 'Class method Cambis\Silverstan\Tests\Rule\ClassMethod\Fixture\DataObjectWrite::onBeforeWrite() is missing required call to parent::onBeforeWrite().', - 23, - ], - ]); - } - - #[Override] - protected function getRule(): Rule - { - return new RequireParentCallInOverridenMethodRule( - new NodeFinder(), - [ - [ - 'class' => DataObject::class, - 'method' => 'onBeforeWrite', - ], - [ - 'class' => DataObject::class, - 'method' => 'onAfterWrite', - 'isFirst' => true, - ], - [ - 'class' => DataObject::class, - 'method' => 'requireDefaultRecords', - 'isFirst' => true, - ], - ] - ); - } -} diff --git a/tests/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRuleTest.php b/tests/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRuleTest.php deleted file mode 100755 index 029642e..0000000 --- a/tests/Rule/ClassPropertyNode/DisallowOverridingOfConfigurationPropertyTypeRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ -final class DisallowOverridingOfConfigurationPropertyTypeRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowOverridingName.php'], [ - [ - 'Type string|null of configuration property Cambis\Silverstan\Tests\Rule\ClassPropertyNode\Fixture\DisallowOverridingName::$table_name is not the same as type string of overridden configuration property ' . DataObject::class . '::$table_name.', - 12, - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowOverridingOfConfigurationPropertyTypeRule( - self::getContainer()->getByType(ClassReflectionAnalyser::class), - self::getContainer()->getByType(PropertyReflectionAnalyser::class), - self::getContainer()->getByType(ReflectionResolver::class) - ); - } -} diff --git a/tests/Rule/ClassPropertyNode/Fixture/DisallowOverridingName.php b/tests/Rule/ClassPropertyNode/Fixture/DisallowOverridingName.php deleted file mode 100755 index 51ac249..0000000 --- a/tests/Rule/ClassPropertyNode/Fixture/DisallowOverridingName.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -final class RequireConfigurationPropertyOverrideRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/RequireTableName.php'], [ - [ - 'Class Cambis\Silverstan\Tests\Rule\InClassNode\Fixture\RequireTableName is missing required configuration property $table_name', - 8, - ], - ]); - } - - #[Override] - protected function getRule(): Rule - { - return new RequireConfigurationPropertyOverrideRule([ - [ - 'class' => DataObject::class, - 'properties' => ['table_name'], - ], - ]); - } -} diff --git a/tests/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRuleTest.php b/tests/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRuleTest.php deleted file mode 100644 index 66f79cf..0000000 --- a/tests/Rule/MethodCall/DisallowMethodCallOnUnsafeDataObjectRuleTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -final class DisallowMethodCallOnUnsafeDataObjectRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowMethodCallDataObject.php'], [ - [ - 'Accessing $foo->Bar()->doSomethingPotentiallyDangerous() is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 9, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - [ - 'Accessing $foo->Bar()->doSomethingPotentiallyDangerous() is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 16, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - [ - 'Accessing $foo->Bar()->doSomethingPotentiallyDangerous() is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 23, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowMethodCallOnUnsafeDataObjectRule(['doSomethingSafe']); - } -} diff --git a/tests/Rule/MethodCall/Fixture/DisallowMethodCallDataObject.php b/tests/Rule/MethodCall/Fixture/DisallowMethodCallDataObject.php deleted file mode 100644 index e1fa7ed..0000000 --- a/tests/Rule/MethodCall/Fixture/DisallowMethodCallDataObject.php +++ /dev/null @@ -1,27 +0,0 @@ -Bar()->doSomethingPotentiallyDangerous(); - -if ($foo->Bar()->exists()) { - $foo->Bar()->doSomethingPotentiallyDangerous(); -} - -if (!$foo->Bar()->exists()) { - $foo->Bar()->doSomethingPotentiallyDangerous(); -} - -$foo->Bar()->write(); -$foo->Bar()->doSomethingPotentiallyDangerous(); - -$foo->Bar()->delete(); -$foo->Bar()->doSomethingPotentiallyDangerous(); - -$foo->Baz()->doSomethingPotentiallyDangerous(); - -$foo->Bar()->doSomethingSafe(); diff --git a/tests/Rule/MethodCall/Source/Model/Foo.php b/tests/Rule/MethodCall/Source/Model/Foo.php deleted file mode 100644 index 4fa50ef..0000000 --- a/tests/Rule/MethodCall/Source/Model/Foo.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -final class DisallowNewInstanceOnInjectableRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowNewInstance.php'], [ - [ - 'Use Cambis\Silverstan\Tests\Rule\New_\Source\InjectableClass::create() instead of new Cambis\Silverstan\Tests\Rule\New_\Source\InjectableClass().', - 13, - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowNewInstanceOnInjectableRule( - self::getContainer()->getByType(ClassReflectionAnalyser::class), - self::getContainer()->getByType(ReflectionProvider::class) - ); - } -} diff --git a/tests/Rule/New_/Fixture/DisallowNewInstance.php b/tests/Rule/New_/Fixture/DisallowNewInstance.php deleted file mode 100755 index 86e8035..0000000 --- a/tests/Rule/New_/Fixture/DisallowNewInstance.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ -final class DisallowPropertyFetchOnConfigForClassRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowPropertyFetch.php'], [ - [ - 'Cannot resolve the type of Cambis\Silverstan\Tests\Rule\PropertyFetch\Fixture\DisallowPropertyFetch::config()->foo. Use Cambis\Silverstan\Tests\Rule\PropertyFetch\Fixture\DisallowPropertyFetch::config()->get(\'foo\') instead.', - 16, - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowPropertyFetchOnConfigForClassRule(); - } -} diff --git a/tests/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRuleTest.php b/tests/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRuleTest.php deleted file mode 100755 index 52416f1..0000000 --- a/tests/Rule/PropertyFetch/DisallowPropertyFetchOnUnsafeDataObjectRuleTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -final class DisallowPropertyFetchOnUnsafeDataObjectRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowPropertyFetchDataObject.php'], [ - [ - 'Accessing $foo->Bar()->Title is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 9, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - [ - 'Accessing $foo->Bar()->Title is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 17, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - [ - 'Accessing $foo->Bar()->Title is potentially unsafe, as $foo->Bar() may not exist in the database. Call $foo->Bar()->exists() first to verify that it is safe to access.', - 24, - 'See https://api.silverstripe.org/5/SilverStripe/ORM/DataObject.html#method_exists', - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowPropertyFetchOnUnsafeDataObjectRule(); - } -} diff --git a/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetch.php b/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetch.php deleted file mode 100755 index 8c50cc8..0000000 --- a/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetch.php +++ /dev/null @@ -1,19 +0,0 @@ -foo; - echo static::config()->get('foo'); - } -} diff --git a/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetchDataObject.php b/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetchDataObject.php deleted file mode 100644 index 4dc47d4..0000000 --- a/tests/Rule/PropertyFetch/Fixture/DisallowPropertyFetchDataObject.php +++ /dev/null @@ -1,26 +0,0 @@ -Bar()->Title; -$foo->Bar()->Title = 'Foo'; - -if ($foo->Bar()->exists()) { - $foo->Bar()->Title; -} - -if (!$foo->Bar()->exists()) { - $foo->Bar()->Title; -} - -$foo->Bar()->write(); -$foo->Bar()->Title; - -$foo->Bar()->delete(); -$foo->Bar()->Title; - -$foo->Baz()->Title; diff --git a/tests/Rule/PropertyFetch/Source/Model/Foo.php b/tests/Rule/PropertyFetch/Source/Model/Foo.php deleted file mode 100644 index 884068e..0000000 --- a/tests/Rule/PropertyFetch/Source/Model/Foo.php +++ /dev/null @@ -1,25 +0,0 @@ -write(); - } -} diff --git a/tests/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest.php b/tests/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest.php deleted file mode 100755 index f3babf6..0000000 --- a/tests/Rule/StaticPropertyFetch/DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -final class DisallowStaticPropertyFetchOnConfigurationPropertyRuleTest extends RuleTestCase -{ - public function testRule(): void - { - $this->analyse([__DIR__ . '/Fixture/DisallowStaticPropertyFetch.php'], [ - [ - 'Unsafe access to configuration property Cambis\Silverstan\Tests\Rule\StaticPropertyFetch\Fixture\DisallowStaticPropertyFetch::$foo through self::. Use self::config->get(\'foo\') instead.', - 23, - 'See: https://docs.silverstripe.org/en/5/developer_guides/configuration/configuration/#accessing-configuration-properties', - ], - ]); - } - - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/../../tests.neon', - ]; - } - - #[Override] - protected function getRule(): Rule - { - return new DisallowStaticPropertyFetchOnConfigurationPropertyRule( - self::getContainer()->getByType(ClassReflectionAnalyser::class), - self::getContainer()->getByType(PropertyReflectionAnalyser::class) - ); - } -} diff --git a/tests/Rule/StaticPropertyFetch/Fixture/DisallowStaticPropertyFetch.php b/tests/Rule/StaticPropertyFetch/Fixture/DisallowStaticPropertyFetch.php deleted file mode 100755 index 221b459..0000000 --- a/tests/Rule/StaticPropertyFetch/Fixture/DisallowStaticPropertyFetch.php +++ /dev/null @@ -1,27 +0,0 @@ - 'Foo', - ])]); - -assertType( - ArrayList::class . '<' . Foo::class . '>', - $list -); - -assertType( - Foo::class . '|null', - $list->first() -); - -assertType( - Foo::class . '|null', - $list->last() -); - -foreach ($list as $item) { - assertType(Foo::class, $item); -} diff --git a/tests/Type/Fixture/DataListTypes.php b/tests/Type/Fixture/DataListTypes.php deleted file mode 100644 index 85fb781..0000000 --- a/tests/Type/Fixture/DataListTypes.php +++ /dev/null @@ -1,22 +0,0 @@ -', - Foo::get() -); - -assertType( - Foo::class . '|null', - Foo::get()->first() -); - -assertType( - Foo::class . '|null', - Foo::get()->last() -); diff --git a/tests/Type/Fixture/PageTypes.php b/tests/Type/Fixture/PageTypes.php deleted file mode 100644 index d9c2506..0000000 --- a/tests/Type/Fixture/PageTypes.php +++ /dev/null @@ -1,14 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/ArrayListTypes.php'); - yield from $this->gatherAssertTypes(__DIR__ . '/Fixture/DataListTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../tests.neon']; - } -} diff --git a/tests/Type/PageTypeTest.php b/tests/Type/PageTypeTest.php deleted file mode 100644 index 1b058ce..0000000 --- a/tests/Type/PageTypeTest.php +++ /dev/null @@ -1,34 +0,0 @@ -gatherAssertTypes(__DIR__ . '/Fixture/PageTypes.php'); - } - - /** - * @dataProvider typeFileAsserts - */ - public function testFileAsserts(string $assertType, string $file, mixed ...$args): void - { - $this->assertFileAsserts($assertType, $file, ...$args); - } - - /** - * @return string[] - */ - #[Override] - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../tests.neon']; - } -} diff --git a/tests/Type/Source/Model/Foo.php b/tests/Type/Source/Model/Foo.php deleted file mode 100644 index eb9f77c..0000000 --- a/tests/Type/Source/Model/Foo.php +++ /dev/null @@ -1,10 +0,0 @@ -