Skip to content

Commit 4b3ea55

Browse files
committed
Add E2E test for phpstan/phpstan#14093
The bug only manifests when the `sys_temp_dir` path starts with an alphanumeric character (like a drive letter on Windows, or a relative folder name on Linux).
1 parent ccc0745 commit 4b3ea55

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,17 @@ jobs:
451451
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv test.php 2>&1)
452452
echo "$OUTPUT"
453453
../bashunit -a contains 'Parallel processing scheduler' "$OUTPUT"
454+
- script: |
455+
cd e2e/bug-14093
456+
# Use a relative sys_temp_dir so the value starts with a letter (not /), just like Windows
457+
# paths starting with a drive letter. If the sys_temp_dir value isn't correctly quoted,
458+
# PHP evaluates ~ as a bitwise NOT rather than a literal character, truncating the path.
459+
mkdir tmp~1
460+
php -d "sys_temp_dir='tmp~1'" ../../bin/phpstan analyze
461+
if [ -d tmp ]; then
462+
echo "FAIL: tmp was created by a worker, meaning sys_temp_dir='tmp~1' was incorrectly evaluated to 'tmp'"
463+
exit 1
464+
fi
454465
455466
steps:
456467
- name: Harden the runner (Audit all outbound calls)

e2e/bug-14093/phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- test.php

e2e/bug-14093/test.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
function add(int $a, int $b): int
4+
{
5+
return $a + $b;
6+
}

0 commit comments

Comments
 (0)