{"action":"opened","issue":{"url":"https://api.github.com/repos/slevomat/coding-standard/issues/276","repository_url":"https://api.github.com/repos/slevomat/coding-standard","labels_url":"https://api.github.com/repos/slevomat/coding-standard/issues/276/labels{/name}","comments_url":"https://api.github.com/repos/slevomat/coding-standard/issues/276/comments","events_url":"https://api.github.com/repos/slevomat/coding-standard/issues/276/events","html_url":"https://github.com/slevomat/coding-standard/issues/276","id":295451702,"number":276,"title":"ReferenceUsedNamesOnly: importing global functions and constants should not be necessary when in the global namespace","user":{"login":"nicwortel","id":1055691,"avatar_url":"https://avatars2.githubusercontent.com/u/1055691?v=4","gravatar_id":"","url":"https://api.github.com/users/nicwortel","html_url":"https://github.com/nicwortel","followers_url":"https://api.github.com/users/nicwortel/followers","following_url":"https://api.github.com/users/nicwortel/following{/other_user}","gists_url":"https://api.github.com/users/nicwortel/gists{/gist_id}","starred_url":"https://api.github.com/users/nicwortel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicwortel/subscriptions","organizations_url":"https://api.github.com/users/nicwortel/orgs","repos_url":"https://api.github.com/users/nicwortel/repos","events_url":"https://api.github.com/users/nicwortel/events{/privacy}","received_events_url":"https://api.github.com/users/nicwortel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-08T10:06:09Z","updated_at":"2018-02-08T10:06:09Z","closed_at":null,"author_association":"NONE","body":"# Steps to reproduce\r\n\r\n1. Create a file `index.php`:\r\n\r\n```php\r\n<?php\r\n\r\necho PHP_VERSION;\r\n\r\necho count([]);\r\n```\r\n2. Create a `phpcs.xml`:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ruleset>\r\n    <rule ref=\"SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly\" >\r\n        <properties>\r\n            <property name=\"allowFallbackGlobalFunctions\" value=\"false\"/>\r\n            <property name=\"allowFallbackGlobalConstants\" value=\"false\"/>\r\n        </properties>\r\n    </rule>\r\n</ruleset>\r\n```\r\n3. Run PHPCS:\r\n```bash\r\nvendor/bin/phpcs index.php\r\n```\r\n\r\n# Expected result\r\n\r\nPHPCS passes: since we are in the global namespace, we shouldn't have to import functions or constants.\r\n\r\n# Actual result\r\nPHPCS reports errors:\r\n```\r\n--------------------------------------------------------------------------------------------------------------------\r\nFOUND 2 ERRORS AFFECTING 2 LINES\r\n--------------------------------------------------------------------------------------------------------------------\r\n 3 | ERROR | [x] Constant PHP_VERSION should not be referenced via a fallback global name, but via a use statement.\r\n 5 | ERROR | [x] Function count() should not be referenced via a fallback global name, but via a use statement.\r\n--------------------------------------------------------------------------------------------------------------------\r\nPHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY\r\n--------------------------------------------------------------------------------------------------------------------\r\n```"}}
{"actor":{"display_login":"nicwortel"}}