Skip to content

Commit

Permalink
Php 7.4 (#4)
Browse files Browse the repository at this point in the history
* Test against 7.4

* Updated PHPStan 0.12
  • Loading branch information
Slamdunk committed Dec 8, 2019
1 parent c155ca6 commit 9d54bd2
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ sudo: false
matrix:
fast_finish: true
include:
- php: 7.2
env: CS_CHECK=1 STATIC_ANALYSIS=1
- php: 7.3
env: CS_CHECK=1 STATIC_ANALYSIS=1
- php: 7.4
env: CODE_COVERAGE=1

cache:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"friendsofphp/php-cs-fixer": "^2.16"
},
"require-dev": {
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^7.5",
"roave/security-advisories": "dev-master",
"slam/php-debug-r": "^1.6",
"slam/phpstan-extensions": "^3.6",
"thecodingmachine/phpstan-strict-rules": "^0.11"
"slam/phpstan-extensions": "^4.0",
"thecodingmachine/phpstan-strict-rules": "^0.12"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 3 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ final class Config extends PhpCsFixerConfig
public const APP_V2 = 'APP_V2';
public const LIB = 'LIB';

/**
* @param array<string, mixed> $overriddenRules
*/
public function __construct(string $type = self::APP_V2, array $overriddenRules = [])
{
parent::__construct(\sprintf('%s:%s', __NAMESPACE__, $type));
Expand Down
4 changes: 4 additions & 0 deletions lib/PhpFileOnlyProxyFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

final class PhpFileOnlyProxyFixer implements ConfigurationDefinitionFixerInterface, DefinedFixerInterface, WhitespacesAwareFixerInterface
{
/**
* @var FixerInterface
*/
private $fixer;

public function __construct(FixerInterface $fixer)
Expand Down Expand Up @@ -43,6 +46,7 @@ public function getOptions()

public function resolve(array $configuration)
{
return [];
}
};
}
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- vendor/phpstan/phpstan/conf/config.levelmax.neon
- phar://phpstan.phar/conf/config.levelmax.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/slam/phpstan-extensions/conf/slam-rules.neon
- vendor/slam/phpstan-extensions/conf/thecodingmachine-rules.neon
Expand All @@ -10,3 +10,5 @@ parameters:
- tests/
ignoreErrors:
- '#Parameter .+ given#'
- '#Method .+ has no return typehint specified#'
- '#Method .+ has parameter .+ with no value type specified in iterable type array#'
11 changes: 6 additions & 5 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
*/
final class ConfigTest extends TestCase
{
public function testConfig()
public function testConfig(): void
{
$config = new Config();

self::assertInstanceOf(ConfigInterface::class, $config);
self::assertNotEmpty($config->getCustomFixers());
}

public function testAllDefaultRulesAreSpecified()
public function testAllDefaultRulesAreSpecified(): void
{
$config = new Config();
/** @var array<string, mixed> $configRules */
$configRules = $config->getRules();
$ruleSet = new RuleSet($configRules);
$rules = $ruleSet->getRules();
Expand Down Expand Up @@ -78,7 +79,7 @@ public function testAllDefaultRulesAreSpecified()
self::assertEquals($orderedCurrentRules, $currentRules, 'Order the rules alphabetically please');
}

public function testFutureMode()
public function testFutureMode(): void
{
\putenv('PHP_CS_FIXER_FUTURE_MODE');

Expand All @@ -89,7 +90,7 @@ public function testFutureMode()
self::assertNotEmpty(\getenv('PHP_CS_FIXER_FUTURE_MODE'));
}

public function testTypes()
public function testTypes(): void
{
$rules = (new Config(Config::APP_V1))->getRules();
self::assertFalse($rules['declare_strict_types']);
Expand All @@ -106,7 +107,7 @@ public function testTypes()
self::assertSame((new Config())->getRules(), (new Config(Config::APP_V2))->getRules());
}

public function testOverwrite()
public function testOverwrite(): void
{
$rules = (new Config(Config::APP_V2))->getRules();
self::assertTrue($rules['declare_strict_types']);
Expand Down
9 changes: 6 additions & 3 deletions tests/FinalAbstractPublicFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class FinalAbstractPublicFixerTest extends AbstractFixerTestCase
{
public function testIsRisky()
public function testIsRisky(): void
{
self::assertInstanceOf(FixerDefinition::class, $this->fixer->getDefinition());
self::assertTrue($this->fixer->isRisky());
Expand All @@ -20,12 +20,15 @@ public function testIsRisky()
/**
* @dataProvider provideCases
*/
public function testFix($expected, $input = null)
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

public function provideCases()
/**
* @return string[][]
*/
public function provideCases(): array
{
$original = '
public $a1;
Expand Down
9 changes: 6 additions & 3 deletions tests/FinalInternalClassFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class FinalInternalClassFixerTest extends AbstractFixerTestCase
{
public function testIsRisky()
public function testIsRisky(): void
{
self::assertInstanceOf(FixerDefinition::class, $this->fixer->getDefinition());
self::assertTrue($this->fixer->isRisky());
Expand All @@ -20,12 +20,15 @@ public function testIsRisky()
/**
* @dataProvider provideCases
*/
public function testFix($expected, $input = null)
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

public function provideCases()
/**
* @return string[][]
*/
public function provideCases(): array
{
return [
[
Expand Down
9 changes: 6 additions & 3 deletions tests/FunctionReferenceSpaceFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
*/
final class FunctionReferenceSpaceFixerTest extends AbstractFixerTestCase
{
public function testIsRisky()
public function testIsRisky(): void
{
self::assertInstanceOf(FixerDefinition::class, $this->fixer->getDefinition());
}

/**
* @dataProvider provideCases
*/
public function testFix($expected, $input = null)
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

public function provideCases()
/**
* @return string[][]
*/
public function provideCases(): array
{
$same = function (string $content): string {
$use = $content;
Expand Down
9 changes: 6 additions & 3 deletions tests/InlineCommentSpacerFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
*/
final class InlineCommentSpacerFixerTest extends AbstractFixerTestCase
{
public function testDefinition()
public function testDefinition(): void
{
self::assertInstanceOf(FixerDefinition::class, $this->fixer->getDefinition());
}

/**
* @dataProvider provideCases
*/
public function testFix($expected, $input = null)
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

public function provideCases()
/**
* @return string[][]
*/
public function provideCases(): array
{
return [
[
Expand Down
10 changes: 5 additions & 5 deletions tests/PhpFileOnlyProxyFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class PhpFileOnlyProxyFixerTest extends TestCase
{
public function testFixerInterfaceProxy()
public function testFixerInterfaceProxy(): void
{
$fixer = $this->createMock(FixerInterface::class);

Expand Down Expand Up @@ -79,7 +79,7 @@ public function testFixerInterfaceProxy()
self::assertEmpty($proxy->getDefinition()->getCodeSamples());
}

public function testGetDefinitionIsProxied()
public function testGetDefinitionIsProxied(): void
{
$fixer = $this->createMock(DefinedFixerInterface::class);

Expand All @@ -106,7 +106,7 @@ public function testGetDefinitionIsProxied()
self::assertSame($riskyDescription, $definition->getRiskyDescription());
}

public function testConfigureIsProxied()
public function testConfigureIsProxied(): void
{
$fixer = $this->createMock(ConfigurationDefinitionFixerInterface::class);
$configuration = [\uniqid()];
Expand All @@ -122,7 +122,7 @@ public function testConfigureIsProxied()
$proxy->configure($configuration);
}

public function testGetConfigurationDefinitionIsProxied()
public function testGetConfigurationDefinitionIsProxied(): void
{
$fixer = $this->createMock(ConfigurationDefinitionFixerInterface::class);

Expand All @@ -138,7 +138,7 @@ public function testGetConfigurationDefinitionIsProxied()
self::assertSame($definition, $proxy->getConfigurationDefinition());
}

public function testSetWhitespacesConfigIsProxied()
public function testSetWhitespacesConfigIsProxied(): void
{
$fixer = $this->createMock(WhitespacesAwareFixerInterface::class);
$config = new WhitespacesFixerConfig();
Expand Down
4 changes: 2 additions & 2 deletions tests/Utf8FixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
*/
final class Utf8FixerTest extends AbstractFixerTestCase
{
public function testIsRisky()
public function testIsRisky(): void
{
self::assertInstanceOf(FixerDefinition::class, $this->fixer->getDefinition());
self::assertTrue($this->fixer->isRisky());
}

public function testFix()
public function testFix(): void
{
$expected = <<<'EOF'
1234567890
Expand Down

0 comments on commit 9d54bd2

Please sign in to comment.