{"id":24539890,"url":"https://github.com/xenioushk/phpcs_101","last_synced_at":"2026-02-08T09:31:50.097Z","repository":{"id":271943056,"uuid":"851465884","full_name":"xenioushk/phpcs_101","owner":"xenioushk","description":"This guide provides a comprehensive guideline for setting up PHPCS for a WordPress theme or plugin. You will also get instructions for setting up the PHPCS Visual Studio Code extension setup.","archived":false,"fork":false,"pushed_at":"2025-02-27T10:37:20.000Z","size":323,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-11T17:53:58.190Z","etag":null,"topics":["phpcs","phpcs-standard"],"latest_commit_sha":null,"homepage":"https://bluewindlab.net","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xenioushk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-09-03T06:36:33.000Z","updated_at":"2025-02-27T10:37:23.000Z","dependencies_parsed_at":"2025-02-27T11:44:17.115Z","dependency_job_id":"fdca86a1-3366-4776-8262-4b2d3c57f29e","html_url":"https://github.com/xenioushk/phpcs_101","commit_stats":null,"previous_names":["xenioushk/phpcs_101"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xenioushk/phpcs_101","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fphpcs_101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fphpcs_101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fphpcs_101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fphpcs_101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xenioushk","download_url":"https://codeload.github.com/xenioushk/phpcs_101/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fphpcs_101/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29226469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T09:15:18.648Z","status":"ssl_error","status_checked_at":"2026-02-08T09:14:33.745Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["phpcs","phpcs-standard"],"created_at":"2025-01-22T17:16:40.702Z","updated_at":"2026-02-08T09:31:50.082Z","avatar_url":"https://github.com/xenioushk.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHPCS Setup\n\nThis guide provides a comprehensive guideline for setting up PHPCS for a WordPress theme or plugin. You will also get instructions for setting up the PHPCS Visual Studio Code extension setup.\n\n## Requirements\n\nYou need to install the following softwares on your machine.\n\n- [composer](https://getcomposer.org/)\n- [npm](https://www.npmjs.com/)\n- [node](https://nodejs.org/en)\n\n## Steps\n\n1. Navigate to the project root directory.\n2. Open composer.json file and add/update the codes.\n\n```json\n\"require\": {\n  \"php\": \"\u003e=7.4|^8.0\",\n  \"composer/installers\": \"^1.0.12\"\n},\n```\n\n```json\n\"require-dev\": {\n  \"wp-coding-standards/wpcs\": \"^3.1\",\n  \"phpcompatibility/phpcompatibility-wp\": \"2.1\",\n  \"dealerdirect/phpcodesniffer-composer-installer\": \"^1.0\",\n  \"squizlabs/php_codesniffer\": \"^3.10\"\n},\n```\n\n```json\n\"config\": {\n  \"allow-plugins\": {\n    \"composer/installers\": true,\n    \"dealerdirect/phpcodesniffer-composer-installer\": true,\n    \"johnpbloch/wordpress-core-installer\": true\n  }\n}\n```\n\n3. Run the command to install composer packages.\n\n```bash\ncomposer update\n```\n\n4. You will now see a bin folder inside the `vendor` directory.\n\n![phpcs bin directory](/previews/composer/phpcs_bin_folder.jpg)\n\n5. Next, open the `package.json` file and add this code.\n\n```json\n\"lint:php\": \"vendor/bin/phpcs\",\n\"lint:php:fix\": \"vendor/bin/phpcbf\",\n```\n\n![Update package.json file](/previews/npm/phplintcode.jpg)\n\n6. Now, copy/download the `phpcs.xml` file from this [link](phpcs.xml) and paste it to the project root directory.\n\n![Update package.json file](/previews/npm/phplintcode.jpg)\n\n7. All done. Now, we can run this command to check the php linting errors and fix them.\n\n```bash\nnpm run lint:php\nnpm run lint:php:fix\n```\n\n**Output:**\n\n![PHPCS linting report](/previews/phpcs/phpcs_log.jpg)\n\n## Ignoring the issue\n\nSometimes we need to ignore some of the error highlights.\nJust add the `// phpcs:ignore` text after the line and issue will be fixed.\n\n```php\nfunction init_bwl_advanced_faq_manager() { // phpcs:ignore\n    new BWL_Advanced_Faq_Manager();\n}\n```\n\n## Install VSCode PHP Sniffer extension\n\n1. Search and install visual studio code PHP Sniffer \u0026 Beautifer extension.\n\n![install_php_sniffer_and_beautifer_vscode_extension](/previews/phpcs/install_php_sniffer_and_beautifer_vscode_extension.jpg)\n\n2. Navigate to settings of the visual studio code and search for `.json` file. Click on the `Edit in settings.json`link and add following lines of code.\n\n   ![create workspace based settings.json file](/previews/phpcs/edit_settings.json_file.jpg)\n\n```json\n{\n  \"phpSniffer.autoDetect\": true,\n  \"phpSniffer.run\": \"onSave\", // Runs PHPCS on save\n  \"[php]\": {\n    \"editor.defaultFormatter\": \"valeryanm.vscode-phpsab\",\n    \"editor.insertSpaces\": false,\n    \"editor.tabSize\": 4\n  },\n  \"files.trimTrailingWhitespace\": false,\n  \"editor.renderFinalNewline\": \"on\",\n  \"files.insertFinalNewline\": true,\n  \"files.trimFinalNewlines\": false,\n  \"files.eol\": \"\\n\" // Enforces Unix-style line endings\n}\n```\n\n3. Test a particular file.\n\n```bash\n./vendor/bin/phpcs --standard=WordPress bwl-services-api.php\n```\n\n4. Fix a particular file.\n\n```bash\n./vendor/bin/phpcbf bwl-services-api.php\n```\n\nThat's it.\n\n## PHP Function comment parameters.\n\nIn PHPDoc comments, there are several fields you can use to provide additional information about the function. Here are some commonly used fields:\n\n```php\n@param: Describes the parameters the function accepts.\n@return: Describes the return value of the function.\n@throws: Describes any exceptions the function might throw.\n@deprecated: Indicates that the function is deprecated and should not be used.\n@see: Provides a reference to another function or resource.\n@link: Provides a URL to a related resource.\n@author: Indicates the author of the function.\n@version: Indicates the version of the function.\n@since: Indicates the version since the function is available.\n@example: Provides an example of how to use the function.\n```\n\n### Acknowledgement\n\n- [bluewindlab.net](https://bluewindlab.net)\n- [composer](https://getcomposer.org/)\n- [npm](https://www.npmjs.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Fphpcs_101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxenioushk%2Fphpcs_101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Fphpcs_101/lists"}