You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-3Lines changed: 24 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,14 @@
4
4
5
5
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.
6
6
7
-
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 vendor library. Normally this would only be detectable at run time, but with PHPUnitSyntaxCoverage, you can make sure all files and classes are checked.
7
+
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.
8
8
9
9
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).
10
10
11
11
# Requirements
12
12
- PHP 7.1 or higher
13
13
- PHPUnit 7 or higher
14
+
- Correctly configured autoloading
14
15
15
16
## Installation
16
17
```
@@ -22,8 +23,10 @@ Extend your unit tests from \PHPFUI\PHPUnitSyntaxCoverage\Extensions
22
23
```php
23
24
class UnitTest extends \PHPFUI\PHPUnitSyntaxCoverage\Extensions
$this->assertValidPHPDirectory(__DIR__ . '/../App', 'App directory has an error');
27
30
$this->assertValidPHPFile(__FILE__, 'Unit Test file not valid');
28
31
$this->assertValidPHP('<?php echo "hi";');
29
32
}
@@ -41,9 +44,27 @@ Instead of file by file testing, use **assertValidPHPDirectory** to test an enti
41
44
```
42
45
The error message will include the offending file name and line number.
43
46
47
+
Use **addSkipDirectory** to add simple case insensitive file matching to skip specific directories / files.
48
+
49
+
## Autoloading
50
+
You 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.
51
+
52
+
## PHP Version
53
+
While this library only supports PHP 7.1 or higher, 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
0 commit comments