Skip to content

Commit

Permalink
Merge pull request #106 from ray-di/annotation_v2
Browse files Browse the repository at this point in the history
Support doctrine/annotation v2 and PHP 8.2
  • Loading branch information
koriym authored Sep 21, 2023
2 parents cf56280 + 8ae5dac commit 8373747
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 388 deletions.
34 changes: 4 additions & 30 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,7 @@ on:
workflow_dispatch:

jobs:
coding-standards:
name: Coding Standards
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: cs2pr
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: COMPOSER_ROOT_VERSION=1.99 composer install --no-interaction --no-progress

- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr
cs:
uses: ray-di/.github/.github/workflows/coding-standards.yml@v1
with:
php_version: 8.2
59 changes: 6 additions & 53 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,9 @@ on:
workflow_dispatch:

jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
php-version:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
dependencies:
- lowest
- highest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
ini-values: zend.assertions=1

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install lowest dependencies
if: ${{ matrix.dependencies == 'lowest' }}
run: composer update --prefer-lowest --no-interaction --no-progress

- name: Install highest dependencies
if: ${{ matrix.dependencies == 'highest' }}
run: composer update --no-interaction --no-progress

- name: Run test suite
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
ci:
uses: ray-di/.github/.github/workflows/continuous-integration.yml@next_stable
with:
old_stable: '["7.2", "7.3", "7.4", "8.0", "8.1"]'
current_stable: 8.2
next_stable: 8.3
88 changes: 5 additions & 83 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,8 @@ on:
workflow_dispatch:

jobs:
static-analysis-phpstan:
name: Static Analysis with PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: cs2pr
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: COMPOSER_ROOT_VERSION=1.99 composer install --no-interaction --no-progress

- name: Run PHPStan
run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction --error-format=checkstyle | cs2pr

static-analysis-psalm:
name: Static Analysis with Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: cs2pr
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install dependencies
run: COMPOSER_ROOT_VERSION=1.99 composer install --no-interaction --no-progress

- name: Run Psalm
run: ./vendor/bin/psalm --show-info=false --output-format=checkstyle --shepherd | cs2pr

static-analysis-phpmd:
name: Static Analysis with PHPMD
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: COMPOSER_ROOT_VERSION=1.99 composer install --no-interaction --no-progress

- name: Run PHP Mess Detector
run: ./vendor/bin/phpmd src text ./phpmd.xml
sa:
uses: ray-di/.github/.github/workflows/static-analysis.yml@v1
with:
php_version: 8.2
has_crc_config: true
22 changes: 22 additions & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"symbol-whitelist": [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
"Attribute", "ReflectionAttribute",
"Ray\\Di\\AbstractModule", "Ray\\Di\\Annotation\\ScriptDir",
"Ray\\Di\\Argument", "Ray\\Di\\Arguments",
"Ray\\Di\\AssistedModule", "Ray\\Di\\Bind",
"Ray\\Di\\Container", "Ray\\Di\\Dependency",
"Ray\\Di\\DependencyInterface","Ray\\Di\\DependencyProvider",
"Ray\\Di\\Di\\Qualifier", "Ray\\Di\\Exception\\NotFound",
"Ray\\Di\\Exception\\Unbound", "Ray\\Di\\InjectionPointInterface",
"Ray\\Di\\Injector", "Ray\\Di\\InjectorInterface", "Ray\\Di\\Instance",
"Ray\\Di\\MultiBinding\\Map", "Ray\\Di\\MultiBinding\\MapProvider",
"Ray\\Di\\Name", "Ray\\Di\\NullCache",
"Ray\\Di\\NullModule", "Ray\\Di\\NullObjectDependency",
"Ray\\Di\\ProviderInterface", "Ray\\Di\\ProviderSetModule",
"Ray\\Di\\SetContextInterface"

]
}
32 changes: 18 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
],
"require": {
"php": "^7.2 || ^8.0",
"doctrine/annotations": "^1.12",
"doctrine/cache": "^1.10 | ^2.1",
"doctrine/annotations": "^1.12 || ^2.0",
"doctrine/cache": "^1.10 || ^2.1",
"koriym/attributes": "^1.0",
"koriym/null-object": "^1.0",
"koriym/param-reader": "^1.0",
"koriym/printo": "^1.0",
"nikic/php-parser": "^4.5",
"ray/aop": "^2.14"
},
"require-dev": {
"ext-pdo": "*",
"doctrine/cache": "^1.10",
"ray/di": "^2.16",
"phpunit/phpunit": "^8.5.24 || ^9.5",
"bamarni/composer-bin-plugin": "^1.4",
"ray/di": "^2.x-dev"
"bamarni/composer-bin-plugin": "^1.4"
},
"config": {
"sort-packages": true,
Expand All @@ -46,18 +46,22 @@
"files": ["tests/deleteFiles.php"]
},
"scripts": {
"post-install-cmd": ["@composer bin all install --ansi"],
"post-update-cmd": ["@composer bin all update --ansi"],
"test": "./vendor/bin/phpunit --log-junit=build/junit.xml",
"test": "phpunit --log-junit=build/junit.xml",
"tests": ["@cs", "@sa", "@test"],
"coverage": ["php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"pcov": ["php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml"],
"cs": ["./vendor/bin/phpcs --standard=./phpcs.xml src tests"],
"cs-fix": ["./vendor/bin/phpcbf src tests"],
"clean": ["./vendor/bin/phpstan clear-result-cache", "./vendor/bin/psalm --clear-cache", "rm -rf tests/tmp/*.php"],
"sa": ["./vendor/bin/psalm -c psalm.compiler.xml --show-info=true", "./vendor/bin/phpstan analyse -c phpstan.neon --no-progress"],
"metrics": ["@test", "./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"],
"phpmd": ["./vendor/bin/phpmd src/di text ./phpmd.xml"],
"cs": ["phpcs --standard=./phpcs.xml src tests"],
"cs-fix": ["phpcbf src tests"],
"clean": ["phpstan clear-result-cache", "psalm --clear-cache", "rm -rf tests/tmp/*.php"],
"sa": ["psalm -c psalm.compiler.xml --show-info=true", "phpstan analyse -c phpstan.neon --no-progress"],
"metrics": ["@test", "phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"],
"phpmd": ["phpmd src/di text ./phpmd.xml"],
"build": ["@cs", "@sa", "@pcov", "@metrics"]
},
"extra": {
"bamarni-bin": {
"forward-command": true,
"bin-links": true
}
}
}
9 changes: 0 additions & 9 deletions php-require-checker.config.json

This file was deleted.

31 changes: 25 additions & 6 deletions tests/Fake/Deep/FakeScriptInjectorContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@


use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\FilesystemCache;
use Ray\Compiler\AbstractInjectorContext;
use Ray\Compiler\Annotation\Compile;
use Ray\Compiler\DiCompileModule;
use Ray\Di\AbstractModule;
use Ray\Di\NullCache;
use Ray\Di\Scope;

final class FakeScriptInjectorContext extends AbstractInjectorContext
{
Expand All @@ -23,6 +18,30 @@ public function __invoke(): AbstractModule

public function getCache(): CacheProvider
{
return new FilesystemCache('/tmp');
return new class() extends CacheProvider {
protected function doFetch($id)
{
}

protected function doContains($id)
{
}

protected function doSave($id, $data, $lifeTime = 0)
{
}

protected function doDelete($id)
{
}

protected function doFlush()
{
}

protected function doGetStats()
{
}
};
}
}
Loading

0 comments on commit 8373747

Please sign in to comment.