Skip to content

Commit

Permalink
Avoid php8 only syntax when possible
Browse files Browse the repository at this point in the history
This resulted in phpstan to fail if the active PHP version is <8.0:
Internal error: syntax error, unexpected 'static' (T_STATIC)

In case a project depending on api-platform/core would use ClientTrait directly,
or indirectly, phpstan would try to parse it and fail with the above syntax error.

Move the type declarations into a comment instead.

Fixes api-platform#4614
  • Loading branch information
lazka committed Jan 17, 2022
1 parent ff3aab5 commit a5e66e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Util/ClientTrait80.php
Expand Up @@ -15,7 +15,10 @@

trait ClientTrait80
{
public function withOptions(array $options): static
/**
* @return static
*/
public function withOptions(array $options)
{
$clone = clone $this;
$clone->defaultOptions = self::mergeDefaultOptions($options, $this->defaultOptions);
Expand Down
5 changes: 4 additions & 1 deletion src/Util/ResponseTrait80.php
Expand Up @@ -15,7 +15,10 @@

trait ResponseTrait80
{
public function getInfo(?string $type = null): mixed
/**
* @return mixed
*/
public function getInfo(?string $type = null)
{
if ($type) {
return $this->info[$type] ?? null;
Expand Down

0 comments on commit a5e66e5

Please sign in to comment.