Skip to content

Expand 'read_type_annotations' to allow an array of files to enable / block the functionality on and an array of tags to allow/block #5248

@DeveloperRob

Description

@DeveloperRob

Is your feature request related to a problem? Please describe.
In one of our projects, we use the facebook-php-business-sdk. They have added the @deprecated flag to a fairly core constructor to indicate that a certain usage of it (passing the second argument) is deprecated. The problem we have is that Phan then warns that every call to the function is a call to a deprecated function.

Describe the solution you'd like
The ideal solution here would be that you can pass true / false to read_type_annotations as normal, but you can also pass (for instance):

[
    "return" => false,
    "default" => true,
] // To enable all tags except @return
[
    "param" =>  true,
    "default" => false,
] // To disable all tags except @return
[
    "files" => [
        "vendor\facebook\php-business-sdk\src\FacebookAds\Object\AbstractCrudObject.php" => [
            "deprecated": false,
            "default": true,
    ],
    "default": true,
] // To enable all tags everywhere except @deprecated in 'AbstractCrudObject.php'

This would allow the deprecation of read_magic_method_annotations, read_magic_property_annotations & read_mixin_annotations, allowing a single argument to give much greater control over PHPDoc tag reading.

Describe alternatives you've considered
Currently we have a stub file but we have ran into a few issues where we add new functionality and then get false positives as the stub file doesn't reflect the real file. I also intend to raise a ticket with Facebook as well, as I don't consider their use of @deprecated correct (given the entire function isn't deprecated).

Additional context
I am aware this is likely a fair amount of work, and may have a bigger performance impact compared to the benefits it would bring. If the opinion of more experienced developers working on the project don't think the performance impact would be an issue then I am happy to try and work on an initial PR for the functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis improves the quality of Phan's analysis of a codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions