Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
feat : Updated localheinz/php-cs-fixer-config to v1.19 and added php …
Browse files Browse the repository at this point in the history
…7.3 to travis
  • Loading branch information
danielb authored and prisis committed Jan 7, 2019
1 parent 0649695 commit 4d2da42
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dist: trusty
sudo: required
language: php

env:
Expand Down Expand Up @@ -30,23 +28,26 @@ jobs:
- stage: Test
php: 7.2
env: REMOVE_XDEBUG=true
- stage: Test
php: 7.3
env: REMOVE_XDEBUG=true

- stage: Coding standard
if: type != cron
php: 7.2
php: 7.3
env: REMOVE_XDEBUG=true
script:
- ./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
- stage: Coding standard
if: type != cron
php: 7.2
php: 7.3
env: REMOVE_XDEBUG=false
script:
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src

- stage: Coverage
if: type != cron
php: 7.2
php: 7.3
env: REMOVE_XDEBUG=false
script:
- bash -xc "$TEST -c ./phpunit.xml.dist --coverage-clover=coverage.xml"
Expand All @@ -56,4 +57,4 @@ jobs:
notifications:
email:
on_success: never
on_failure: change
on_failure: change
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
],
"require": {
"php": "^7.1",
"localheinz/php-cs-fixer-config": "1.15.*",
"localheinz/php-cs-fixer-config": "1.19.*",
"pedrotroller/php-cs-custom-fixer": "^2.15.2"
},
"require-dev": {
"phpstan/phpstan": "^0.10.5",
"phpstan/phpstan-deprecation-rules": "^0.10.5",
"phpstan/phpstan-phpunit": "^0.10.5",
"phpstan/phpstan-strict-rules": "^0.10.5",
"phpunit/phpunit": "^7.2.0"
"phpstan/phpstan": "^0.10.7",
"phpstan/phpstan-deprecation-rules": "^0.10.2",
"phpstan/phpstan-phpunit": "^0.10.0",
"phpstan/phpstan-strict-rules": "^0.10.1",
"phpunit/phpunit": "^7.4.0"
},
"config": {
"sort-packages": true
Expand Down
52 changes: 33 additions & 19 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ final class ConfigTest extends TestCase
{
public function testImplementsInterface(): void
{
$this->assertInstanceOf(ConfigInterface::class, new Config());
self::assertInstanceOf(ConfigInterface::class, new Config());
}

public function testValues(): void
{
$config = new Config();

$this->assertSame('narrowspark', $config->getName());
self::assertSame('narrowspark', $config->getName());
}

public function testHasPsr2Rules(): void
Expand Down Expand Up @@ -61,26 +61,27 @@ public function testIfAllRulesAreTested(): void
$this->getContribRules(),
$this->getSymfonyRules(),
$this->getPhp71Rules(),
$this->getPhp73Rules(),
$this->getPHPUnitRules(),
$this->getPedroTrollerRules()
);
$rules = (new Config())->getRules();

foreach ($rules as $key => $value) {
$this->assertTrue(isset($testRules[$key]), '[' . $key . '] Rule is missing.');
self::assertTrue(isset($testRules[$key]), '[' . $key . '] Rule is missing.');
}

$this->assertCount(\count($testRules), $rules);
self::assertCount(\count($testRules), $rules);
}

public function testDoesNotHaveHeaderCommentFixerByDefault(): void
{
$rules = (new Config())->getRules();

$this->assertArrayHasKey('header_comment', $rules);
$this->assertFalse($rules['header_comment']);
$this->assertTrue($rules['no_blank_lines_before_namespace']);
$this->assertFalse($rules['single_blank_line_before_namespace']);
self::assertArrayHasKey('header_comment', $rules);
self::assertFalse($rules['header_comment']);
self::assertTrue($rules['no_blank_lines_before_namespace']);
self::assertFalse($rules['single_blank_line_before_namespace']);
}

public function testHasHeaderCommentFixerIfProvided(): void
Expand All @@ -89,17 +90,17 @@ public function testHasHeaderCommentFixerIfProvided(): void
$config = new Config($header);
$rules = $config->getRules();

