-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added phan, php-cs-fixer and bug fixes
- Loading branch information
1 parent
05d34de
commit 4e29a24
Showing
30 changed files
with
751 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
.DS_Store | ||
*~ | ||
*.sw[aop] | ||
.php-cs-fixer.cache | ||
.phpunit.result.cache | ||
|
||
# Deployment dependencies | ||
vendor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
use \Phan\Config; | ||
|
||
/** | ||
* This configuration will be read and overlayed on top of the | ||
* default configuration. Command line arguments will be applied | ||
* after this file is read. | ||
* | ||
* @see src/Phan/Config.php | ||
* See Config for all configurable options. | ||
* | ||
* A Note About Paths | ||
* ================== | ||
* | ||
* Files referenced from this file should be defined as | ||
* | ||
* ``` | ||
* Config::projectPath('relative_path/to/file') | ||
* ``` | ||
* | ||
* where the relative path is relative to the root of the | ||
* project which is defined as either the working directory | ||
* of the phan executable or a path passed in via the CLI | ||
* '-d' flag. | ||
*/ | ||
return [ | ||
// If true, missing properties will be created when | ||
// they are first seen. If false, we'll report an | ||
// error message. | ||
"allow_missing_properties" => true, | ||
|
||
// Allow null to be cast as any type and for any | ||
// type to be cast to null. | ||
"null_casts_as_any_type" => true, | ||
|
||
// If this has entries, scalars (int, float, bool, string, null) | ||
// are allowed to perform the casts listed. | ||
// E.g. ['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']] | ||
// allows casting null to a string, but not vice versa. | ||
// (subset of scalar_implicit_cast) | ||
'scalar_implicit_partial' => [ | ||
'int' => ['float', 'string'], | ||
'float' => ['int'], | ||
'string' => ['int'], | ||
'null' => ['string', 'bool'], | ||
'bool' => ['null'], | ||
], | ||
|
||
// Backwards Compatibility Checking | ||
'backward_compatibility_checks' => false, | ||
|
||
// Run a quick version of checks that takes less | ||
// time | ||
"quick_mode" => true, | ||
|
||
// Only emit critical issues | ||
"minimum_severity" => 0, | ||
|
||
// A set of fully qualified class-names for which | ||
// a call to parent::__construct() is required | ||
'parent_constructor_required' => [ | ||
], | ||
|
||
// Add any issue types (such as 'PhanUndeclaredMethod') | ||
// here to inhibit them from being reported | ||
'suppress_issue_types' => [ | ||
// These report false positives in libraries due | ||
// to them not being used by any of the other | ||
// library code. | ||
'PhanUnreferencedPublicClassConstant', | ||
'PhanWriteOnlyProtectedProperty', | ||
'PhanUnreferencedPublicMethod', | ||
'PhanUnreferencedUseNormal', | ||
'PhanUnreferencedProtectedMethod', | ||
'PhanUnreferencedProtectedProperty', | ||
|
||
], | ||
|
||
// A list of directories that should be parsed for class and | ||
// method information. After excluding the directories | ||
// defined in exclude_analysis_directory_list, the remaining | ||
// files will be statically analyzed for errors. | ||
// | ||
// Thus, both first-party and third-party code being used by | ||
// your application should be included in this list. | ||
'directory_list' => [ | ||
'src', | ||
'vendor', | ||
'tests', | ||
], | ||
|
||
// A list of directories holding code that we want | ||
// to parse, but not analyze | ||
"exclude_analysis_directory_list" => [ | ||
"vendor", | ||
"tests", | ||
], | ||
|
||
// A file list that defines files that will be excluded | ||
// from parsing and analysis and will not be read at all. | ||
// | ||
// This is useful for excluding hopelessly unanalyzable | ||
// files that can't be removed for whatever reason. | ||
'exclude_file_list' => [ | ||
], | ||
|
||
// Set to true in order to attempt to detect dead | ||
// (unreferenced) code. Keep in mind that the | ||
// results will only be a guess given that classes, | ||
// properties, constants and methods can be referenced | ||
// as variables (like `$class->$property` or | ||
// `$class->$method()`) in ways that we're unable | ||
// to make sense of. | ||
'dead_code_detection' => true, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
$finder = (new PhpCsFixer\Finder()) | ||
->in(__DIR__) | ||
; | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'array_syntax' => [ | ||
'syntax' => 'short', | ||
], | ||
'binary_operator_spaces' => [ | ||
'default' => 'align_single_space', | ||
], | ||
'blank_line_after_opening_tag' => true, | ||
'blank_line_before_statement' => ['statements' => ['return']], | ||
'braces_position' => [ | ||
'allow_single_line_anonymous_functions' => true, | ||
'allow_single_line_empty_anonymous_classes' => true, | ||
'anonymous_classes_opening_brace' => 'same_line', | ||
'anonymous_functions_opening_brace' => 'same_line', | ||
'classes_opening_brace' => 'same_line', | ||
'control_structures_opening_brace' => 'same_line', | ||
'functions_opening_brace' => 'same_line', | ||
], | ||
'combine_consecutive_unsets' => true, | ||
'concat_space' => [ | ||
'spacing' => 'one', | ||
], | ||
'declare_equal_normalize' => true, | ||
'escape_implicit_backslashes' => [ | ||
'single_quoted' => true, | ||
'double_quoted' => true, | ||
], | ||
'function_typehint_space' => true, | ||
'include' => true, | ||
'lowercase_cast' => true, | ||
// 'class_attributes_separation' => ['elements' => ['method']], | ||
'native_function_casing' => true, | ||
'no_blank_lines_after_phpdoc' => true, | ||
'no_empty_comment' => true, | ||
'no_empty_statement' => true, | ||
'no_mixed_echo_print' => [ | ||
'use' => 'echo', | ||
], | ||
'no_multiline_whitespace_around_double_arrow' => true, | ||
'multiline_whitespace_before_semicolons' => false, | ||
'no_short_bool_cast' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'no_spaces_around_offset' => true, | ||
'no_unused_imports' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'object_operator_without_whitespace' => true, | ||
'ordered_imports' => true, | ||
'short_scalar_cast' => true, | ||
'single_blank_line_before_namespace' => true, | ||
'single_quote' => true, | ||
'space_after_semicolon' => true, | ||
'ternary_operator_spaces' => true, | ||
'trailing_comma_in_multiline' => ['elements' => ['arrays']], | ||
'trim_array_spaces' => true, | ||
'unary_operator_spaces' => true, | ||
'whitespace_after_comma_in_array' => true, | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,19 @@ | |
"type": "library", | ||
"description": "Type constraint checking library", | ||
"license": "BSD-3-Clause", | ||
"authors": [ | ||
{ | ||
"name": "Brian Moon", | ||
"email": "[email protected]", | ||
"homepage": "https://www.dealnews.com/", | ||
"role": "Developer" | ||
} | ||
], | ||
"config": { | ||
"optimize-autoloader": true, | ||
"discard-changes": true, | ||
"sort-packages": true | ||
}, | ||
"require": { | ||
"php": ">=7.1.0" | ||
"ext-mbstring": "*", | ||
"php": "^8.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.38", | ||
"php-parallel-lint/php-parallel-lint": "^1.3", | ||
"phpunit/phpunit": "^9.6" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
|
@@ -24,7 +27,19 @@ | |
"DealNews\\Constraints\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5" | ||
"scripts": { | ||
"phan": [ | ||
"docker run --rm -e PHAN_DISABLE_XDEBUG_WARN=1 -v `pwd`:/mnt/src -w /mnt/src phanphp/phan:5 -p" | ||
], | ||
"test": [ | ||
"parallel-lint src/ tests/", | ||
"phpunit --colors=never" | ||
], | ||
"lint": [ | ||
"parallel-lint src/ tests/" | ||
], | ||
"fix": [ | ||
"php-cs-fixer fix --config .php-cs-fixer.dist.php src tests" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./tests/bootstrap.php" | ||
colors="true"> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<groups> | ||
<exclude> | ||
<group>functional</group> | ||
</exclude> | ||
</groups> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false"> | ||
<directory suffix=".php">./src</directory> | ||
<exclude> | ||
<directory suffix=".php">./tests</directory> | ||
<directory suffix=".php">./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage includeUncoveredFiles="true" processUncoveredFiles="false"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
<exclude> | ||
<directory suffix=".php">./tests</directory> | ||
<directory suffix=".php">./vendor</directory> | ||
</exclude> | ||
<report> | ||
<text outputFile="php://stdout" showUncoveredFiles="true"/> | ||
</report> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<groups> | ||
<exclude> | ||
<group>functional</group> | ||
</exclude> | ||
</groups> | ||
</phpunit> |
Oops, something went wrong.