From 2aa8e8da1bb3396d06fa92af5c13d26f0958a134 Mon Sep 17 00:00:00 2001 From: Alexandre Gomes Gaigalas Date: Sat, 14 Mar 2026 21:57:34 -0300 Subject: [PATCH] Move to src/ layout, add strict_types, add PHPStan to CI - Move source from library/Respect/Data/ to src/ and tests from tests/library/Respect/Data/ to tests/. Update PSR-4 autoload to Respect\Data\ -> src/ with autoload-dev for tests. - Add declare(strict_types=1) to all 22 PHP files. - Raise PHPStan to level 2 with ignores for magic method and property access patterns. - Modernize CI: split into tests and static-analysis jobs, update to actions/checkout@v6 and ramsey/composer-install@v3. --- .github/workflows/ci.yml | 38 ++++++++----------- composer.json | 7 +++- phpcs.xml.dist | 2 +- phpstan.neon.dist | 8 ++-- .../Respect/Data => src}/AbstractMapper.php | 2 + .../Data => src}/CollectionIterator.php | 2 + .../Data => src}/Collections/Collection.php | 2 + .../Data => src}/Collections/Filterable.php | 2 + .../Data => src}/Collections/Filtered.php | 2 + .../Respect/Data => src}/Collections/Mix.php | 2 + .../Data => src}/Collections/Mixable.php | 2 + .../Data => src}/Collections/Typable.php | 2 + .../Data => src}/Collections/Typed.php | 2 + .../Data => src}/Styles/AbstractStyle.php | 2 + .../Respect/Data => src}/Styles/CakePHP.php | 2 + .../Respect/Data => src}/Styles/NorthWind.php | 2 + .../Respect/Data => src}/Styles/Plural.php | 2 + .../Respect/Data => src}/Styles/Sakila.php | 2 + .../Respect/Data => src}/Styles/Standard.php | 2 + .../Respect/Data => src}/Styles/Stylable.php | 2 + .../Respect/Data => }/AbstractMapperTest.php | 2 + .../Data => }/CollectionIteratorTest.php | 2 + .../Data => }/Collections/CollectionTest.php | 2 + .../Data => }/Collections/FilteredTest.php | 2 + .../Data => }/Collections/MixedTest.php | 2 + .../Data => }/Collections/TypedTest.php | 2 + 26 files changed, 71 insertions(+), 28 deletions(-) rename {library/Respect/Data => src}/AbstractMapper.php (99%) rename {library/Respect/Data => src}/CollectionIterator.php (97%) rename {library/Respect/Data => src}/Collections/Collection.php (99%) rename {library/Respect/Data => src}/Collections/Filterable.php (87%) rename {library/Respect/Data => src}/Collections/Filtered.php (94%) rename {library/Respect/Data => src}/Collections/Mix.php (94%) rename {library/Respect/Data => src}/Collections/Mixable.php (87%) rename {library/Respect/Data => src}/Collections/Typable.php (86%) rename {library/Respect/Data => src}/Collections/Typed.php (94%) rename {library/Respect/Data => src}/Styles/AbstractStyle.php (97%) rename {library/Respect/Data => src}/Styles/CakePHP.php (97%) rename {library/Respect/Data => src}/Styles/NorthWind.php (97%) rename {library/Respect/Data => src}/Styles/Plural.php (98%) rename {library/Respect/Data => src}/Styles/Sakila.php (86%) rename {library/Respect/Data => src}/Styles/Standard.php (97%) rename {library/Respect/Data => src}/Styles/Stylable.php (94%) rename tests/{library/Respect/Data => }/AbstractMapperTest.php (98%) rename tests/{library/Respect/Data => }/CollectionIteratorTest.php (98%) rename tests/{library/Respect/Data => }/Collections/CollectionTest.php (99%) rename tests/{library/Respect/Data => }/Collections/FilteredTest.php (97%) rename tests/{library/Respect/Data => }/Collections/MixedTest.php (97%) rename tests/{library/Respect/Data => }/Collections/TypedTest.php (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 757d47a..c02b873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,30 +6,24 @@ on: pull_request: jobs: - test: + tests: + name: Tests runs-on: ubuntu-latest - strategy: - matrix: - php: [ '8.5' ] steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - uses: actions/checkout@v6 + - uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: '8.5' + - uses: ramsey/composer-install@v3 + - run: composer phpunit - - name: Get composer cache - uses: actions/cache@v4 + static-analysis: + name: Static Analysis + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: shivammathur/setup-php@v2 with: - path: ~/.cache/composer - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --no-progress --prefer-dist --no-interaction - - - name: Run PHPUnit - run: vendor/bin/phpunit --configuration phpunit.xml.dist \ No newline at end of file + php-version: '8.5' + - uses: ramsey/composer-install@v3 + - run: composer phpstan diff --git a/composer.json b/composer.json index 0e683fc..4d996e7 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,12 @@ }, "autoload": { "psr-4": { - "Respect\\": "library/Respect" + "Respect\\Data\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Respect\\Data\\": "tests/" } }, "scripts": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e46b5b1..923dc83 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -11,7 +11,7 @@ - library/ + src/ tests/ diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 863cf16..b3f480f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,9 +1,9 @@ parameters: - level: 1 + level: 2 paths: - - library/ + - src/ - tests/ ignoreErrors: - - message: '/Call to an undefined static method Respect\\Data\\Collections\\(Collection|Filtered|Mix|Typed)::\w+\(\)\./' - - message: '/Call to an undefined method Respect\\Data\\AbstractMapper::\w+\(\)\./' + - message: '/Call to an undefined (static )?method Respect\\Data\\(AbstractMapper|Collections\\(Collection|Filtered|Mix|Typed))::\w+\(\)\./' + - message: '/Access to an undefined property Respect\\Data\\Collections\\Collection::\$\w+\./' - message: '/Unsafe usage of new static\(\)\./' diff --git a/library/Respect/Data/AbstractMapper.php b/src/AbstractMapper.php similarity index 99% rename from library/Respect/Data/AbstractMapper.php rename to src/AbstractMapper.php index 0531be4..1ea036e 100644 --- a/library/Respect/Data/AbstractMapper.php +++ b/src/AbstractMapper.php @@ -1,5 +1,7 @@