Skip to content

Possible improvements to --show-deprecated #126

Open
@stronk7

Description

@stronk7

Disclaimer: I've not looked how the --show-deprecated option works internally, and maybe the idea below is not achievable at all.

While using the --show-deprecated option with PHP 8.1 against some large codebase, I was surprised that only a few cases were detected, when that version comes to lots of classes now requiring correct return type-hinting.

So, for example, this file / class:

<?php

class my_ite implements Iterator {
    public function current() {
        return 1;
    }
    public function key() {
        return 1;
    }
    public function next() {
        // do something.
    }
    public function rewind() {
        // do something.
    }
    public function valid() {
        return true;
    }
}

Does, in fact, miss a lot of return types (or #[ReturnTypeWillChange] attributes). See https://3v4l.org/bPN2V

But, parallel-lint does not detect them at all:

$ vendor/bin/parallel-lint --show-deprecated test.php 
PHP 8.1.9 | 10 parallel jobs
.                                                            1/1 (100 %)


Checked 1 files in 0.5 seconds
No syntax error found

(note, neither php -l test.php does)

So, I was guessing if, maybe, when the file (class) being linted does not have unknown dependencies (errors)... it would be possible to, effectively, try to run the file and get all those deprecation messages that aren't shown normally.

Again, surely this is a non-sense and crazy idea, I just discovered that my hypothetical (only, I was happy) 12 deprecation cases detected by --show-deprecated... they are going to be, in reality, some good hundred, heh.

Still I'm not sure to understand why some are detected (for example php_user_filter::filter($in, $out, &$consumed, bool $closing): int was perfectly detected and others (like Iterator::valid() : bool) aren't, unless you effectively "run" the file.

And that's the story and the (crazy) idea, thanks for the tool, it's really useful!

Ciao :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions