PHPackages                             phpfui/phpunit-syntax-coverage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpfui/phpunit-syntax-coverage

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phpfui/phpunit-syntax-coverage
==============================

PHPUnit Testing extensions for complete syntax checking of all files and classes in your project

V1.0.21(1mo ago)25.2k↑76.5%10MITPHPPHP &gt;=8.1 &lt;8.6CI passing

Since Aug 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/phpfui/PHPUnitSyntaxCoverage)[ Packagist](https://packagist.org/packages/phpfui/phpunit-syntax-coverage)[ Docs](https://github.com/phpfui/PHPUnitSyntaxCoverage)[ RSS](/packages/phpfui-phpunit-syntax-coverage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (23)Used By (10)

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://camo.githubusercontent.com/9013ba33bf90ec577afff17645849ad0ea7e76c2f830d2a2a7e41796c4840851/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706675692f706870756e69742d73796e7461782d636f7665726167652e737667)](https://packagist.org/packages/phpfui/phpunit-syntax-coverage) [![](https://camo.githubusercontent.com/742e8be8005b1fe76a64a5d8f5e6a5d4f63bf315e9a44a6d23e4e11c76b0555f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/742e8be8005b1fe76a64a5d8f5e6a5d4f63bf315e9a44a6d23e4e11c76b0555f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e7376673f7374796c653d666c6174)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phpunitsyntaxcoverage---)

PHPUnit Extension for complete PHP Syntax Code Coverage
-------------------------------------------------------

[](#phpunit-extension-for-complete-php-syntax-code-coverage)

This 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.

Often 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.

PHPUnitSyntaxCoverage 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).

Requirements
============

[](#requirements)

- Modern versions of PHP and PHPUnit
- Correctly configured autoloading

Installation
------------

[](#installation)

```
composer require phpfui/phpunit-syntax-coverage

```

Usage
-----

[](#usage)

Extend your unit tests from \\PHPFUI\\PHPUnitSyntaxCoverage\\Extensions

```
class UnitTest extends \PHPFUI\PHPUnitSyntaxCoverage\Extensions
  {
  public function testProjectSyntax()
    {
    $this->addSkipDirectory(__DIR__ . '/../App/Examples');
    $this->assertValidPHPDirectory(__DIR__ . '/../App', 'App directory has an error');
    $this->assertValidPHPFile(__FILE__, 'Unit Test file not valid');
    $this->assertValidPHP('
