Skip to content

Commit

Permalink
Use kubawerlos/php-cs-fixer-config
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed May 3, 2020
1 parent 259af3a commit e462418
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 143 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# types checker
# Types checker

[![Latest Stable Version](https://img.shields.io/packagist/v/kubawerlos/types-checker.svg)](https://packagist.org/packages/kubawerlos/types-checker)
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/types-checker.svg)](https://php.net)
Expand Down
149 changes: 11 additions & 138 deletions dev-tools/.php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

declare(strict_types=1);

return PhpCsFixer\Config::create()
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
->setRiskyAllowed(true)
/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

return PhpCsFixerConfig\Factory::createForLibrary('Types checker')
->setUsingCache(false)
->setFinder(
PhpCsFixer\Finder::create()
Expand All @@ -16,138 +23,4 @@ return PhpCsFixer\Config::create()
__FILE__,
__DIR__ . '/../types-checker',
])
)
->setRules([
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => true,
'class_attributes_separation' => ['elements' => ['method', 'property']],
'class_definition' => [
'multiLineExtendsEachSingleLine' => true,
'singleItemSingleLine' => true,
],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'comment_to_phpdoc' => true,
'compact_nullable_typehint' => true,
'concat_space' => [
'spacing' => 'one',
],
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'final_class' => true,
'final_internal_class' => true,
'final_public_method_for_abstract_class' => true,
'final_static_access' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => [
'functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi'],
],
'heredoc_to_nowdoc' => true,
'increment_style' => [
'style' => 'post',
],
'linebreak_after_opening_tag' => true,
'list_syntax' => [
'syntax' => 'long',
],
'logical_operators' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
],
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_function_invocation' => [
'include' => ['@all'],
],
'no_alternative_syntax' => true,
'no_binary_string' => true,
'no_extra_blank_lines' => [
'tokens' => [
'continue',
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'throw',
'use',
'use_trait',
],
],
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_superfluous_elseif' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => [
'sortAlgorithm' => 'alpha',
],
'php_unit_internal_class' => true,
'php_unit_ordered_covers' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_strict' => true,
'php_unit_test_annotation' => true,
'php_unit_test_case_static_method_calls' => true,
'php_unit_test_class_requires_covers' => true,
'phpdoc_line_span' => ['property' => 'single'],
'phpdoc_order' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types_order' => true,
'return_assignment' => true,
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'string_line_ending' => true,
'unary_operator_spaces' => false,
'visibility_required' => [
'elements' => [
'const',
'property',
'method',
],
],
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
] + \array_reduce(
\iterator_to_array(new PhpCsFixerCustomFixers\Fixers()),
static function (array $carry, PhpCsFixer\Fixer\DefinedFixerInterface $fixer): array {
if (!$fixer instanceof PhpCsFixer\Fixer\DeprecatedFixerInterface) {
$carry[$fixer->getName()] = true;
}

if ($fixer instanceof PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer) {
$carry[$fixer->getName()] = ['elements' => [
'covers',
'coversNothing',
'dataProvider',
'deprecated',
'internal',
'param',
'requires',
'return',
'var',
]];
}

return $carry;
},
[]
));
);
3 changes: 2 additions & 1 deletion dev-tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"phpstan/phpstan": "^0.12.19",
"phpstan/phpstan-strict-rules": "^0.12.2",
"squizlabs/php_codesniffer": "^3.5.5",
"vimeo/psalm": "^3.11.2"
"vimeo/psalm": "^3.11.2",
"kubawerlos/php-cs-fixer-config": "dev-master"
},
"scripts": {
"analyse": [
Expand Down
47 changes: 45 additions & 2 deletions dev-tools/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker;

use TypesChecker\Report\Report;
Expand Down
9 changes: 9 additions & 0 deletions src/ClassCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker;

use Symfony\Component\Finder\Finder;
Expand Down
9 changes: 9 additions & 0 deletions src/Command/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker\Command;

use Symfony\Component\Console\Command\Command as BaseCommand;
Expand Down
9 changes: 9 additions & 0 deletions src/Report/ClassReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker\Report;

final class ClassReport
Expand Down
9 changes: 9 additions & 0 deletions src/Report/MethodReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker\Report;

final class MethodReport
Expand Down
9 changes: 9 additions & 0 deletions src/Report/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace TypesChecker\Report;

final class Report
Expand Down
9 changes: 9 additions & 0 deletions tests/CheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace Tests;

use PHPUnit\Framework\TestCase;
Expand Down
9 changes: 9 additions & 0 deletions tests/ClassCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace Tests;

use PHPUnit\Framework\TestCase;
Expand Down
11 changes: 10 additions & 1 deletion tests/Command/CheckCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of Types checker.
*
* (c) Kuba Werłos <werlos@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace Tests\Command;

use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -51,7 +60,7 @@ public function testRunWithInvalidAutoloader(): void
public function testRunWithUnknownClass(): void
{
$this->expectException(\Error::class);
$this->expectErrorMessage("Class 'HiddenPlace\UnknownClass' not found");
$this->expectErrorMessage("Class 'HiddenPlace\\UnknownClass' not found");

$this->tester->run([
'path' => [__DIR__ . '/../_stubs/ExtendingUnknownClass.php'],
Expand Down

0 comments on commit e462418

Please sign in to comment.