{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322","repository_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards","labels_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322/labels{/name}","comments_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322/comments","events_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322/events","html_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322","id":301997754,"number":1322,"title":"Cannot redeclare WordPress\\Sniffs\\Files\\FilenameSniff","user":{"login":"GaryJones","id":88371,"avatar_url":"https://avatars2.githubusercontent.com/u/88371?v=4","gravatar_id":"","url":"https://api.github.com/users/GaryJones","html_url":"https://github.com/GaryJones","followers_url":"https://api.github.com/users/GaryJones/followers","following_url":"https://api.github.com/users/GaryJones/following{/other_user}","gists_url":"https://api.github.com/users/GaryJones/gists{/gist_id}","starred_url":"https://api.github.com/users/GaryJones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GaryJones/subscriptions","organizations_url":"https://api.github.com/users/GaryJones/orgs","repos_url":"https://api.github.com/users/GaryJones/repos","events_url":"https://api.github.com/users/GaryJones/events{/privacy}","received_events_url":"https://api.github.com/users/GaryJones/received_events","type":"User","site_admin":false},"labels":[{"id":197939651,"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/labels/Type:%20Bug","name":"Type: Bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-03T13:21:34Z","updated_at":"2018-03-03T14:17:02Z","closed_at":null,"author_association":"MEMBER","body":"I'm trying to implement https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes.\r\n\r\nWith a custom test class, I've got the following in my `.phpcs.xml.dist`:\r\n\r\n```\r\n<rule ref=\"WordPress\"/>\r\n<rule ref=\"WordPress.Files.Filename\">\r\n\t<properties>\r\n\t\t<property name=\"custom_test_class_whitelist\" type=\"array\" value=\"WP_Import_UnitTestCase\"/>\r\n\t</properties>\r\n</rule>\r\n```\r\n\r\nI get the following fatal error:\r\n\r\n```\r\nPHP Fatal error:  Cannot declare class WordPress\\Sniffs\\Files\\FileNameSniff, because the name is already in use in /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FilenameSniff.php on line 221\r\nPHP Stack trace:\r\nPHP   1. {main}() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/bin/phpcs:0\r\nPHP   2. PHP_CodeSniffer\\Runner->runPHPCS() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/bin/phpcs:18\r\nPHP   3. PHP_CodeSniffer\\Runner->init() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/src/Runner.php:70\r\nPHP   4. PHP_CodeSniffer\\Ruleset->__construct() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/src/Runner.php:294\r\nPHP   5. PHP_CodeSniffer\\Ruleset->registerSniffs() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/src/Ruleset.php:217\r\nPHP   6. PHP_CodeSniffer\\Autoload::loadFile() /Users/gary/Local Sites/wordpress-core/app/public/src/wp-content/plugins/wordpress-importer/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1103\r\n```\r\n\r\nWith the second `rule` commented out, I get no fatal error (but do get the Error regarding the name of test file for the class that extends WP_Import_UnitTestCase that I'm trying to silence). \r\n\r\nIf I comment out the first rule, I don't get a fatal error, but still do get the Error violation.\r\n\r\nDirect `require-dev` dependencies:\r\n\r\n```\r\ndealerdirect/phpcodesniffer-composer-installer v0.4.4\r\nphpunit/phpunit                                5.7.27\r\nsquizlabs/php_codesniffer                      3.2.3\r\nwimg/php-compatibility                         8.1.0\r\nwp-coding-standards/wpcs                       0.14.1\r\n```\r\n\r\nWPCS `dev-develop` also gives the same situation."},"comment":{"url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/comments/370150488","html_url":"https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322#issuecomment-370150488","issue_url":"https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1322","id":370150488,"user":{"login":"jrfnl","id":663378,"avatar_url":"https://avatars1.githubusercontent.com/u/663378?v=4","gravatar_id":"","url":"https://api.github.com/users/jrfnl","html_url":"https://github.com/jrfnl","followers_url":"https://api.github.com/users/jrfnl/followers","following_url":"https://api.github.com/users/jrfnl/following{/other_user}","gists_url":"https://api.github.com/users/jrfnl/gists{/gist_id}","starred_url":"https://api.github.com/users/jrfnl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrfnl/subscriptions","organizations_url":"https://api.github.com/users/jrfnl/orgs","repos_url":"https://api.github.com/users/jrfnl/repos","events_url":"https://api.github.com/users/jrfnl/events{/privacy}","received_events_url":"https://api.github.com/users/jrfnl/received_events","type":"User","site_admin":false},"created_at":"2018-03-03T14:17:02Z","updated_at":"2018-03-03T14:17:02Z","author_association":"CONTRIBUTOR","body":"@GaryJones I've just tried to reproduce the issue and am not having any luck.\r\n\r\nBased on the Composer info you provided, I've done a test run against the `master` of WP Importer using PHPCS 3.2.3, WPCS 0.14.1 and PHPCompatibility 8.1.0 using the following ruleset and am not getting any PHP errors (but lots of CS violations are being reported):\r\n```xml\r\n<?xml version=\"1.0\"?>\r\n<ruleset name=\"Test1322\">\r\n\r\n\t<file>.</file>\r\n\r\n\t<arg name=\"extensions\" value=\"php\"/>\r\n\t<arg value=\"sp\"/>\r\n\r\n\t<rule ref=\"WordPress\"/>\r\n\r\n\t<rule ref=\"WordPress.Files.Filename\">\r\n\t\t<properties>\r\n\t\t\t<property name=\"custom_test_class_whitelist\" type=\"array\" value=\"WP_Import_UnitTestCase\"/>\r\n\t\t</properties>\r\n\t</rule>\r\n\r\n\t<config name=\"testVersion\" value=\"5.2-\"/>\r\n\t<rule ref=\"PHPCompatibility\"/>\r\n</ruleset>\r\n```\r\n\r\nI've also searched all three standards for additional `class_exists()` calls which might suffer the same issue as we saw in the `PrefixAllGlobals` sniff, but haven't found any problems there either.\r\n\r\n* What PHP version are you using ? Not that it should matter, but I might as well try and reproduce with the same version.\r\n* Can you push your WIP branch ? I've cloned the WP Importer GH repo + your fork."}}
{"actor":{"display_login":"jrfnl"}}