Skip to content
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

apply php configurations when fork child workers #559

Merged
merged 3 commits into from
Jun 26, 2021
Merged

apply php configurations when fork child workers #559

merged 3 commits into from
Jun 26, 2021

Conversation

yangchaobj
Copy link
Contributor

@yangchaobj yangchaobj commented Jun 21, 2021

Currently, ProcessHelper only copy command-line arguments of phpstan, but ignore those of php itself.
In some cases, the custom configuration for php: --configuration (-c in short), is very usefull.

for example:
If a custom php.ini is specified when starting phpstan like:
php74 -c my-php.ini analyze --level 0 ...

my-php.ini

extension=yaf
yaf.use_namespace = On
...

phpstan creates child workers to analyze, however, it only copies its own the command-line arguments, not those of php itself (-c my-php.ini).
In workers, "yaf.use_namespace" could not take effect, the reference to "Yaf\Application" will generate "Yaf\Application not found" error message.

@yangchaobj yangchaobj changed the title copy php configurations when fork child workers apply php configurations when fork child workers Jun 21, 2021
@dktapps
Copy link
Contributor

dktapps commented Jun 22, 2021

I'd also find this useful, since PHPStan and JIT don't work so well together on Windows, and it's tiresome to have to disable it in php.ini.

@ondrejmirtes
Copy link
Member

since PHPStan and JIT don't work so well together on Windows

Looks like you have a different root issue @dktapps that should be addressed.

@@ -24,8 +24,11 @@ public static function getWorkerCommand(
InputInterface $input
): string
{
$phpIni = php_ini_loaded_file();
$phpCmd = ($phpIni === false) ? escapeshellarg(PHP_BINARY) : sprintf('%s -c %s', escapeshellarg(PHP_BINARY), $phpIni);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$phpIni needs to be escaped as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, you are right, let me fix it.

@dktapps
Copy link
Contributor

dktapps commented Jun 26, 2021

since PHPStan and JIT don't work so well together on Windows

Looks like you have a different root issue @dktapps that should be addressed.

I know, but I've been unsuccessful at identifying the root cause of the problem after several months of investigation. I know it has something to do with subprocesses, but I'm not sure exactly what - something leads to PHP segfaulting in PM analysis runs.

I end up disabling JIT as a workaround, but PHPStan makes that difficult due to not passing CLI arguments to subprocesses.

@ondrejmirtes ondrejmirtes merged commit 85fbcff into phpstan:master Jun 26, 2021
@ondrejmirtes
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants