-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Description
Bug Report: phpinfo()
Accepts Any Integer Value as Parameter
Issue Summary:
The phpinfo()
function in PHP accepts any integer as a parameter, even though it is supposed to only accept predefined constants as flags. This allows invalid flag values (e.g., phpinfo(9999);
) to be passed without throwing any error or warning.
Expected Behavior:
The phpinfo()
function should validate the parameter to ensure that only valid flags (constants like INFO_GENERAL
, INFO_CREDITS
, etc.) are passed. Passing an invalid flag should throw an error (e.g., ValueError
) or trigger a warning. Additionally, an enum could be used to ensure better handling and readability of these flags.
Current Behavior:
Currently, calling phpinfo()
with any arbitrary integer (e.g., phpinfo(9999);
) does not produce an error and still generates output, which could lead to unexpected behavior.
Steps to Reproduce:
- Call
phpinfo(9999);
or any invalid integer. - Observe that no error is thrown, and the function continues to execute.
// Example of unexpected behavior:
phpinfo(9999);
Suggested Fixes:
- Implement strict validation to check if the passed parameter is a valid constant (or combination of constants).
- Consider throwing a
ValueError
or issuing a warning if an invalid flag is passed. - Introduce an enum or another stricter typing system to define the allowed constants for better code clarity and maintainability.
Flags Reference:
INFO_GENERAL => 1
INFO_CREDITS => 2
INFO_CONFIGURATION=> 4
INFO_MODULES => 8
INFO_ENVIRONMENT => 16
INFO_VARIABLES => 32
INFO_LICENSE => 64
INFO_ALL => -1
Link to phpinfo() documentation
PHP Version
PHP 8.3.11
Operating System
Windows 11