Skip to content

Commit 528115f

Browse files
committed
Initial commit
0 parents  commit 528115f

16 files changed

Lines changed: 518 additions & 0 deletions

‎.gitiattributes‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# no binary files in this repo and store all files with LF line endings.
2+
3+
# for windows do the following:
4+
# git config --global core.eol native
5+
# git config --global core.autocrlf true
6+
7+
* text=auto

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
vendor/
2+
.idea/
3+
bin/
4+
composer.lock
5+
.php_cs.cache
6+
.phpunit.result.cache
7+
phpunit.xml

‎.php_cs.dist‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__.'\src')
5+
->in(__DIR__.'\tests')
6+
;
7+
8+
return PhpCsFixer\Config::create()
9+
->setIndent("\t")
10+
->setLineEnding("\r\n")
11+
->setRules([
12+
'array_syntax' => ['syntax' => 'short'],
13+
'blank_line_after_namespace' => true,
14+
'blank_line_after_opening_tag' => true,
15+
'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'die', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'return', 'switch', 'throw', 'try', 'while', 'yield']],
16+
'combine_consecutive_issets' => true,
17+
'combine_consecutive_unsets' => true,
18+
'concat_space' => ['spacing' => 'one'],
19+
'declare_equal_normalize' => ['space' => 'single'],
20+
'dir_constant' => true,
21+
'elseif' => true,
22+
'ereg_to_preg' => true,
23+
'explicit_indirect_variable' => true,
24+
'explicit_string_variable' => true,
25+
'full_opening_tag' => true,
26+
'function_typehint_space' => true,
27+
'is_null' => true,
28+
'linebreak_after_opening_tag' => true,
29+
'list_syntax' => ['syntax' => 'short'],
30+
'logical_operators' => true,
31+
'lowercase_cast' => true,
32+
'lowercase_constants' => true,
33+
'lowercase_keywords' => true,
34+
'lowercase_static_reference' => true,
35+
'magic_constant_casing' => true,
36+
'magic_method_casing' => true,
37+
'method_chaining_indentation' => true,
38+
'modernize_types_casting' => true,
39+
'native_function_casing' => true,
40+
'native_function_invocation' => [],
41+
'new_with_braces' => true,
42+
'no_alias_functions' => ['sets' => ['@all']],
43+
'no_alternative_syntax' => true,
44+
'no_blank_lines_after_phpdoc' => true,
45+
'no_break_comment' => ['comment_text' => 'Intentionally fall through'],
46+
'no_closing_tag' => true,
47+
'no_empty_comment' => true,
48+
'no_empty_statement' => true,
49+
'no_leading_namespace_whitespace' => true,
50+
'no_spaces_inside_parenthesis' => true,
51+
'no_superfluous_phpdoc_tags' => true,
52+
'no_trailing_whitespace' => true,
53+
'no_trailing_whitespace_in_comment' => true,
54+
'no_unneeded_control_parentheses' => true,
55+
'no_unneeded_final_method' => true,
56+
'no_unreachable_default_argument_value' => true,
57+
'no_unset_cast' => true,
58+
'no_useless_return' => true,
59+
'no_whitespace_before_comma_in_array' => true,
60+
'no_whitespace_in_blank_line' => true,
61+
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
62+
'normalize_index_brace' => true,
63+
'not_operator_with_successor_space' => true,
64+
'ordered_class_elements' => ['sortAlgorithm' => 'alpha',],
65+
'protected_to_private' => true,
66+
'psr0' => true,
67+
'return_type_declaration' => ['space_before' => 'one',],
68+
'semicolon_after_instruction' => true,
69+
'set_type_to_cast' => true,
70+
'short_scalar_cast' => true,
71+
'simple_to_complex_string_variable' => true,
72+
'simplified_null_return' => true,
73+
'single_blank_line_at_eof' => true,
74+
'single_blank_line_before_namespace' => true,
75+
'single_import_per_statement' => true,
76+
'single_line_after_imports' => true,
77+
'single_line_comment_style' => true,
78+
'single_quote' => true,
79+
'single_trait_insert_per_statement' => true,
80+
'standardize_not_equals' => true,
81+
'switch_case_semicolon_to_colon' => true,
82+
'switch_case_space' => true,
83+
'ternary_to_null_coalescing' => true,
84+
'void_return' => true,
85+
'yoda_style' => true,
86+
// 'braces' => ['position_after_control_structures' => 'next', 'position_after_functions_and_oop_constructs' => 'next', 'position_after_anonymous_constructs' => 'next',],
87+
// 'no_unneeded_curly_braces' => true,
88+
])
89+
->setFinder($finder)
90+
;
91+

