-
Notifications
You must be signed in to change notification settings - Fork 44
Fix "False positive staticMethod.alreadyNarrowedType for Strings::length() inside numeric comparison" #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
de60355
d0990ea
09366f0
52193ac
6125f3a
9e66aa2
6258992
244009b
e9b26e0
7c519b4
d08853b
f571e6c
96f8daa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # https://help.github.com/en/categories/automating-your-workflow-with-github-actions | ||
|
|
||
| name: "E2E Tests" | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - "2.0.x" | ||
|
|
||
| concurrency: | ||
| group: e2e-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| e2e-tests: | ||
| name: "E2E tests" | ||
| runs-on: "ubuntu-latest" | ||
| timeout-minutes: 60 | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - script: | | ||
| cd e2e/bug-208 | ||
| composer install | ||
| vendor/bin/phpstan | ||
|
|
||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: "Checkout" | ||
Check warningCode scanning / zizmor credential persistence through GitHub Actions artifacts Warning
credential persistence through GitHub Actions artifacts
|
||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
Comment on lines
+39
to
+40
|
||
|
|
||
| - name: "Install PHP" | ||
| uses: "shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc" # v2.37.1 | ||
Check noticeCode scanning / poutine Github Action from Unverified Creator used Note
Usage of the following GitHub Actions repositories was detected in workflows
or composite actions, but their owner is not a verified creator. |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| with: | ||
| coverage: "none" | ||
| php-version: "8.3" | ||
|
|
||
| - uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0 | ||
Check noticeCode scanning / poutine Github Action from Unverified Creator used Note
Usage of the following GitHub Actions repositories was detected in workflows
or composite actions, but their owner is not a verified creator. |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
|
|
||
| - name: "Install bashunit" | ||
| uses: "TypedDevs/bashunit@ffa9c79e71ecbb9990e777348bc9ba12314b62d0" # 0.39.1 | ||
Check noticeCode scanning / poutine Github Action from Unverified Creator used Note
Usage of the following GitHub Actions repositories was detected in workflows
or composite actions, but their owner is not a verified creator. |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| with: | ||
| directory: "e2e" | ||
|
|
||
| - name: "Test" | ||
| run: ${{ matrix.script }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /vendor | ||
| composer.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "require-dev": { | ||
| "nette/utils": "^3.2.5", | ||
| "phpstan/phpstan-nette": "@dev", | ||
| "phpstan/phpstan": "@dev" | ||
| }, | ||
| "repositories": [ | ||
| { | ||
| "type": "path", | ||
| "url": "../../" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| includes: | ||
| - ../../extension.neon | ||
| - ../../rules.neon | ||
|
|
||
| parameters: | ||
| level: 8 | ||
| paths: | ||
| - src |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| use Nette\Utils\Strings; | ||
|
|
||
| function withoutPriorCheck(string $body): void | ||
| { | ||
| if (Strings::length($body) < 100) { // no error | ||
| echo 'a'; | ||
| } | ||
| } | ||
|
|
||
| function withPriorCheck(string $body): void | ||
| { | ||
| if ($body !== '' && Strings::length($body) < 100) { // false positive | ||
| echo 'a'; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a e2e suite, based on phpstan-src.
it was needed because the error beeing fixed is issued by a phpstan-core rule and it only happens with type inference extensions of phpstan-nette
the added tests reproduced the origin problem in https://github.com/phpstan/phpstan-nette/actions/runs/28579140883/job/84734877032?pr=210