Created
April 20, 2017 12:38
-
-
Save Garbee/9f0b209698a28f2004e28ba993d50fa1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
return PhpCsFixer\Config::create() | |
->setRiskyAllowed(true) | |
->setRules([ | |
'@PSR2' => true, | |
'array_syntax' => ['syntax' => 'short'], | |
'binary_operator_spaces' => [ | |
'align_double_arrow' => true, | |
'align_equals' => true, | |
], | |
'combine_consecutive_unsets' => true, | |
// one should use PHPUnit methods to set up expected exception | |
'general_phpdoc_annotation_remove' => [ | |
'expectedException', | |
'expectedExceptionMessage', | |
'expectedExceptionMessageRegExp', | |
], | |
'heredoc_to_nowdoc' => true, | |
'linebreak_after_opening_tag' => true, | |
'lowercase_cast' => true, | |
'lowercase_constants' => true, | |
'mb_str_functions' => true, | |
'method_separation' => true, | |
'modernize_types_casting' => true, | |
'native_function_casing' => true, | |
'new_with_braces' => true, | |
'no_blank_lines_after_class_opening' => true, | |
'no_blank_lines_after_phpdoc' => true, | |
'no_empty_comment' => true, | |
'no_empty_phpdoc' => true, | |
'no_empty_statement' => true, | |
'no_extra_consecutive_blank_lines' => [ | |
'break', | |
'continue', | |
'extra', | |
'return', | |
'throw', | |
'use', | |
'parenthesis_brace_block', | |
'square_brace_block', | |
'curly_brace_block', | |
], | |
'no_leading_namespace_whitespace' => true, | |
'no_php4_constructor' => true, | |
'no_short_echo_tag' => true, | |
'no_unreachable_default_argument_value' => true, | |
'no_useless_else' => true, | |
'no_useless_return' => true, | |
'ordered_class_elements' => [ | |
'use_trait', | |
'constant_public', | |
'constant_protected', | |
'constant_private', | |
'property_public', | |
'property_protected', | |
'property_private', | |
'construct', | |
'destruct', | |
'magic', | |
'phpunit', | |
'method_public', | |
'method_protected', | |
'method_private', | |
], | |
'ordered_imports' => [ | |
'sortAlgorithm' => 'length', | |
], | |
'php_unit_strict' => true, | |
'php_unit_construct' => true, | |
'php_unit_dedicate_assert' => true, | |
'phpdoc_no_empty_return' => true, | |
'phpdoc_no_package' => true, | |
'phpdoc_scalar' => true, | |
'phpdoc_types' => true, | |
'phpdoc_order' => true, | |
'pow_to_exponentiation' => true, | |
'random_api_migration' => true, | |
'return_type_declaration' => [ | |
'space_before' => 'none', | |
], | |
'semicolon_after_instruction' => true, | |
'short_scalar_cast' => true, | |
'single_quote' => true, | |
'space_after_semicolon' => true, | |
'standardize_not_equals' => true, | |
'strict_comparison' => true, | |
'strict_param' => true, | |
'ternary_to_null_coalescing' => true, | |
'trailing_comma_in_multiline_array' => true, | |
]) | |
->setFinder( | |
PhpCsFixer\Finder::create() | |
->exclude('tests/Fixtures') | |
->exclude('bootstrap/cache') | |
->exclude('storage') | |
->exclude('vendor') | |
->in(__DIR__) | |
); |
This file contains hidden or 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
{ | |
"scripts": { | |
"pre-install-cmd": [ | |
"php -r \"file_exists('.env') || copy('.env.example', '.env');\"" | |
], | |
"post-create-project-cmd": [ | |
"php artisan key:generate" | |
], | |
"post-install-cmd": [ | |
"Illuminate\\Foundation\\ComposerScripts::postInstall", | |
"php artisan optimize" | |
], | |
"post-update-cmd": [ | |
"Illuminate\\Foundation\\ComposerScripts::postUpdate", | |
"php artisan optimize" | |
], | |
"phinx": "phinx", | |
"db:reset": [ | |
"@composer phinx rollback -- -t 0", | |
"@composer phinx migrate", | |
"php artisan db:seed" | |
], | |
"phpstan": [ | |
"phpstan analyze app -c phpstan.neon --no-progress", | |
"phpstan analyze bootstrap -c phpstan.neon --no-progress", | |
"phpstan analyze database/migrations -c phpstan.neon --no-progress", | |
"phpstan analyze database/seeds -c phpstan.neon --no-progress", | |
"phpstan analyze tests -c phpstan.neon --no-progress" | |
], | |
"phpunit": [ | |
"phpunit --colors=always" | |
], | |
"phpmd": "phpmd app,config html phpmd.xml --reportfile storage/build/phpmd.html", | |
"phpcs": "phpcs --standard=phpcs.xml", | |
"test": [ | |
"@phpcs", | |
"phpmd app,config text phpmd.xml", | |
"@twig-lint", | |
"@phpstan", | |
"phpunit --coverage-text --colors=never" | |
], | |
"twig-lint": "php artisan twig:lint" | |
}, | |
} |
This file contains hidden or 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
<?xml version="1.0"?> | |
<ruleset name="MyStandard"> | |
<description>Project Coding Standard</description> | |
<file>app</file> | |
<file>bootstrap</file> | |
<file>database</file> | |
<file>tests</file> | |
<!-- Full PSR2 to start --> | |
<rule ref="PSR2" /> | |
<!-- Add check for code being commended out. --> | |
<rule ref="Squiz.PHP.CommentedOutCode"> | |
<!-- Config files are OK to have things commented out that are code. --> | |
<exclude-pattern>config/*</exclude-pattern> | |
</rule> | |
<!-- | |
Don't allow things like `$x = $y = 4`. | |
--> | |
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/> | |
<!-- | |
Avoid code that causes excessive processing. | |
For example: | |
for($i = 0; $i < count($something); $++) {} | |
--> | |
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/> | |
<rule ref="Generic.PHP.ForbiddenFunctions"> | |
<properties> | |
<!-- | |
Use echo vs print, | |
Don't use create_function at all, | |
Don't commit var_dump ever. | |
--> | |
<property name="forbiddenFunctions" type="array" | |
value="print=>echo,create_function=>null,var_dump=>null,eval=>null" /> | |
<property name="error" value="true"/> | |
</properties> | |
</rule> | |
<rule ref="Generic.NamingConventions.ConstructorName"/> | |
<rule ref="Generic.PHP.DeprecatedFunctions"/> | |
<rule ref="Generic.Formatting.SpaceAfterCast"/> | |
<rule ref="Generic.Files.LineLength"> | |
<properties> | |
<property name="lineLimit" value="80"/> | |
<property name="absoluteLineLimit" value="120"/> | |
</properties> | |
<exclude-pattern>tests/*/*</exclude-pattern> | |
</rule> | |
<rule ref="Generic.Files.LineEndings"/> | |
<rule ref="Generic.Files.ByteOrderMark"/> | |
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/> | |
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/> | |
<rule ref="Generic.CodeAnalysis.EmptyStatement"/> | |
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/> | |
<rule ref="Generic.PHP.NoSilencedErrors"> | |
<properties> | |
<property name="error" value="false" /> | |
</properties> | |
</rule> | |
<rule ref="Generic.Strings.UnnecessaryStringConcat"> | |
<properties> | |
<property name="allowMultiline" value="true" /> | |
</properties> | |
</rule> | |
<rule ref="Generic.Functions.CallTimePassByReference"/> | |
<rule ref="Squiz.PHP.GlobalKeyword"/> | |
<rule ref="Squiz.PHP.LowercasePHPFunctions"/> | |
<rule ref="Squiz.PHP.NonExecutableCode"/> | |
<rule ref="Squiz.Scope.StaticThisUsage"/> | |
<!-- | |
We don't want to check the services file. | |
This is generated by the framework. | |
--> | |
<exclude-pattern>bootstrap/cache/services.php</exclude-pattern> | |
<rule ref="PSR1.Classes.ClassDeclaration"> | |
<!-- | |
Classes in the database folder break if put under namespaces. | |
--> | |
<exclude-pattern>database/*</exclude-pattern> | |
</rule> | |
<rule ref="PSR1.Files.SideEffects"> | |
<!-- | |
This file is built to have multiple effects by the framework. | |
Just ignore it and avoid needing to refactor things to work by modifying it. | |
--> | |
<exclude-pattern>bootstrap/autoload.php</exclude-pattern> | |
</rule> | |
</ruleset> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<ruleset name="project-phpmd" | |
xmlns="http://pmd.sf.net/ruleset/1.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" | |
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> | |
<description> | |
</description> | |
<rule ref="rulesets/codesize.xml/CyclomaticComplexity"> | |
<properties> | |
<property name="reportLevel" value="4"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/NPathComplexity"> | |
<properties> | |
<property name="minimum" value="50"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/> | |
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"> | |
<properties> | |
<property name="minimum" value="400"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"> | |
<properties> | |
<property name="minimum" value="5"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"> | |
<properties> | |
<property name="minimum" value="25"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/TooManyFields"> | |
<properties> | |
<property name="maxfields" value="10"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/TooManyMethods"> | |
<properties> | |
<property name="maxmethods" value="12"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity"> | |
<properties> | |
<property name="maximum" value="49"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/controversial.xml"/> | |
<rule ref="rulesets/design.xml/ExitExpression"/> | |
<rule ref="rulesets/design.xml/EvalExpression"/> | |
<rule ref="rulesets/design.xml/GotoStatement"/> | |
<rule ref="rulesets/design.xml/DepthOfInheritance"/> | |
<rule ref="rulesets/design.xml/CouplingBetweenObjects"> | |
<properties> | |
<property name="minimum" value="12"/> | |
</properties> | |
</rule> | |
<rule ref="rulesets/unusedcode.xml"/> | |
<exclude-pattern>app/macros.php</exclude-pattern> | |
</ruleset> |
This file contains hidden or 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
includes: | |
- vendor/phpstan/phpstan/conf/config.level5.neon | |
parameters: | |
reportUnmatchedIgnoredErrors: false | |
checkFunctionArgumentTypes: true | |
enableUnionTypes: true | |
excludes_analyse: | |
- app/macros.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment