-
Notifications
You must be signed in to change notification settings - Fork 153
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
Several include-path regex issues on both Windows and Linux #485
Comments
Hi @gwharton. Thank you for your report. Join Magento Community Engineering Slack and ask your questions in #github channel. |
FYI, the full set of sniffs I tested for regex match was
|
You can also see evidence of the \m being present on windows in the regex where phpcs fails and bugs out because of the Magento2.Legacy.ModuleXML include regex being wrong on windows.
|
If you'd like me to package this test environment up onto packagist to make it easier for you to reproduce, just let me know. More than happy to help. |
@magento I am working on this |
Preconditions
Steps to reproduce
The following creates a blank project, installs the necessary composer packages, creates some test files, and then patches phpcs to provide additional debugging output on the console for regex matching of include paths.
I went through all of the Magento sniffs that have an include-path regex specified in the ruleset.xml file and verified that matches were being made where expected. I did this both on Ubuntu 24.04 and on Windows 11/Cygwin. Here is a summary of the tests that dd not produce the expected matching behaviour and some notes.
Ubuntu 24.04 - Magento2.Html.HtmlBinding
PHPCS Magento Ruleset Include Pattern :
*\/.phtml$
NO MATCH
I am assuming that this test is intended to run on all files with a
.phtml
extension. As written, the expression will match onpath/.phtml
but notpath/file.phtml
.Ubuntu 24.04 - Magento2.Legacy.Layout
PHPCS Magento Ruleset Include Pattern :
*/view/(adminhtml|frontend|base)/*\/.xml
NO MATCH
Looking at the pattern, I would assume that this is intended to match files with filenames such as
anything/view/adminhtml/anything/test.xml
, but thats not what the expression is looking for. Is it really looking for an xml file with no name and just extension.Windows 11/Cygwin - Magento2.Legacy.ClassReferencesInConfigurationFiles
PHPCS Magento Ruleset Include Pattern :
*\/etc/*.xml$
NO MATCH
The pattern is wrong here. It is matching
\\
(Backslash) and then\e
(ASCII 8) followed by tc\something.xml.Windows 11/Cygwin - Magento2.Html.HtmlBinding
PHPCS Magento Ruleset Include Pattern :
*\/.phtml$
NO MATCH
The pattern is wrong here. It is matching
\\
(Backslash) and then\.
(.
) and thenphtml
. i.e filename ends in\.phtml
Windows 11/Cygwin - Magento2.Legacy.ModuleXML
PHPCS Magento Ruleset Include Pattern :
*\/module.xml$
NO MATCH
The pattern is wrong here. It is matching
\\
(Backslash) and then\m
(undefined, preg_match should throw an error here) and thenodule.xml
.Windows 11/Cygwin - Magento2.Legacy.DiConfig
PHPCS Magento Ruleset Include Pattern :
*\/di.xml$
NO MATCH
The pattern is wrong here. It is matching
\\
(Backslash) and then\d
(a digit from[0-9]
) and theni.xml
.Windows 11/Cygwin - Magento2.Legacy.WidgetXML
PHPCS Magento Ruleset Include Pattern :
*\/widget.xml$
MATCHED but.......
Well ok, the regex matches on this one, but not by design, but by accident. The pattern as written will match anything followed by
\\
(Backslash) followed by\w
(and word character[a-zA-Z0-9_]
) followed byidget.xml
.The text was updated successfully, but these errors were encountered: