Phpinspectionsea: [Feature Request] Add an inspection to warn for unnecessary type checks

Created on 8 Oct 2018  路  3Comments  路  Source: kalessil/phpinspectionsea

| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Issue type | Feature Request |
| Plugin | Php Inspections (EA Extended), 3.0.6.1 |
| Language level | PHP 7.2 |

Current behaviour:

This is a feature request, thus the whole check is missing right now.

Expected behaviour:

Please have a look at the following code:

<?php

declare(strict_types=1);

function foo(string $input): string
{
    if (is_string($input)) {
        return 'Input is a string';
    }
    return 'Input is not a string.';
}

I'd expect an inspection that warns that the type check in this case is not required, as strict_types=1 is set and the input param is already declared that it has to be a string. Same is true with many other functions like is_int(), is_float(), is_array(), etc.

duplicate

Most helpful comment

It's a great tool that deserves more support! Thank you again for creating the tool.

All 3 comments

Sorry, the suggestion is already implemented in "EA Ultimate": "Callable parameter usage violates definition".

So, you discovered ultimate, congrats and thank you for supporting via Patreon =) The license is coming today (~evening).

It's a great tool that deserves more support! Thank you again for creating the tool.

Was this page helpful?
0 / 5 - 0 ratings