Re: Deprecate Undefined Constant Usage in php.ini Files (GH-20060)

From: Date: Mon, 20 Oct 2025 18:17:16 +0000
Subject: Re: Deprecate Undefined Constant Usage in php.ini Files (GH-20060)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-128875@lists.php.net to get a copy of this message
On 20/10/2025 10:16, Hans Krentel wrote:
So, there would indeed be a change compared to my earlier answer: I now propose using only uppercase names for constant resolution (and thus for the warning you asked about). This would mean: - Allowing unquoted strings with lowercase characters to pass through unchanged. - Restricting constant name resolution to a pattern like:
     CONSTANT_NAME [A-Z_][A-Z0-9_]*
...possibly with a minimum length greater than one, as shown.
I don't think this kind of pattern matching is the right way to go. It's perfectly normal in INI files to have all sorts of strings which aren't quoted; looking through the samples provided in the source, I spotted this: user_agent=PHP No regex is going to recognise that that should be interpreted as "PHP", not constant("PHP"). As I think I mentioned in an earlier message, the specific problem raised seems to be more to do with string-to-int conversion, rather than the INI parsing itself. Even if the invalid constant is surrounded by quotes, this is not a useful setting: error_reporting = "X_ERROR"|E_WARNING|E_PARSE|E_NOTICE Maybe the part of the parser that handles *operators* is what needs a behaviour change instead? -- Rowan Tommins [IMSoP]

Thread (8 messages)

« previous php.internals (#128875) next »