Skip to content

False negatives when denied call used in: first class callable, dynamic call, anonymous class, array callable, ... #275

Closed
@janedbal

Description

@janedbal

Hi, this package is very similar to our rule in shipmonk/phpstan-rules under forbidCustomFunctions

I was considering to switch to your package as it has far more features (and possibly phase-out our rule one day), but when I ran quick comparison of the behaviour of our packages, I found that phpstan-disallowed-calls is missing quite a few features, most notably it suffers from those false-negatives:

  • First class callables not detected
    • denied_function(...);
  • Dynamic calls not detected
    • $fn = 'denied_function'; $fn();
  • Anonymous classes not detected
    • new class extends ClassWithForbiddenConstructor {};
  • Callables not detected
    • array_map('denied_function', $array);
    • array_map([$class, 'forbiddenMethod'], $array);
  • See the MR for full diff, there are few other differences

Due to that, I'm sticking with our implementation for now, but if you ever consider implementing those, please let me know and I'll reconsider again :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions