-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
PHPStan Pro "not a valid ini size" error when using PHPSTAN_PRO_WEB_PORT env var #5433
Comments
This bug report is missing a link to reproduction on phpstan.org. It will most likely be closed after manual review. |
Would be great to have a |
Sounds like a issue in your config or in https://github.com/reactphp/http/blob/master/src/Io/IniUtil.php
It seems its a empty string or a space-only string or similar phpstan relqted sources seem to be arround here, in case you want to investigate https://github.com/phpstan/phpstan-src/blob/181f75ce89a521aebc0336a61352b821645c738a/src/Command/FixerApplication.php#L349 |
There's an invalid value in your |
@ondrejmirtes seems valid to me?
If I put a memory.php with this as the contents:
Then I run
But if I change it to:
I get this:
Guessing the single quotes around 512M are the issue here? The seme behavior happens whether it's |
I'll add some debugging to PHPStan Pro itself which should tell us more info. This piece of code is what's triggering that: https://github.com/reactphp/http/blob/cd36b4fa319f1296cb634743a600e3548e31d443/src/HttpServer.php#L316-L342 |
Happy to test whatever you need me to! |
I just added this piece of code to PHPStan Pro: try {
$postMaxSize = ini_get('post_max_size');
if ($postMaxSize === false) {
$postMaxSize = '';
}
IniUtil::iniSizeToBytes($postMaxSize);
} catch (\InvalidArgumentException $e) {
$phpIni = php_ini_loaded_file();
$output->writeln(sprintf(
"PHPStan Pro is likely to crash because your php.ini (%s)\ncontains post_max_size directive with value %s which is invalid.",
$phpIni !== false ? $phpIni : 'none',
var_export(ini_get('post_max_size'), true)
));
return 1;
} So you should see it crash before running with this nice error message. If this message isn't printed and PHPStan Pro still crashes later with the exception stack trace from the original post then I don't know what's going on... Make sure your PHPStan Pro is up to date by launching it and checking "About PHPStan Pro" in the user menu. You can force the update there. |
Looks like PHPStan copies the php.ini file into a temp folder and the value is getting lost during that copy? Maybe |
You can get around that if you disable Xdebug. PHPStan relaunches with the help of https://github.com/composer/xdebug-handler if it detects Xdebug so that it doesn't affect performance. |
@ondrejmirtes does PHPStan base this on detecting if the xdebug module is loaded? Or even if it's loaded, does it check if it's disabled? i.e. |
@angrybrad I'm not sure, check what https://github.com/composer/xdebug-handler does. |
https://github.com/composer/xdebug-handler/blob/main/src/XdebugHandler.php#L73-L78 In my case, I'm running xdebug 3.0.4. Based on that, XdebugHandler should consider xdebug "off". Not sure if it's an issue in XdebugHandler, or PHPStan's implementation of it, unfortunately. I'll try to do some more testing to narrow it down. |
PHPStan just calls |
Based on the conversation here this doesn't seem to be related to the XdebugHandler library, since we've verified that Xdebug is indeed disabled for my environment. |
There seem to be 3 odd things:
Number 3 seems the most interesting to me, but as far as I can tell, the PHPStan Pro code isn't public, so I'm not sure what logic is around that environment variable.
In addition to printing out the path to the loaded php.ini file, can you copy the contents of it into a location that can be examined? That might expose something interesting. |
A bit slow, but finally root-caused this! The docker images we're using (for example https://github.com/craftcms/docker/tree/main/7.4) have custom php.ini files that get copied into the container: https://github.com/craftcms/docker/blob/main/7.4/craft-cms.ini The values are read from environment variables. Whatever logic/library PHPStan Pro is using to check for valid values doesn't know how to parse when the values are environment variables. If I hard-code them to actual values, it works as expected. |
Hi, since the message I just tried a fix, can you please try |
That works! Thanks, @ondrejmirtes! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Running 0.12.94 of PHPStan and trying out the Pro version.
Using Nitro, which is a Docker-based development environment. That container already exposes port 3000, so I figured I'd be able to tell PHPStan to use that with
PHPSTAN_PRO_WEB_PORT
.But I'm getting the following error, which seems like it could be an error not related to Docker at all.
php.ini's memory limit in the container shows
512M
, which seems valid to me:Have tried various combinations of
--memory-limit=512M
to PHPStan with the same error.If I try it without setting
PHPSTAN_PRO_WEB_PORT
, it appears to work fine, other than the fact that port 11111 isn't exposed in this Nitro container so I can't access it from the host machine.Not sure the best way to debug this, but open to suggestions!
Did PHPStan help you today? Did it make you happy in any way?
Love PHPStan!
The text was updated successfully, but these errors were encountered: