Skip to content

preg_match greater than 0 #11293

Closed
Closed

Description

@ondrejmirtes

Bug report

All of these conditions should be understood the same way

/cc @staabm

Code snippet that reproduces the problem

https://phpstan.org/r/774080cc-2f73-49a5-a049-491d030ca831

Expected output

Same dumped type in all cases

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

  1. added this to the Easy fixes milestone on Jul 6, 2024
  2. phpstan-bot commented on Jul 6, 2024

    @phpstan-bot
    Contributor

    @ondrejmirtes After the latest push in 1.12.x, PHPStan now reports different result with your code snippet:

    @@ @@
    - 8: Dumped type: array{0?: string, 1?: string}
    -15: Dumped type: array{string, string}
    -22: Dumped type: array{0?: string, 1?: string}
    -32: Dumped type: array{0?: string, 1?: string}
    -41: Dumped type: array{0?: string, 1?: string}
    + 8: Dumped type: array<string>
    +15: Dumped type: array<string>
    +22: Dumped type: array<string>
    +32: Dumped type: array<string>
    +41: Dumped type: array<string>
    Full report
    Line Error
    8 Dumped type: array<string>
    15 Dumped type: array<string>
    22 Dumped type: array<string>
    32 Dumped type: array<string>
    41 Dumped type: array<string>
  3. deleted a comment from phpstan-bot on Jul 19, 2024
  4. deleted a comment from phpstan-bot on Jul 19, 2024
  5. phpstan-bot commented on Jul 19, 2024

    @phpstan-bot
    Contributor

    @ondrejmirtes After the latest push in 1.12.x, PHPStan now reports different result with your code snippet:

    @@ @@
    - 8: Dumped type: array{0?: string, 1?: string}
    -15: Dumped type: array{string, string}
    -22: Dumped type: array{0?: string, 1?: string}
    -32: Dumped type: array{0?: string, 1?: string}
    -41: Dumped type: array{0?: string, 1?: string}
    + 8: Dumped type: array{0?: string, 1?: numeric-string}
    +15: Dumped type: array{string, numeric-string}
    +22: Dumped type: array{0?: string, 1?: numeric-string}
    +32: Dumped type: array{0?: string, 1?: numeric-string}
    +41: Dumped type: array{0?: string, 1?: numeric-string}
    Full report
    Line Error
    8 Dumped type: array{0?: string, 1?: numeric-string}
    15 Dumped type: array{string, numeric-string}
    22 Dumped type: array{0?: string, 1?: numeric-string}
    32 Dumped type: array{0?: string, 1?: numeric-string}
    41 Dumped type: array{0?: string, 1?: numeric-string}
  6. phpstan-bot commented on Aug 5, 2024

    @phpstan-bot
    Contributor

    @ondrejmirtes After the latest push in 1.12.x, PHPStan now reports different result with your code snippet:

    @@ @@
    - 8: Dumped type: array{0?: string, 1?: string}
    -15: Dumped type: array{string, string}
    -22: Dumped type: array{0?: string, 1?: string}
    -32: Dumped type: array{0?: string, 1?: string}
    -41: Dumped type: array{0?: string, 1?: string}
    + 8: Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    +15: Dumped type: array{string, non-falsy-string&numeric-string}
    +22: Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    +32: Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    +41: Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    Full report
    Line Error
    8 Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    15 Dumped type: array{string, non-falsy-string&numeric-string}
    22 Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    32 Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
    41 Dumped type: array{0?: string, 1?: non-falsy-string&numeric-string}
  7. dktapps commented on Sep 3, 2024

    @dktapps
    Contributor

    Yep, ran into this problem in a bunch of places in PocketMine: https://github.com/pmmp/PocketMine-MP/actions/runs/10665106327/job/29557785290?pr=6441

  8. staabm commented on Sep 3, 2024

    @staabm
    Contributor

    another example combining int-cast and smaller-then (copied from #11262)

    https://phpstan.org/r/0d011355-4446-4bd8-9b8d-0c44907f9a07

  9. phpstan-bot commented on Sep 4, 2024

    @phpstan-bot
    Contributor

    @staabm After the latest push in 1.12.x, PHPStan now reports different result with your code snippet:

    @@ @@
    -17: Offset 'background_image' might not exist on array{0?: string, background_image?: string, 1?: string}.
    +17: Offset 'background_image' might not exist on array{0?: string, background_image?: non-empty-string, 1?: non-empty-string}.
    Full report
    Line Error
    17 Offset 'background_image' might not exist on array{0?: string, background_image?: non-empty-string, 1?: non-empty-string}.
  10. nicholasruunu commented on Oct 15, 2024

    @nicholasruunu

    Does this have to do with the issue I'm having?
    https://phpstan.org/r/4f406a70-f5f5-42ab-84ab-19c6c8f6549a

  11. ondrejmirtes commented on Oct 16, 2024

    @ondrejmirtes
    MemberAuthor

    @nicholasruunu Unrelated, please open a separate discussion.

  12. ondrejmirtes commented on Nov 8, 2024

    @ondrejmirtes
    MemberAuthor
  13. github-actions commented on Dec 10, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  14. locked as resolved and limited conversation to collaborators on Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions