-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from navarr/php8-annotation
Bring in Version 2
- Loading branch information
Showing
63 changed files
with
3,546 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
WARDEN_ENV_NAME=depends | ||
WARDEN_ENV_TYPE=laravel | ||
WARDEN_WEB_ROOT=/ | ||
WARDEN_PHP=1 | ||
COMPOSER_VERSION=2 | ||
PHP_VERSION=7.4 | ||
|
||
TRAEFIK_DOMAIN=depends.test | ||
TRAEFIK_SUBDOMAIN=app | ||
|
||
WARDEN_PHP=1 | ||
PHP_VERSION=8.0 | ||
PHP_XDEBUG_3=1 | ||
|
||
COMPOSER_VERSION=2 | ||
WARDEN_COMPOSER_DIR=./.composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,81 @@ | ||
name: Static Analysis Test | ||
name: Continuous Integration | ||
on: [push] | ||
|
||
jobs: | ||
phpunit: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: composer install | ||
|
||
- name: Test | ||
run: vendor/bin/phpunit tests --testdox --coverage-clover coverage.xml | ||
|
||
- name: Upload to CodeCov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: coverage.xml | ||
fail_ci_if_error: true | ||
|
||
phpstan: | ||
name: Static Analysis Check | ||
runs-on: ubuntu-latest | ||
container: | ||
image: davidalger/php:7.2 | ||
image: davidalger/php:8.0 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v1 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: composer2 install | ||
|
||
- name: Install Prestissimo | ||
run: composer global require hirak/prestissimo | ||
- name: Run PHPStan | ||
run: vendor/bin/phpstan | ||
|
||
phpcs: | ||
name: Code Style (PSR-12) | ||
runs-on: ubuntu-latest | ||
container: | ||
image: davidalger/php:8.0 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: composer2 install | ||
|
||
- name: PHP Code Sniffer | ||
run: vendor/bin/phpcs | ||
|
||
infection: | ||
name: Infection Check | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Run PHPStan | ||
run: vendor/bin/phpstan analyse src --level max | ||
- name: Check for Mutants | ||
run: vendor/bin/infection --threads=$(nproc) --no-progress --logger-github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
# The @dependency Annotation | ||
![Static Analysis Test](https://github.com/navarr/dependency-annotation/workflows/Static%20Analysis%20Test/badge.svg) | ||
# The #[Dependency] Attribute | ||
[![Latest Stable Version](http://poser.pugx.org/navarr/dependency-annotation/v)](https://packagist.org/packages/navarr/dependency-annotation) | ||
[![Total Downloads](http://poser.pugx.org/navarr/dependency-annotation/downloads)](https://packagist.org/packages/navarr/dependency-annotation) | ||
[![Latest Unstable Version](http://poser.pugx.org/navarr/dependency-annotation/v/unstable)](https://packagist.org/packages/navarr/dependency-annotation) | ||
[![License](http://poser.pugx.org/navarr/dependency-annotation/license)](https://packagist.org/packages/navarr/dependency-annotation) | ||
![Tests](https://github.com/navarr/dependency-annotation/actions/workflows/commit.yml/badge.svg) | ||
![Code Coverage](https://codecov.io/gh/navarr/dependency-annotation/branch/main/graph/badge.svg?token=BHTKOZZDR3) | ||
|
||
This project supplies a Composer plugin that adds a command (`why-block`) that interprets the PHP `@dependency` | ||
annotation. | ||
This project supplies a Composer plugin that adds a command (`why-block`) that interprets a PHP `#[Dependency]` | ||
attribute. | ||
|
||
## How to use the `@dependency` annotation | ||
## How to use the `#[Dependency]` annotation | ||
|
||
Simply include a `@dependency` annotation in any slash-based comment block, in the following format: | ||
Simply include a `#[Dependency]` attribute on any attributable target in the following format: | ||
|
||
@dependency composer-package:version-constraint [Explanation] | ||
#[Navarr\Depends\Annotation\Dependency('package', 'versionConstraint', 'reason')] | ||
|
||
All fields except the explanation are mandatory. Adding an explanation is _highly recommended_, however. | ||
This FQN may be imported, in which case you can simply use `#[Dependency(...)]` | ||
|
||
The version-constraint field cannot contain spaces (even if surrounded by quotes). | ||
All fields except the explanation are mandatory. Adding an explanation is _highly recommended_, however. | ||
|
||
## How to process reasons not to upgrade a composer dependency | ||
|
||
If you are using the `@dependency` annotation thoroughly, and you are having issues updating a composer dependency, you | ||
If you are using the `#[Dependency]` annotation thoroughly, and you are having issues updating a composer dependency, you | ||
can use the command `composer why-block composer-package version` | ||
|
||
This will output a list of files containing a `@dependency` annotation on composer-package with a version-constraint | ||
that cannot be fulfilled by your specified version. | ||
This will output a list of files containing a `#[Dependency]` annotation on composer-package with a version-constraint | ||
that cannot be fulfilled by the specified version. | ||
|
||
## How to install | ||
|
||
`composer global require navarr/dependency-annotation` | ||
|
||
## Compatibility with v1 | ||
|
||
For speed, version 2 automatically excludes the legacy `@dependency` annotation in favor of the PHP8 `#[Dependency]` | ||
attribute. While transitioning, you may specify the `-l` or `--include-legacy-annotations` flag to the `why-block` | ||
command to force it to process v1 annotations as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"source": { | ||
"directories": [ | ||
"src" | ||
] | ||
}, | ||
"phpUnit": { | ||
"configDir": "." | ||
}, | ||
"mutators": { | ||
"@default": true, | ||
"ConcatOperandRemoval": { | ||
"ignore": [ | ||
"Navarr\\Depends\\Parser\\AstParser::parse::82", | ||
"Navarr\\Depends\\Parser\\AstParser::parse::83" | ||
] | ||
}, | ||
"Concat": { | ||
"ignore": [ | ||
"Navarr\\Depends\\Parser\\AstParser::parse::82", | ||
"Navarr\\Depends\\Parser\\AstParser::parse::83" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
<rule ref="PSR12"/> | ||
<file>src</file> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
parameters: | ||
level: 8 | ||
paths: | ||
- src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<testsuite name="unit"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
<coverage cacheDirectory="/tmp"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
<exclude> | ||
<directory suffix=".php">src/polyfills</directory> | ||
<file>src/Proxy/MimeDeterminer.php</file> | ||
</exclude> | ||
</coverage> | ||
</phpunit> |
Oops, something went wrong.