Skip to content

Commit

Permalink
Update for Symfony 7 (#186)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrik Foldes <[email protected]>
  • Loading branch information
sspat and Patrik Foldes authored May 21, 2024
1 parent 75a4422 commit 5511ee6
Show file tree
Hide file tree
Showing 85 changed files with 295 additions and 545 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
- "ubuntu-latest"
- "windows-latest"
php-version:
- "8.0"
- "8.1"
- "8.2"
dependencies:
- "lowest"
- "highest"
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down
56 changes: 28 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,42 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"cebe/php-openapi": "^1.7",
"league/openapi-psr7-validator": "^0.18.0",
"lukasoppermann/http-status": "^3.2",
"nikic/php-parser": "^4.13",
"league/openapi-psr7-validator": "^0.22.0",
"lukasoppermann/http-status": "^4.0",
"nikic/php-parser": "^4.19",
"nyholm/psr7": "^1.5",
"phpdocumentor/reflection-docblock": "^5.3",
"sspat/reserved-words": "^3.0",
"symfony/cache": "^6.0",
"symfony/cache-contracts": "^3",
"symfony/config": "^6.0",
"symfony/console": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/event-dispatcher": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/psr-http-message-bridge": "^2.1",
"symfony/routing": "^6.0",
"symfony/yaml": "^6.0",
"symfony/cache": "^6.4|^7.0",
"symfony/cache-contracts": "^3.5",
"symfony/config": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/psr-http-message-bridge": "^6.4|^7.0",
"symfony/routing": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0",
"thecodingmachine/safe": "^1.3|^2"
},
"require-dev": {
"doctrine/coding-standard": "^9.0",
"matthiasnoback/symfony-config-test": "^4.3",
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.18",
"squizlabs/php_codesniffer": "^3.6",
"symfony/browser-kit": "^6.0",
"symfony/dom-crawler": "^6.0",
"symfony/framework-bundle": "^6.0",
"doctrine/coding-standard": "^12.0",
"matthiasnoback/symfony-config-test": "^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^10.5",
"roave/infection-static-analysis-plugin": "^1.35",
"squizlabs/php_codesniffer": "^3.10",
"symfony/browser-kit": "^6.4|^7.0",
"symfony/dom-crawler": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"thecodingmachine/phpstan-safe-rule": "^1.2",
"vimeo/psalm": "^4.22"
"vimeo/psalm": "^5.24"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down Expand Up @@ -90,7 +90,7 @@
"psalm": "psalm",
"stan": "phpstan analyse --memory-limit=-1 --xdebug",
"tests": "phpunit --fail-on-warning",
"mutation": "vendor/bin/roave-infection-static-analysis-plugin --only-covered --test-framework-options=\"--testsuite=unit\"",
"mutation": "php -d memory_limit=-1 vendor/bin/roave-infection-static-analysis-plugin --only-covered --test-framework-options=\"--testsuite=unit\"",
"all": "composer psalm && composer stan && composer tests && composer mutation && composer cs && composer security",
"get-security": "rm -f local-php-security-checker && curl -s https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest | grep -E \"browser_download_url(.+)linux_amd64\" | cut -d : -f 2,3 | tr -d \\\" | xargs -I % curl % -L -o local-php-security-checker && chmod +x local-php-security-checker",
"security": "./local-php-security-checker"
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ parameters:
paths:
- src
# - test
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
excludePaths:
- 'src/DependencyInjection/Configuration.php'
Expand All @@ -27,6 +26,10 @@ parameters:
message: '#OnMoon\\OpenApiServerBundle\\Router\\RouteLoader::__construct\(\) does not call parent constructor from Symfony\\Component\\Config\\Loader\\Loader\.#'
paths:
- %currentWorkingDirectory%/src/Router/RouteLoader.php
-
message: '#Method OnMoon\\OpenApiServerBundle\\Specification\\SpecificationParser::getResponseDtoDefinitions\(\) has parameter \$responses with no value type specified in iterable type array\.#'
paths:
- %currentWorkingDirectory%/src/Specification/SpecificationParser.php
includes:
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
Expand Down
49 changes: 22 additions & 27 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="unit">
<directory>./test/unit</directory>
</testsuite>
<testsuite name="functional">
<directory>./test/functional</directory>
</testsuite>
<testsuite name="generation">
<directory>./test/generation</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="E_ALL"/>
<env name="APP_ENV" value="test" />
<env name="APP_DEBUG" value="false" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="unit">
<directory>./test/unit</directory>
</testsuite>
<testsuite name="functional">
<directory>./test/functional</directory>
</testsuite>
<testsuite name="generation">
<directory>./test/generation</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="E_ALL"/>
<env name="APP_ENV" value="test"/>
<env name="APP_DEBUG" value="false"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
strictBinaryOperands="true"
findUnusedVariablesAndParams="true"
ensureArrayStringOffsetsExist="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
phpVersion="8.1"
>
<projectFiles>
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/Definitions/DtoDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class DtoDefinition extends GeneratedClassDefinition implements DtoReference
private array $properties;
private ?ClassReference $implements;

/**
* @param PropertyDefinition[] $properties
*/
/** @param PropertyDefinition[] $properties */
public function __construct(array $properties)
{
$this->implements = ClassDefinition::fromFQCN(Dto::class);
Expand All @@ -28,9 +26,7 @@ final public function isEmpty(): bool
return count($this->properties) === 0;
}

/**
* @return PropertyDefinition[]
*/
/** @return PropertyDefinition[] */
final public function getProperties(): array
{
return $this->properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ final public function getExtends(): ?ClassReference
return $this->extends;
}

/**
* @return GeneratedInterfaceDefinition
*/
/** @return GeneratedInterfaceDefinition */
final public function setExtends(?ClassReference $extends): self
{
$this->extends = $extends;
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/Definitions/GraphDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@ final class GraphDefinition
private array $specifications;
private ServiceSubscriberDefinition $serviceSubscriber;

/**
* @param SpecificationDefinition[] $specifications
*/
/** @param SpecificationDefinition[] $specifications */
public function __construct(array $specifications, ServiceSubscriberDefinition $serviceSubscriber)
{
$this->specifications = $specifications;
$this->serviceSubscriber = $serviceSubscriber;
}

/**
* @return SpecificationDefinition[]
*/
/** @return SpecificationDefinition[] */
public function getSpecifications(): array
{
return $this->specifications;
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/Definitions/OperationDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

final class OperationDefinition
{
/**
* @param ResponseDefinition[] $responses
*/
/** @param ResponseDefinition[] $responses */
public function __construct(
private string $url,
private string $method,
Expand Down Expand Up @@ -52,9 +50,7 @@ public function getRequest(): ?DtoReference
return $this->request;
}

/**
* @return ResponseDefinition[]
*/
/** @return ResponseDefinition[] */
public function getResponses(): array
{
return $this->responses;
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/Definitions/ServiceSubscriberDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ public function __construct()
$this->implements = [ClassDefinition::fromFQCN(ApiLoader::class)];
}

/**
* @return ClassReference[]
*/
/** @return ClassReference[] */
public function getImplements(): array
{
return $this->implements;
}

/**
* @param ClassReference[] $implements
*/
/** @param ClassReference[] $implements */
public function setImplements(array $implements): self
{
$this->implements = $implements;
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/Definitions/SpecificationDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public function __construct(private SpecificationConfig $specification, private
{
}

/**
* @return OperationDefinition[]
*/
/** @return OperationDefinition[] */
public function getOperations(): array
{
return $this->operations;
Expand All @@ -29,9 +27,7 @@ public function getSpecification(): SpecificationConfig
return $this->specification;
}

/**
* @return ComponentDefinition[]
*/
/** @return ComponentDefinition[] */
public function getComponents(): array
{
return $this->components;
Expand Down
8 changes: 2 additions & 6 deletions src/CodeGenerator/FileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public function __construct(
$this->serviceSubscriberGenerator = $serviceSubscriberGenerator;
}

/**
* @return GeneratedFileDefinition[]
*/
/** @return GeneratedFileDefinition[] */
public function generateAllFiles(GraphDefinition $graph): array
{
/** @var GeneratedFileDefinition[] $result */
Expand All @@ -58,9 +56,7 @@ public function generateAllFiles(GraphDefinition $graph): array
return $result;
}

/**
* @return GeneratedFileDefinition[]
*/
/** @return GeneratedFileDefinition[] */
public function generateDtoTree(?DtoReference $root): array
{
if (! $root instanceof DtoDefinition) {
Expand Down
4 changes: 1 addition & 3 deletions src/CodeGenerator/Naming/NamingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

interface NamingStrategy
{
/**
* @psalm-return class-string<RequestHandler>
*/
/** @psalm-return class-string<RequestHandler> */
public function getInterfaceFQCN(string $apiNameSpace, string $operationId): string;

public function stringToNamespace(string $text): string;
Expand Down
Loading

0 comments on commit 5511ee6

Please sign in to comment.