$this->assertArrayHasKey('header_comment', $rules);
self::assertArrayHasKey('header_comment', $rules);

$expected = [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_declare_strict',
'separate' => 'both',
];
$this->assertSame($expected, $rules['header_comment']);
$this->assertTrue($rules['no_blank_lines_before_namespace']);
$this->assertFalse($rules['single_blank_line_before_namespace']);
self::assertSame($expected, $rules['header_comment']);
self::assertTrue($rules['no_blank_lines_before_namespace']);
self::assertFalse($rules['single_blank_line_before_namespace']);
}

public function testAllConfiguredRulesAreBuiltIn(): void
Expand All @@ -119,7 +120,7 @@ public function testAllConfiguredRulesAreBuiltIn(): void
\array_merge($this->builtInFixers(), $pedroTrollerRules)
);

$this->assertEmpty($fixersNotBuiltIn, \sprintf(
self::assertEmpty($fixersNotBuiltIn, \sprintf(
'Failed to assert that fixers for the rules "%s" are built in',
\implode('", "', $fixersNotBuiltIn)
));
Expand All @@ -139,13 +140,13 @@ public function testDoesNotHaveRulesEnabled(string $fixer, $reason): void
];

if ($fixer === 'array_syntax') {
$this->assertNotSame(['syntax' => 'long'], $config->getRules()['array_syntax'], \sprintf(
self::assertNotSame(['syntax' => 'long'], $config->getRules()['array_syntax'], \sprintf(
'Fixer "%s" should not be enabled, because "%s"',
$fixer,
$reason['long']
));
} else {
$this->assertArraySubset($rule, $config->getRules(), true, \sprintf(
self::assertArraySubset($rule, $config->getRules(), true, \sprintf(
'Fixer "%s" should not be enabled, because "%s"',
$fixer,
$reason
Expand Down Expand Up @@ -216,6 +217,13 @@ public function getPhp71Rules(): array
];
}

public function getPhp73Rules(): array
{
return [
'heredoc_indentation' => true,
];
}

/**
* @return array
*/
Expand Down Expand Up @@ -281,7 +289,7 @@ protected function getContribRules(): array
'ensure_fully_multiline' => true,
'keep_multiple_spaces_after_comma' => false,
],
'static_lambda' => false,
'static_lambda' => true,
'string_line_ending' => true,
'method_chaining_indentation' => true,
'modernize_types_casting' => true,
Expand All @@ -298,10 +306,12 @@ protected function getContribRules(): array
'no_useless_return' => true,
'no_superfluous_elseif' => true,
'phpdoc_to_return_type' => true,
'phpdoc_var_annotation_correct_order' => true,
'no_superfluous_phpdoc_tags' => false,
'not_operator_with_space' => false,
'not_operator_with_successor_space' => true,
'no_homoglyph_names' => false,
'no_unset_cast' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => false,
Expand Down Expand Up @@ -388,9 +398,13 @@ private function getSymfonyRules(): array
'break',
'continue',
'declare',
'default',
'die',
'do',
'exit',
'for',
'foreach',
'goto',
'if',
'include',
'include_once',
Expand Down Expand Up @@ -548,12 +562,12 @@ private function getSymfonyRules(): array
private function assertHasRules(array $expected, array $actual, string $set): void
{
foreach ($expected as $fixer => $isEnabled) {
$this->assertArrayHasKey($fixer, $actual, \sprintf(
self::assertArrayHasKey($fixer, $actual, \sprintf(
'Failed to assert that a rule for fixer "%s" (in set "%s") exists.,',
$fixer,
$set
));
$this->assertSame($isEnabled, $actual[$fixer], \sprintf(
self::assertSame($isEnabled, $actual[$fixer], \sprintf(
'Failed to assert that fixer "%s" (in set "%s") is %s.',
$fixer,
$set,
Expand All @@ -574,7 +588,7 @@ private function configuredFixers(): array
*
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/2361
*/
$rules = \array_map(function () {
$rules = \array_map(static function () {
return true;
}, $config->getRules());

Expand Down

0 comments on commit 4d2da42

Please sign in to comment.