{"id":15008373,"url":"https://github.com/phpfui/phpunitsyntaxcoverage","last_synced_at":"2025-04-09T16:05:01.838Z","repository":{"id":57051335,"uuid":"287154247","full_name":"phpfui/PHPUnitSyntaxCoverage","owner":"phpfui","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-22T23:09:20.000Z","size":85,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T16:04:54.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/phpfui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-08-13T01:42:26.000Z","updated_at":"2024-10-22T23:06:39.000Z","dependencies_parsed_at":"2024-02-23T21:23:27.344Z","dependency_job_id":"11afb79c-986c-4d1b-a949-02acbc97d5d7","html_url":"https://github.com/phpfui/PHPUnitSyntaxCoverage","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfui%2FPHPUnitSyntaxCoverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfui%2FPHPUnitSyntaxCoverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfui%2FPHPUnitSyntaxCoverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfui%2FPHPUnitSyntaxCoverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpfui","download_url":"https://codeload.github.com/phpfui/PHPUnitSyntaxCoverage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065289,"owners_count":21041871,"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-09-24T19:17:55.917Z","updated_at":"2025-04-09T16:05:01.819Z","avatar_url":"https://github.com/phpfui.png","language":"PHP","readme":"# PHPUnitSyntaxCoverage [![Tests](https://github.com/phpfui/PHPUnitSyntaxCoverage/actions/workflows/tests.yml/badge.svg)](https://github.com/phpfui/PHPUnitSyntaxCoverage/actions?query=workflow%3Atests) [![Latest Packagist release](https://img.shields.io/packagist/v/phpfui/phpunit-syntax-coverage.svg)](https://packagist.org/packages/phpfui/phpunit-syntax-coverage) ![](https://img.shields.io/badge/PHPStan-level%206-brightgreen.svg?style=flat)\n\n## PHPUnit Extension for complete PHP Syntax Code Coverage\n\nThis package will checks for easy to miss syntax errors in all your PHP code. It will also check all your classes to see if they are loadable, but without actually instantiating the class.\n\nOften we accidently check in code with easily detectable syntax errors, but unless the file or class is actually loaded by PHP, we might not see the error. Often the file or class is syntaxically correct, but a method signature may not match an updated class or vendor library. Normally this would only be detectable at run time, but with **PHPUnitSyntaxCoverage**, you can make sure all files and classes are checked.\n\nPHPUnitSyntaxCoverage uses [PhpParser](https://github.com/nikic/PHP-Parser) to check for basic syntax errors. It then uses [ReflectionClass](https://www.php.net/manual/en/class.reflectionclass.php) to load any classes that are found in the source without instantiating them.  This will find additional errors (such as missing or changed base classes from a package update).\n\n# Requirements\n- Modern versions of PHP and PHPUnit\n- Correctly configured autoloading\n\n## Installation\n```\ncomposer require phpfui/phpunit-syntax-coverage\n```\n\n## Usage\nExtend your unit tests from \\PHPFUI\\PHPUnitSyntaxCoverage\\Extensions\n```php\nclass UnitTest extends \\PHPFUI\\PHPUnitSyntaxCoverage\\Extensions\n  {\n  public function testProjectSyntax()\n    {\n    $this-\u003eaddSkipDirectory(__DIR__ . '/../App/Examples');\n    $this-\u003eassertValidPHPDirectory(__DIR__ . '/../App', 'App directory has an error');\n    $this-\u003eassertValidPHPFile(__FILE__, 'Unit Test file not valid');\n    $this-\u003eassertValidPHP('\u003c?php echo \"hi\";');\n    }\n  }\n```\nYou can use any of the following asserts:\n- assertValidPHP(string $code, string $message = '')\n- assertValidPHPDirectory(string $directory, string $message = '', bool $recurseSubdirectories = true, array $extensions = ['.php'])\n- assertValidPHPFile(string $fileName, string $message = '')\n\n## Directory Testing\nInstead of file by file testing, use **assertValidPHPDirectory** to test an entire directory. Any files added to the directory will be automatically tested.\n```php\n  $this-\u003eassertValidPHPDirectory(__DIR__ . '/../App', 'App directory error');\n```\nThe error message will include the offending file name and line number.\n\nUse **addSkipDirectory** to add simple case insensitive file matching to skip specific directories / files.\n\n## Autoloading\nYou must make sure autoloading is correctly configured for all classes.  This means you can't pass references to classes that will not resolve correctly in your source. Use **addSkipDirectory** if you have test code that may not validate correctly.\n\n## Namespace Testing\nThe **assertValidPHPFile** and **assertValidPHPDirectory** asserts will test for the proper namespace in the file path (for PSR-0 autoloading and fully pathed PSR-4 autoloading), but you can turn off namespace testing with **skipNamespaceTesting** or exclude a specific namespace tests with **addSkipNamespace**.\n\n## PHP Version\nWhile this library only supports currently supported versions of PHP, you can create a project and point it to PHP 5.2 or higher. The default is to prefer PHP 7 code, but to prefer or only parse PHP 5, configure phpunit.xml(.dist) with\n~~~xml\n\t\u003cphp\u003e\n\t\t\u003cenv name=\"PHPFUI\\PHPUnitSyntaxCoverage\\Extensions_parser_type\" value=\"X\"/\u003e\n\t\u003c/php\u003e\n~~~\nWhere X is one of the following **numbers**:\n1. Prefer PHP 7\n2. Prefer PHP 5\n3. Only PHP 7\n4. Only PHP 5\n\n## Examples\nSee [examples](https://github.com/phpfui/PHPUnitSyntaxCoverage/blob/master/tests/UnitTest.php)\n\n## Full Class Documentation\n[PHPFUI/InstaDoc](http://phpfui.com/?n=PHPFUI/PHPUnitSyntaxCoverage)\n\n## License\nPHPFUI is distributed under the MIT License.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpfui%2Fphpunitsyntaxcoverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpfui%2Fphpunitsyntaxcoverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpfui%2Fphpunitsyntaxcoverage/lists"}