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

Problem with Consistence.Exceptions.ExceptionDeclaration #47

Open
lookyman opened this issue Jul 30, 2018 · 3 comments
Open

Problem with Consistence.Exceptions.ExceptionDeclaration #47

lookyman opened this issue Jul 30, 2018 · 3 comments

Comments

@lookyman
Copy link

use Throwable;

class InvalidResponseException extends Exception
{
    public function __construct(Validator $validator, ?Throwable $previous = null)
    {
        // ...
    }

This reports Exception is not chainable. It must have optional \Throwable as last constructor argument and has "Throwable".

@VasekPurchart
Copy link
Member

Is this the whole class? As in there is no namespace? (I see no PHP open tag and Exception is not used while Throwable is, so it seems pretty suspicious to me).

@lookyman
Copy link
Author

Nope, of course it's not a whole class 😊 It's just an excerpt to show the issue. The problem seems to be here.

@miroslavhajek
Copy link

This problem is not fixed in https://github.com/consistence-community/coding-standard/pull/3/files - condition accepts only FCQN.

Use

if (
    !in_array($lastArgument->getTypeHint(), ['\Throwable', '?\Throwable', 'Throwable', '?Throwable'], true)
    && !StringHelper::endsWith($lastArgument->getTypeHint(), 'Exception')
    && !StringHelper::endsWith($lastArgument->getTypeHint(), 'Error')
)

instead of line 119 where was added: $lastArgument->getTypeHint() !== '?\Throwable'

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

No branches or pull requests

3 participants