{"id":19028657,"url":"https://github.com/researchgate/phpnsc","last_synced_at":"2025-04-08T02:43:10.508Z","repository":{"id":1714233,"uuid":"2444007","full_name":"researchgate/phpnsc","owner":"researchgate","description":"Small tool to check for missing use statements when using PHP namespaces","archived":false,"fork":false,"pushed_at":"2025-03-28T10:19:10.000Z","size":128,"stargazers_count":43,"open_issues_count":5,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T11:27:32.664Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/researchgate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-09-23T13:18:27.000Z","updated_at":"2025-03-28T10:19:14.000Z","dependencies_parsed_at":"2024-06-21T04:11:24.961Z","dependency_job_id":null,"html_url":"https://github.com/researchgate/phpnsc","commit_stats":{"total_commits":92,"total_committers":13,"mean_commits":7.076923076923077,"dds":0.6630434782608696,"last_synced_commit":"1f60489a175493ce726ba4743084e06620dfbecb"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchgate%2Fphpnsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchgate%2Fphpnsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchgate%2Fphpnsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchgate%2Fphpnsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/researchgate","download_url":"https://codeload.github.com/researchgate/phpnsc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767232,"owners_count":20992538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T21:11:58.927Z","updated_at":"2025-04-08T02:43:10.471Z","avatar_url":"https://github.com/researchgate.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"phpnsc\n======\n\n![Test status](https://github.com/researchgate/phpnsc/actions/workflows/tests.yml/badge.svg)\n[![Latest Stable Version](https://poser.pugx.org/rg/phpnsc/v/stable)](https://packagist.org/packages/rg/phpnsc)\n[![Total Downloads](https://poser.pugx.org/rg/phpnsc/downloads)](https://packagist.org/packages/rg/phpnsc)\n[![License](https://poser.pugx.org/rg/phpnsc/license)](https://packagist.org/packages/rg/phpnsc)\n\nThe PHP namespace checker, checks all files in a project for invalid class references.\n\nIt prints an error, if a class was used with it's simple or relative name but is:\n\n- not in the same namespace\n- or not in the corresponding sub namespace\n- or does not have a corresponding use statement\n\nUsage\n-----\n\n- Add a JSON config file to your project root (see `config.sample.json`)\n- Run phpnsc:\n\n```bash  \nphpnsc run path/to/config.json\n```\n\nConfiguration\n-------------\n\nThe configuration has to be in a JSON file, that usually is placed in the root of your project. Example:\n\n```json\n{\n    \"sources\": [\n        {\n            \"vendor\": \"vendorNamespace\",\n            \"folders\": {\n                \"root\": \"path/to/sources\",\n                \"include\": [\n                    \"subpackage\",\n                    \"subpackage_two\"\n                ],\n                \"exclude\": [\n                    \"subpackage/excluded\"\n                ]\n            },\n            \"filetypes\": {\n                \"include\": [\n                    \".php\"\n                ],\n                \"exclude\": [\n                    \".config.php\"\n                ]\n            }\n        }\n    ],\n    \"output\": [\n        {\n            \"class\": \"rg\\\\tools\\\\phpnsc\\\\CheckstyleOutput\",\n            \"parameter\": \"build/logs/phpnsc.xml\"\n        },\n        {\n            \"class\": \"rg\\\\tools\\\\phpnsc\\\\ConsoleOutput\",\n            \"parameter\": \"\"\n        }\n    ]\n}\n```\n\n- sources: list of source folders to be scanned\n    - vendor: specifies the root vendor namespace of your project, see (https://gist.github.com/1234504)\n    - folders/root: the root folder of your project\n    - include: which sub-folders of your project root should be included?\n    - exclude: are there be any sub-sub-folders that should be excluded?\n    - filetypes: file types that should be included and excluded from analysis\n- output: array of output classes that should be used. Currently support are:\n    - CheckstyleOutput (checkstyle compatible XML file, e.g. for a CI server)\n    - ConsoleOutput\n\nHow it works\n------------\n\nFirst the tool scans for all files matching the criteria defined in the config file. For each file it strips out all\nunnecessary stuff like comments, strings or non php content. After that it analyzes all defined classes and interfaces\nin your project and all used and referenced classes and interfaces in each file based on regular expressions.\nIn the next step, it then uses this information to deduct if all classes and interfaces are referenced correctly.\n\nCurrent limitations\n-------------------\n\nThis tool is still alpha. It is certainly possible, that it does not find all errors of that it finds false positives.\nAdditionally it can not handle importing several namespaces with one use statement and may have problems with using\naliases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresearchgate%2Fphpnsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresearchgate%2Fphpnsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresearchgate%2Fphpnsc/lists"}