Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/e2e-tests.yml
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
Comment on lines +27 to +31

@staabm staabm Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

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


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 warning

Code 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 notice

Code 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.
Comment thread
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 notice

Code 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.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

- name: "Install bashunit"
uses: "TypedDevs/bashunit@ffa9c79e71ecbb9990e777348bc9ba12314b62d0" # 0.39.1

Check notice

Code 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.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
with:
directory: "e2e"

- name: "Test"
run: ${{ matrix.script }}
2 changes: 2 additions & 0 deletions e2e/bug-208/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor
composer.lock
13 changes: 13 additions & 0 deletions e2e/bug-208/composer.json
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": "../../"
}
]
}
8 changes: 8 additions & 0 deletions e2e/bug-208/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- ../../extension.neon
- ../../rules.neon

parameters:
level: 8
paths:
- src
18 changes: 18 additions & 0 deletions e2e/bug-208/src/foo.php
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';
}
}
2 changes: 1 addition & 1 deletion src/Type/Nette/StringsLengthTypeSpecifiyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function specifyTypes(MethodReflection $staticMethodReflection, StaticCal
new IntersectionType([new StringType(), new AccessoryNonEmptyStringType()]),
$context,
$scope,
);
)->setRootExpr($node);
}

}
Loading