{"id":18221922,"url":"https://github.com/brucegithub/namespace-protector","last_synced_at":"2025-04-03T03:30:36.439Z","repository":{"id":62497561,"uuid":"269004297","full_name":"BruceGitHub/namespace-protector","owner":"BruceGitHub","description":"A tool to validate namespace","archived":false,"fork":false,"pushed_at":"2024-11-06T19:11:46.000Z","size":5052,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T06:22:57.739Z","etag":null,"topics":["check","namespace","namespace-protector","php","private","public","tool"],"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/BruceGitHub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-03T06:10:35.000Z","updated_at":"2022-10-26T06:20:29.000Z","dependencies_parsed_at":"2022-11-02T11:46:15.308Z","dependency_job_id":null,"html_url":"https://github.com/BruceGitHub/namespace-protector","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceGitHub%2Fnamespace-protector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceGitHub%2Fnamespace-protector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceGitHub%2Fnamespace-protector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceGitHub%2Fnamespace-protector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BruceGitHub","download_url":"https://codeload.github.com/BruceGitHub/namespace-protector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933213,"owners_count":20857046,"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":["check","namespace","namespace-protector","php","private","public","tool"],"created_at":"2024-11-03T23:00:20.674Z","updated_at":"2025-04-03T03:30:34.510Z","avatar_url":"https://github.com/BruceGitHub.png","language":"PHP","readme":"# namespace-protector\nA tool to validate namespace\n\n[![Latest Stable Version](https://poser.pugx.org/brucegithub/namespace-protector/v)](//packagist.org/packages/brucegithub/namespace-protector) [![Latest Unstable Version](https://poser.pugx.org/brucegithub/namespace-protector/v/unstable)](//packagist.org/packages/brucegithub/namespace-protector) [![License](https://poser.pugx.org/brucegithub/namespace-protector/license)](//packagist.org/packages/brucegithub/namespace-protector) [![Build Status](https://travis-ci.org/BruceGitHub/namespace-protector.svg?branch=master)](https://travis-ci.org/BruceGitHub/namespace-protector) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/BruceGitHub/namespace-protector/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/BruceGitHub/namespace-protector/?branch=master) [![codecov](https://codecov.io/gh/BruceGitHub/namespace-protector/branch/master/graph/badge.svg)](https://codecov.io/gh/BruceGitHub/namespace-protector)\n\n# Ispired by \n\n- https://www.slideshare.net/MicheleOrselli/comunicare-condividere-e-mantenere-decisioni-architetturali-nei-team-di-sviluppo-approcci-e-strumenti\n- https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers#:~:text=Class%20members%2C%20including%20nested%20classes,from%20outside%20the%20containing%20type. \n- https://wiki.php.net/rfc/namespace-visibility\n\nand for fun ...\n\n# Motivation \n\nAllow to improve the information hiding at level of namespace Like C#/Java pubblic/private class. \nThe idea is that namespace in some situations can be private at all except for a specific entry point. \nFor example the namespace of third parts lib. \n\n# The Design of this project follows this rules \n\n- No NULL \n- No instanceof \n- No switch\n- No static\n\n## Nice to have \n- Minimize the @var annotation \n\n# todo\n### 10/10/2021\n- [] Review the db namespace \n- [] Remove psalm-suppress\n- [] Remove psalm minor issues \n\n### Waiting\n- [] Adds mode DISCOVER_CONFIG, so for each lib that in the `extra` node of composer.json declares the visibility settings of the namespace lib, it can perform the validity in autonomy\n\n### Done\n- [x] Adds command to build conflicts graph \n\n# Minimal config \n\nTrought the json configuration it's possible define \n\n```json\n{\n  \"version\": \"0.1.0\",\n  \"start-path\": \"src\",\n  \"composer-json-path\": \"./\",\n  \"public-entries\": [],\n  \"private-entries\": [],\n  \"mode\": \"MODE_MAKE_VENDOR_PRIVATE\"\n}\n\n```\n# Fast because each ast it's cached and reused until the target file change\n\n- mode `public` default mode, in this setup only a private namespace it's validated\n- mode `private vendor` in which each access of vendor namespace trigger a violation if was not added public namespace.\n\n# Install and Run \n\n## with Composer \n`composer require --dev brucegithub/namespace-protector`\n[![asciicast](https://asciinema.org/a/411325.svg)](https://asciinema.org/a/411325)\n\n## with Phar \nAdds this to composer.json\n```json\n\"repositories\": [{\n  \"type\": \"vcs\",\n  \"url\": \"https://github.com/brucegithub/namespace-protector-phar.git\"\n}],\n```\ncomposer require --dev brucegithub/namespace-protector-phar --no-cache \"dev-main\"\n[![asciicast](https://asciinema.org/a/411326.svg)](https://asciinema.org/a/411326)\n\n## with Docker \n```\ndocker run  --rm -it -v $(pwd):/namespace-protector brucedockerhub/namespace-protector:0.1.0 create-config\ndocker run  --rm -it -v $(pwd):/namespace-protector brucedockerhub/namespace-protector:0.1.0 validate-namespace\n```\n\n## setup \n`vendor/bin/namespace-protector create-config`\n\n## run \n`vendor/bin/namespace-protector validate-namespace`\n\n```bash\n➜  namespace-protector git:(master) ✗ vendor/bin/namespace-protector validate-namespace\n|Dump config:\n|\u003e Version: 0.1.0\n|\u003e Cache: FALSE\n|\u003e Plotter: plotter-terminal\n|\u003e Path start: tests/Stub/RealProject/src\n|\u003e Composer Json path: ./\n|\u003e Mode: PUBLIC\n|\u003e Private entries:\n|       \u003eNamespaceProtector\\Common\\\n|       \u003eNamespaceProtector\\Scanner\\\n|       \u003ePhpParser\n\n|\n|\u003e Public entries:\n\n\nLoad data...\nLoaded 3 files to validate\nLoaded 5031 built in symbols\nStart analysis...\n\nProcessed file: tests/Stub/RealProject/src/NamespaceProtectorProcessorFactory.php\n\t \u003e ERROR Line: 7 of use PhpParser\\NodeTraverser\n\t \u003e ERROR Line: 8 of use PhpParser\\ParserFactory\n\t \u003e ERROR Line: 14 of use NamespaceProtector\\Scanner\\ComposerJson\n\t \u003e ERROR Line: 16 of use NamespaceProtector\\Common\\FileSystemPath\n\t \u003e ERROR Line: 19 of use NamespaceProtector\\Scanner\\FileSystemScanner\n\nProcessed file: tests/Stub/RealProject/src/Analyser.php\n\t \u003e ERROR Line: 8 of use NamespaceProtector\\Common\\PathInterface\n\nProcessed file: tests/Stub/RealProject/src/EnvironmentDataLoader.php\n\t \u003e ERROR Line: 8 of use NamespaceProtector\\Scanner\\ComposerJson\nTotal files: 3\nTotal errors: 7\nElapsed time: 0.68148\n```\n\n```bash \nExample of output in png format.\n➜  vendord/bin/namespace-protector validate-namespace plotter-png\n```\n![example output](https://github.com/BruceGitHub/namespace-protector/blob/master/img/example_output.png)\n\n\nFor now it is a lab but...\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrucegithub%2Fnamespace-protector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrucegithub%2Fnamespace-protector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrucegithub%2Fnamespace-protector/lists"}