Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix symfony/error-handler deprecations #105

Closed
wants to merge 1 commit into from

Conversation

andrew-demb
Copy link

Q A
Documentation no
Bugfix yes (?)
BC Break no
New Feature no
RFC no
QA no

Description

symfony/error-handler triggers deprecation errors in case of not (explicitly) specified return types when implemented interface have them declared (in phpdoc).
AFAIK they are triggered to make libraries migration to (possible) future declared return types more explicit.

It can be annoying to update all of libraries with such of changes, but these deprecation messages are pretty hard to silence :(

Here's log of there errors:

PHP Deprecated: Method "Psr\Http\Message\ServerRequestInterface::getParsedBody()" might add "array|object|null" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330
PHP Deprecated: Method "Psr\Http\Message\ServerRequestInterface::getAttribute()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330
PHP Deprecated: Method "Psr\Http\Message\StreamInterface::getMetadata()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\Stream" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330

…tly specified return types

```
PHP Deprecated: Method "Psr\Http\Message\ServerRequestInterface::getParsedBody()" might add "array|object|null" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330
PHP Deprecated: Method "Psr\Http\Message\ServerRequestInterface::getAttribute()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\ServerRequest" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330
PHP Deprecated: Method "Psr\Http\Message\StreamInterface::getMetadata()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Laminas\Diactoros\Stream" now to avoid errors or add an explicit @return annotation to suppress this message. in .../vendor/symfony/error-handler/DebugClassLoader.php on line 330
```

Signed-off-by: Andrii Dembitskyi <andrew.dembitskiy@gmail.com>
@Ocramius
Copy link
Member

Ocramius commented Jul 6, 2022

Honestly, type improvements are welcome, but these are just messed up symfony issues.

@andrew-demb
Copy link
Author

Psalm fails the build because it cannot to read parameter type from interface, when there are phpdoc combines @inheritdoc and additional @return tag.

Error: src/ServerRequest.php:205:34: MissingParamType: Parameter $attribute has no provided type (see https://psalm.dev/154)
Error: src/ServerRequest.php:205:46: MissingParamType: Parameter $default has no provided type (see https://psalm.dev/154)

@andrew-demb
Copy link
Author

andrew-demb commented Jul 6, 2022

Honestly, type improvements are welcome, but these are just messed up symfony issues.

Unfortunately I can't make types more precise for methods like \Laminas\Diactoros\ServerRequest::getAttribute [1].

Let's close then, we will try to hide errors from Symfony.

[1]

/**
* {@inheritdoc}
*/
public function getAttribute($attribute, $default = null)
{
if (! array_key_exists($attribute, $this->attributes)) {
return $default;
}
return $this->attributes[$attribute];
}

@andrew-demb andrew-demb closed this Jul 6, 2022
@andrew-demb andrew-demb deleted the symfony-deprecations branch July 6, 2022 19:37
@Ocramius
Copy link
Member

Ocramius commented Jul 6, 2022

My endorsement is to disable symfony/error-handler overall: it is a noxious component that effectively hooks in everything, worsening both runtime and developer experience.

The types refined in this particular patch were already precise enough in the interfaces declared by PSR-7, so IMO something else is happening.

Regardless of that, we are already working on improving types in #104 and #103.

Adding @return mixed on something where {@inheritDoc} already exists is really not improving on the situation, since mixed has little to no added value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants