Skip to content

Commit

Permalink
Add symfony 5 compatibility (#71)
Browse files Browse the repository at this point in the history
* Updated dev packages

* Updated code style

* Updated symfony packages to ^5.0

* Fixed psalm type issue

* Ignored phpstan false positive and removed fix for it

* Removed another unnecessary check
  • Loading branch information
sspat authored Jul 3, 2020
1 parent 4e31f35 commit 5b89f8a
Show file tree
Hide file tree
Showing 67 changed files with 345 additions and 302 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
include:
- stage: Psalm
php: 7.4
script: ./vendor/bin/psalm
script: ./vendor/bin/psalm.phar

- stage: Stan
php: 7.4
Expand All @@ -39,4 +39,4 @@ jobs:
- composer show squizlabs/php_codesniffer
- composer show doctrine/coding-standard
- composer show slevomat/coding-standard
- ./vendor/bin/phpcs
- ./vendor/bin/phpcs
40 changes: 20 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@
"require": {
"php": "^7.4",
"ext-json": "*",
"cebe/php-openapi": "^1.3",
"league/openapi-psr7-validator": "^0.6.0",
"cebe/php-openapi": "^1.4",
"league/openapi-psr7-validator": "^0.9.0",
"lukasoppermann/http-status": "^2.0",
"nikic/php-parser": "^4.3",
"nyholm/psr7": "^1.2",
"phpdocumentor/reflection-docblock": "^4.3",
"nikic/php-parser": "^4.5",
"nyholm/psr7": "^1.3",
"phpdocumentor/reflection-docblock": "^5.1",
"sspat/reserved-words": "^1.0",
"symfony/cache": "^4.4",
"symfony/config": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dependency-injection": "4.4.*",
"symfony/event-dispatcher": "4.4.*",
"symfony/http-kernel": "4.4.*",
"symfony/process": "^4.4",
"symfony/cache": "^5.0",
"symfony/config": "^5.0",
"symfony/console": "^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/event-dispatcher": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/process": "^5.0",
"symfony/psr-http-message-bridge": "^2.0",
"symfony/routing": "4.4.*",
"symfony/yaml": "4.4.*",
"symfony/routing": "^5.0",
"symfony/yaml": "^5.0",
"thecodingmachine/safe": "^1.0"
},
"require-dev": {
"doctrine/coding-standard": "^7.0",
"phpstan/phpstan": "^0.12.8",
"phpunit/phpunit": "^8.5",
"doctrine/coding-standard": "^8.0",
"phpstan/phpstan": "^0.12.32",
"phpunit/phpunit": "^9.2",
"psalm/phar": "^3.12",
"sensiolabs/security-checker": "^6.0",
"squizlabs/php_codesniffer": "^3.5",
"thecodingmachine/phpstan-safe-rule": "^1.0",
"vimeo/psalm": "^3.8"
"thecodingmachine/phpstan-safe-rule": "^1.0"
},
"minimum-stability": "stable",
"config": {
Expand All @@ -72,7 +72,7 @@
"scripts": {
"cs": "phpcs",
"csfix": "phpcbf",
"psalm": "psalm",
"psalm": "psalm.phar",
"stan": "phpstan analyze src -l 8 --memory-limit=512m",
"sec": "security-checker security:check",
"test": "phpunit",
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/ApiServerCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(GraphGenerator $graphGenerator, NameGenerator $nameG
$this->eventDispatcher = $eventDispatcher;
}

public function generate() : void
public function generate(): void
{
$graph = $this->graphGenerator->generateClassGraph();
$this->interfaceGenerator->setAllInterfaces($graph);
Expand Down
6 changes: 3 additions & 3 deletions src/CodeGenerator/AttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class AttributeGenerator
{
public function setAllAttributes(GraphDefinition $graph) : void
public function setAllAttributes(GraphDefinition $graph): void
{
foreach ($graph->getSpecifications() as $specificationDefinition) {
foreach ($specificationDefinition->getOperations() as $operation) {
Expand All @@ -25,7 +25,7 @@ public function setAllAttributes(GraphDefinition $graph) : void
}
}

public function requestPass(DtoDefinition $root) : void
public function requestPass(DtoDefinition $root): void
{
foreach ($root->getProperties() as $property) {
$specProperty = $property->getSpecProperty();
Expand All @@ -45,7 +45,7 @@ public function requestPass(DtoDefinition $root) : void
}
}

public function responsePass(DtoDefinition $root) : void
public function responsePass(DtoDefinition $root): void
{
foreach ($root->getProperties() as $property) {
$specProperty = $property->getSpecProperty();
Expand Down
12 changes: 6 additions & 6 deletions src/CodeGenerator/Definitions/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ class ClassDefinition
private string $className;
private string $namespace;

public function getClassName() : string
public function getClassName(): string
{
return $this->className;
}

public function setClassName(string $className) : self
public function setClassName(string $className): self
{
$this->className = $className;

return $this;
}

public function getNamespace() : string
public function getNamespace(): string
{
return $this->namespace;
}

public function setNamespace(string $namespace) : self
public function setNamespace(string $namespace): self
{
$this->namespace = $namespace;

return $this;
}

public function getFQCN() : string
public function getFQCN(): string
{
return $this->namespace . '\\' . $this->className;
}

public static function fromFQCN(string $className) : ClassDefinition
public static function fromFQCN(string $className): ClassDefinition
{
$lastPart = strrpos($className, '\\');
if ($lastPart !== false) {
Expand Down
8 changes: 4 additions & 4 deletions src/CodeGenerator/Definitions/DtoDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ public function __construct(array $properties)
$this->properties = $properties;
}

public function isEmpty() : bool
public function isEmpty(): bool
{
return count($this->properties) === 0;
}

/**
* @return PropertyDefinition[]
*/
public function getProperties() : array
public function getProperties(): array
{
return $this->properties;
}

public function getImplements() : ?ClassDefinition
public function getImplements(): ?ClassDefinition
{
return $this->implements;
}

/**
* @return DtoDefinition
*/
public function setImplements(?ClassDefinition $implements) : self
public function setImplements(?ClassDefinition $implements): self
{
$this->implements = $implements;

Expand Down
8 changes: 4 additions & 4 deletions src/CodeGenerator/Definitions/GeneratedClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ class GeneratedClassDefinition extends ClassDefinition
private string $fileName;
private string $filePath;

public function getFileName() : string
public function getFileName(): string
{
return $this->fileName;
}

public function setFileName(string $fileName) : self
public function setFileName(string $fileName): self
{
$this->fileName = $fileName;

return $this;
}

public function getFilePath() : string
public function getFilePath(): string
{
return $this->filePath;
}

public function setFilePath(string $filePath) : self
public function setFilePath(string $filePath): self
{
$this->filePath = $filePath;

Expand Down
6 changes: 3 additions & 3 deletions src/CodeGenerator/Definitions/GeneratedFileDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public function __construct(GeneratedClassDefinition $class, string $fileContent
$this->fileContents = $fileContents;
}

public function getClass() : GeneratedClassDefinition
public function getClass(): GeneratedClassDefinition
{
return $this->class;
}

public function getFileContents() : string
public function getFileContents(): string
{
return $this->fileContents;
}

public function setFileContents(string $fileContents) : self
public function setFileContents(string $fileContents): self
{
$this->fileContents = $fileContents;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class GeneratedInterfaceDefinition extends GeneratedClassDefinition
{
private ?ClassDefinition $extends = null;

public function getExtends() : ?ClassDefinition
public function getExtends(): ?ClassDefinition
{
return $this->extends;
}

/**
* @return GeneratedInterfaceDefinition
*/
public function setExtends(?ClassDefinition $extends) : self
public function setExtends(?ClassDefinition $extends): self
{
$this->extends = $extends;

Expand Down
4 changes: 2 additions & 2 deletions src/CodeGenerator/Definitions/GraphDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function __construct(array $specifications, ServiceSubscriberDefinition $
/**
* @return SpecificationDefinition[]
*/
public function getSpecifications() : array
public function getSpecifications(): array
{
return $this->specifications;
}

public function getServiceSubscriber() : ServiceSubscriberDefinition
public function getServiceSubscriber(): ServiceSubscriberDefinition
{
return $this->serviceSubscriber;
}
Expand Down
22 changes: 11 additions & 11 deletions src/CodeGenerator/Definitions/OperationDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,62 +32,62 @@ public function __construct(string $url, string $method, string $operationId, st
$this->responses = $responses;
}

public function getUrl() : string
public function getUrl(): string
{
return $this->url;
}

public function getMethod() : string
public function getMethod(): string
{
return $this->method;
}

public function getOperationId() : string
public function getOperationId(): string
{
return $this->operationId;
}

public function getRequestHandlerName() : string
public function getRequestHandlerName(): string
{
return $this->requestHandlerName;
}

public function getSummary() : ?string
public function getSummary(): ?string
{
return $this->summary;
}

public function getRequest() : ?RequestDtoDefinition
public function getRequest(): ?RequestDtoDefinition
{
return $this->request;
}

/**
* @return ResponseDtoDefinition[]
*/
public function getResponses() : array
public function getResponses(): array
{
return $this->responses;
}

public function getMarkersInterface() : ?ClassDefinition
public function getMarkersInterface(): ?ClassDefinition
{
return $this->markersInterface;
}

public function setMarkersInterface(?ClassDefinition $markersInterface) : self
public function setMarkersInterface(?ClassDefinition $markersInterface): self
{
$this->markersInterface = $markersInterface;

return $this;
}

public function getRequestHandlerInterface() : RequestHandlerInterfaceDefinition
public function getRequestHandlerInterface(): RequestHandlerInterfaceDefinition
{
return $this->requestHandlerInterface;
}

public function setRequestHandlerInterface(RequestHandlerInterfaceDefinition $requestHandlerInterface) : self
public function setRequestHandlerInterface(RequestHandlerInterfaceDefinition $requestHandlerInterface): self
{
$this->requestHandlerInterface = $requestHandlerInterface;

Expand Down
Loading

0 comments on commit 5b89f8a

Please sign in to comment.