When writing PHP code in Visual Studio Code, the constant FILTER_NULL_ON_FAILURE is automatically converted to lowercase (filter_null_on_failure). This behavior is unique to this constant and does not occur with other filter constants like FILTER_VALIDATE_INT or FILTER_SANITIZE_STRING.

Steps to Reproduce:

Open Visual Studio Code.
Insert any PHP code using filter constants, such as FILTER_VALIDATE_INT or FILTER_SANITIZE_STRING.
Specifically, insert the FILTER_NULL_ON_FAILURE constant.
Observe the behavior: FILTER_NULL_ON_FAILURE is auto-converted to filter_null_on_failure, while other constants remain in uppercase.
Expected Behavior:
The constant FILTER_NULL_ON_FAILURE should retain its original uppercase form, just like other PHP filter constants.

Actual Behavior:
Only FILTER_NULL_ON_FAILURE is auto-converted to lowercase, whereas other filter constants such as FILTER_VALIDATE_INT retain their uppercase form.

Priority: Medium

Suggested Fix:
Investigate why FILTER_NULL_ON_FAILURE is being treated differently from other constants. Ensure that all constants maintain their correct case and that FILTER_NULL_ON_FAILURE remains in uppercase as intended.

    Thank you for reporting the issue, but I cannot replicate it.

    Basically, we don't do any case-lowering;

      6 days later

        DP24 Thank you,

        So it happens when formatting the code?

        That's weird:

          Yes when formatting the code and when pasting

            DP24 - This looks like another extension causes it. Do you use a PHP formatter from another extension?

            • DP24 replied to this.
              4 days later



                Could it be due to the zero constant setting?
                "php.format.rules.nullConstantCasing": "lowercase"

                Here are the complete settings of the PHP extension for comparison:

                {
                	"intelliphp.inlineSuggestionsEnabled": true,
                	"php.completion.namingConvention": "snake_case",
                	"php.completion.parameters": "parentheses",
                	"php.docblock.classSnippet": {},
                	"php.format.rules.addCommaAfterLastArrayElement": true,
                	"php.format.rules.addCommaAfterLastCallParameter": true,
                	"php.format.rules.addCommaAfterLastDeclParameter": true,
                	"php.format.rules.alignConsecutiveAssignments": false,
                	"php.format.rules.alignConstants": true,
                	"php.format.rules.alignEnumCases": true,
                	"php.format.rules.alignMatchArmBodies": true,
                	"php.format.rules.arrayInitializersAlignKeyValuePairs": true,
                	"php.format.rules.arrayInitializersNewLineAfterLastElement": true,
                	"php.format.rules.arrayInitializersNewLineBeforeFirstElement": true,
                	"php.format.rules.blankLinesAfterClass": 1,
                	"php.format.rules.blankLinesAfterFunction": 1,
                	"php.format.rules.blankLinesAfterMethod": 1,
                	"php.format.rules.booleanConstantCasing": "lowercase",
                	"php.format.rules.callParametersNewLineAfterLeftParen": true,
                	"php.format.rules.callParametersNewLineBeforeRightParen": true,
                	"php.format.rules.catchOnNewLine": false,
                	"php.format.rules.elseOnNewLine": false,
                	"php.format.rules.finallyOnNewLine": true,
                	"php.format.rules.forStatementNewLineAfterLeftParen": true,
                	"php.format.rules.forStatementNewLineBeforeRightParen": true,
                	"php.format.rules.groupUseNewLineBeforeFirstDeclaration": true,
                	"php.format.rules.ifStatementNewLineAfterLeftParen": false,
                	"php.format.rules.ifStatementNewLineBeforeRightParen": false,
                	"php.format.rules.indentBraces": false,
                	"php.format.rules.newLineAfterImplements": true,
                	"php.format.rules.nullConstantCasing": "lowercase",
                	"php.format.rules.openBraceOnNewLineForAnonymousClasses": false,
                	"php.format.rules.openBraceOnNewLineForBlocks": false,
                	"php.format.rules.openBraceOnNewLineForTypes": false,
                	"php.format.rules.spaceAfterCast": true,
                	"php.format.rules.spaceAroundConcatenation": false,
                	"php.format.rules.spaceBeforeColonInControlStatements": false,
                	"php.format.rules.spaceBeforeParenthesesInControlStatements": true,
                	"php.format.rules.switchStatementNewLineAfterLeftParen": false,
                	"php.hover.fullname": true,
                	"php.inlayHints.parameters.enabled": true,
                	"php.inlayHints.parameters.suppressNameMatchingValue": true,
                	"php.inlayHints.types.return": true,
                	"php.inlayHints.types.variable": true,
                	"php.linkedEditing.variables": true,
                	"php.problems.excludeGitIgnore": true,
                	"php.problems.scope": "all",
                	"php.stubs": [
                		"*",
                		"imagick",
                		"xdebug"
                	],
                	"php.suggest.basic": true,
                	"php.validate.executablePath": ""
                }
                  8 days later

                  JakubMisek

                  So not that I know, maybe you know more, that's why the screenshots of the extensions

                    Thank you for the details, and I am sorry for the delay!

                    It all looks alright :/ we'll try the same settings if it happens too.

                      Hello,

                      Thank you for providing us with all the details, that helped a lot. It looks like a bug, we will fix this ASAP.

                        Fixed. It will be available in the next pre-release.

                        Thank you!

                          Write a Reply...