Skip to content

Commit

Permalink
Remove legacy TokenAnalyser
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Jan 7, 2025
1 parent 31b0c0e commit 77d7215
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 1,054 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,3 @@ jobs:

- name: PHPUnit Tests
run: bin/phpunit --configuration phpunit.xml.dist --coverage-text

- name: PHPUnit Legacy Tests
run: bin/phpunit --configuration phpunit.xml.dist --coverage-text
env:
PHPUNIT_ANALYSER: 'legacy'
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ The `openapi` command line interface can be used to generate the documentation t
```shell
./vendor/bin/openapi --help
```
Starting with version 4 the default analyser used on the command line is the new `ReflectionAnalyser`.

Using the `--legacy` flag (`-l`) the legacy `TokenAnalyser` can still be used.

### Usage from the Deserializer

Expand Down
8 changes: 1 addition & 7 deletions bin/openapi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use OpenApi\Analysers\AttributeAnnotationFactory;
use OpenApi\Analysers\DocBlockAnnotationFactory;
use OpenApi\Analysers\ReflectionAnalyser;
use OpenApi\Analysers\TokenAnalyser;
use OpenApi\Annotations\OpenApi;
use OpenApi\Generator;
use OpenApi\Util;
Expand All @@ -23,7 +22,6 @@ error_reporting(E_ALL);
// Possible options and their default values.
$options = [
'config' => [],
'legacy' => false,
'output' => false,
'format' => 'auto',
'exclude' => [],
Expand All @@ -36,7 +34,6 @@ $options = [
];
$aliases = [
'c' => 'config',
'l' => 'legacy',
'o' => 'output',
'e' => 'exclude',
'n' => 'pattern',
Expand Down Expand Up @@ -132,7 +129,6 @@ Usage: openapi [--option value] [/path/to/project ...]
Options:
--config (-c) Generator config
ex: -c operationId.hash=false
--legacy (-l) Use legacy TokenAnalyser; default is the new ReflectionAnalyser
--output (-o) Path to store the generated documentation.
ex: --output openapi.yaml
--exclude (-e) Exclude path(s).
Expand Down Expand Up @@ -222,9 +218,7 @@ foreach ($options["processor"] as $processor) {
$generator->getProcessorPipeline()->add($processor);
}

$analyser = $options['legacy']
? new TokenAnalyser()
: new ReflectionAnalyser([new DocBlockAnnotationFactory(), new AttributeAnnotationFactory()]);
$analyser = new ReflectionAnalyser([new DocBlockAnnotationFactory(), new AttributeAnnotationFactory()]);

$openapi = $generator
->setVersion($options['version'])
Expand Down
9 changes: 1 addition & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
"cs": "Fix all codestyle issues",
"rector": "Automatic refactoring",
"lint": "Test codestyle",
"test": "Run all non-legacy and codestyle tests",
"testlegacy": "Run tests using the legacy TokenAnalyser",
"testall": "Run all tests (test + testlegacy)",
"test": "Run all PHP, codestyle and rector tests",
"analyse": "Run static analysis (phpstan/psalm)",
"spectral-examples": "Run spectral lint over all .yaml files in the Examples folder",
"spectral-scratch": "Run spectral lint over all .yaml files in the tests/Fixtures/Scratch folder",
Expand All @@ -108,11 +106,6 @@
"export XDEBUG_MODE=off && phpunit",
"@lint"
],
"testlegacy": "export XDEBUG_MODE=off && export PHPUNIT_ANALYSER=legacy && phpunit",
"testall": [
"@test",
"@testlegacy"
],
"analyse": [
"export XDEBUG_MODE=off && phpstan analyse --memory-limit=2G",
"export XDEBUG_MODE=off && psalm"
Expand Down
1 change: 0 additions & 1 deletion docs/guide/generating-openapi-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Usage: openapi [--option value] [/path/to/project ...]
Options:
--config (-c) Generator config
ex: -c operationId.hash=false
--legacy (-l) Use legacy TokenAnalyser; default is the new ReflectionAnalyser
--output (-o) Path to store the generated documentation.
ex: --output openapi.yaml
--exclude (-e) Exclude path(s).
Expand Down
1 change: 1 addition & 0 deletions docs/guide/under-the-hood.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- The `Generator` iterates over the given sources (Symfony `Finder`, file/directory list, etc)
- The configured analyser (`AnalyserInterface`) reads the files and builds an `Analysis` object.
Default (as of v4) is the `ReflectionAnalyser`. Alternatively, there is the `TokenAnalyser` which was the default in v3.
- The legacy `TokenAnalyser` was removed in v5.
- The `Analysis` object and its annotations are then processed by the configured processors.
- If enabled, the analysis/annotations are validated.
- The root `OpenApi` annotation then contains all annotations and is serialized into YAML/JSON.
Expand Down
3 changes: 0 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
->withSkip([
CombineIfRector::class,
ExplicitBoolCompareRector::class,
ExplicitReturnNullRector::class => [
__DIR__ . '/src/Analysers/TokenAnalyser.php',
],
ForRepeatedCountToOwnVariableRector::class,
RemoveAlwaysTrueIfConditionRector::class => [
__DIR__ . '/src/Processors/ExpandEnums.php',
Expand Down
Loading

0 comments on commit 77d7215

Please sign in to comment.