‎.travis.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
- 7.2
6+
- 7.3
7+
- 7.4
8+
9+
before_script:
10+
- wget http://getcomposer.org/composer.phar
11+
- php composer.phar install

‎CODE_OF_CONDUCT.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project owner. They will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Bruce Wells
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PHPUnitSyntaxCoverage [![Build Status](https://travis-ci.org/phpfui/PHPUnitSyntaxCoverage.png?branch=master)](https://travis-ci.org/phpfui/PHPUnitSyntaxCoverage) [![Latest Packagist release](https://img.shields.io/packagist/v/phpfui/PHPUnitSyntaxCoverage.svg)](https://packagist.org/packages/phpfui/PHPUnitSyntaxCoverage)
2+
3+
## PHPUnit Extension for complete PHP Syntax Code Coverage
4+
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+
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.
8+
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+
11+
# Requirements
12+
- PHP 7.1 or higher
13+
- PHPUnit 7 or higher
14+
15+
## Installation
16+
```
17+
composer require phpfui/phpunit-syntax-coverage
18+
```
19+
20+
## Usage
21+
Extend your unit tests from \PHPFUI\PHPUnitSyntaxCoverage\Extensions
22+
```php
23+
class UnitTest extends \PHPFUI\PHPUnitSyntaxCoverage\Extensions
24+
{
25+
public function testValidPHP()
26+
{
27+
$this->assertValidPHPFile(__FILE__, 'Unit Test file not valid');
28+
$this->assertValidPHP('<?php echo "hi";');
29+
}
30+
}
31+
```
32+
You can use any of the following asserts:
33+
- assertValidPHP(string $code, string $message = '')
34+
- assertValidPHPDirectory(string $directory, string $message = '', bool $recurseSubdirectories = true, array $extensions = ['.php'])
35+
- assertValidPHPFile(string $fileName, string $message = '')
36+
37+
## Directory Testing
38+
Instead of file by file testing, use **assertValidPHPDirectory** to test an entire directory. Any files added to the directory will be automatically tested.
39+
```php
40+
$this->assertValidPHPDirectory(__DIR__ . '/../App', 'App directory error');
41+
```
42+
The error message will include the offending file name and line number.
43+
44+
## Examples
45+
See [examples](https://github.com/phpfui/PHPUnitSyntaxCoverage/blob/master/tests/UnitTest.php)
46+
47+
## Documentation
48+
49+
Full documentation at [PHPFUI\PHPUnitSyntaxCoverage](http://phpfui.com/?p=d&n=PHPFUI%5CPHPUnitSyntaxCoverage)

‎composer.json‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "phpfui/phpunit-syntax-coverage",
3+
"description": "PHPUnit Testing extensions for complete syntax checking of all files and classes in your project",
4+
"minimum-stability": "stable",
5+
"keywords": ["PHPUnit","coverage","syntax","code","test","testing","validation", "code coverage"],
6+
"homepage": "https://github.com/phpfui/PHPUnitSyntaxCoverage",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Bruce Wells",
11+
"email": "brucekwells@gmail.com"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.1"
16+
},
17+
"require-dev": {
18+
"nikic/php-parser": "^4.8",
19+
"phpunit/phpunit": "^7.0|^8.0|>=9.0"
20+
},
21+
"autoload": {
22+
"psr-0": {
23+
"PHPFUI": "src/",
24+
"badPHP": "tests/"
25+
}
26+
}
27+
}

‎phpunit.xml.dist‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
bootstrap="./tests/bootstrap.php"
12+
>
13+
14+
<testsuites>
15+
<testsuite name="PHPFUI PHPUnit Syntax Coverage tests">
16+
<directory>./tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the PHPFUI/PHPUnitSyntaxCoverage package
5+
*
6+
* (c) Bruce Wells
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE.md file that was distributed with this source
10+
* code
11+
*/
12+
13+
namespace PHPFUI\PHPUnitSyntaxCoverage;
14+
15+
class Exception extends \Exception
16+
{
17+
}

0 commit comments

Comments
 (0)