Skip to content

Commit

Permalink
Test phpstan /w restricted php.ini conf
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jun 23, 2022
1 parent c5082a8 commit ecc5a05
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/other-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ jobs:
cd e2e/rector-autoload
composer install
../../phpstan
- |
cd e2e/restricted-php-ini
composer install
php -d open_basedir="$(cd ../.. && pwd):$(php -r 'echo sys_get_temp_dir();')" -d disable_functions="pcntl_exec,pcntl_fork,exec,passthru,proc_open,shell_exec,system,popen" -d auto_prepend_file=phpstan-preload.php ../../phpstan analyse -c app/phpstan.neon
include:
- php-version: 8.0
ini-values: memory_limit=256M
Expand Down
1 change: 1 addition & 0 deletions e2e/restricted-php-ini/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
13 changes: 13 additions & 0 deletions e2e/restricted-php-ini/app/A.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class A
{
public function foo(): void
{
}

public function bar(): void
{
var_dump($x);
}
}
13 changes: 13 additions & 0 deletions e2e/restricted-php-ini/app/B.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class B extends X
{
public function foo(): void
{
}

public function bar(): void
{
var_dump($x);
}
}
15 changes: 15 additions & 0 deletions e2e/restricted-php-ini/app/C.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class C extends A
{
use T;

public function foo(): void
{
}

public function bar(): void
{
var_dump($x);
}
}
9 changes: 9 additions & 0 deletions e2e/restricted-php-ini/app/T.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

trait T
{
public function ff(): void
{
var_dump($x);
}
}
13 changes: 13 additions & 0 deletions e2e/restricted-php-ini/app/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
level: 9
paths:
- ./
parallel:
jobSize: 2
maximumNumberOfProcesses: 4
minimumNumberOfJobsPerProcess: 2
ignoreErrors:
-
message: '~^Undefined variable: \$x$~'
path: '*'
count: 4
7 changes: 7 additions & 0 deletions e2e/restricted-php-ini/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"autoload": {
"files": [
"preload.php"
]
}
}
18 changes: 18 additions & 0 deletions e2e/restricted-php-ini/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions e2e/restricted-php-ini/phpstan-preload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

set_error_handler(
function (int $severity, string $msg, string $file, int $line): bool {
if ((error_reporting() & ~4437) === 0) {
return false;
}

throw new \ErrorException($msg, 0, $severity, $file, $line);
},
\E_ALL
);

eval('class XB {}');
3 changes: 3 additions & 0 deletions e2e/restricted-php-ini/preload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

eval('class X extends XB {}');

0 comments on commit ecc5a05

Please sign in to comment.