Skip to content

Commit

Permalink
Update CS rules
Browse files Browse the repository at this point in the history
  • Loading branch information
HypeMC committed Aug 8, 2024
1 parent 3e26126 commit 54c67f5
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 163 deletions.
21 changes: 4 additions & 17 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Import\OrderedImportsFixer;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->append([__FILE__])
Expand All @@ -13,30 +11,19 @@
->setUsingCache(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR12' => true,
'@PHP71Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'array_indentation' => true,
'compact_nullable_typehint' => true,
'declare_strict_types' => true,
'heredoc_to_nowdoc' => true,
'list_syntax' => ['syntax' => 'short'],
'no_null_property_initialization' => true,
'no_superfluous_phpdoc_tags' => true,
'nullable_type_declaration_for_default_null_value' => true,
'ordered_imports' => [
'imports_order' => [
OrderedImportsFixer::IMPORT_TYPE_CONST,
OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
OrderedImportsFixer::IMPORT_TYPE_CLASS,
],
],
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_separation' => [
'groups' => [['Common\\*']],
],
'pow_to_exponentiation' => true,
'self_static_accessor' => true,
'single_line_throw' => false,
'ternary_to_null_coalescing' => true,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
// PHP 7 compatibility
'get_class_to_class_keyword' => false,
'modernize_strpos' => false,
Expand Down
6 changes: 3 additions & 3 deletions tests/BizkitLoggableCommandBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function testCompilerPassIsRegisteredWithCorrectPriority(): void
$compilerPassIndexes[\get_class($compilerPass)] = $i;
}

$this->assertArrayHasKey(LoggerChannelPass::class, $compilerPassIndexes);
$this->assertArrayHasKey(ExcludeMonologChannelPass::class, $compilerPassIndexes);
self::assertArrayHasKey(LoggerChannelPass::class, $compilerPassIndexes);
self::assertArrayHasKey(ExcludeMonologChannelPass::class, $compilerPassIndexes);

$this->assertGreaterThan(
self::assertGreaterThan(
$compilerPassIndexes[ExcludeMonologChannelPass::class],
$compilerPassIndexes[LoggerChannelPass::class]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __invoke(LoggableOutputInterface $loggableOutput): array
}
};

$this->assertSame($mergedConfig, $configurationProvider(new DummyLoggableOutput()));
self::assertSame($mergedConfig, $configurationProvider(new DummyLoggableOutput()));
}

public function configurationsToMerge(): iterable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class AnnotationConfigurationProviderTest extends TestCase
protected function setUp(): void
{
if (!class_exists(Annotation::class)) {
$this->markTestSkipped('Doctrine Annotation library is required.');
self::markTestSkipped('Doctrine Annotation library is required.');
}
}

Expand All @@ -40,7 +40,7 @@ public function testProviderReturnsExpectedConfigWhenAnnotationIsFound(): void
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyLoggableOutputWithAnnotation())
);
Expand All @@ -54,7 +54,7 @@ public function testProviderReturnsExpectedConfigWhenParentAndChildAnnotationsAr
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyChildLoggableOutputWithAnnotation())
);
Expand All @@ -68,7 +68,7 @@ public function testProviderReturnsExpectedConfigWhenParentAnnotationIsFound():
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyChildLoggableOutputWithParentAnnotation())
);
Expand All @@ -80,7 +80,7 @@ public function testProviderReturnsEmptyConfigWhenAnnotationIsNotFound(): void
$this->createContainerBagWithoutResolveValueMethodCalled()
);

$this->assertSame([], $provider(new DummyLoggableOutput()));
self::assertSame([], $provider(new DummyLoggableOutput()));
}

public function testProviderResolvesConfigParameters(): void
Expand All @@ -93,7 +93,7 @@ public function testProviderResolvesConfigParameters(): void

$container->setParameter('kernel.logs_dir', '/var/log');

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyLoggableOutputWithAnnotationAndParam())
);
Expand All @@ -107,10 +107,10 @@ private function createConfigurationProvider(ContainerBagInterface $containerBag
private function createContainerBagWithResolveValueMethodCalled(array $handlerOptions): ContainerBagInterface
{
$containerBag = $this->createMock(ContainerBagInterface::class);
$containerBag->expects($this->once())
$containerBag->expects(self::once())
->method('resolveValue')
->with($handlerOptions)
->willReturn($this->returnArgument(0))
->willReturn(self::returnArgument(0))
;

return $containerBag;
Expand All @@ -119,7 +119,7 @@ private function createContainerBagWithResolveValueMethodCalled(array $handlerOp
private function createContainerBagWithoutResolveValueMethodCalled(): ContainerBagInterface
{
$containerBag = $this->createMock(ContainerBagInterface::class);
$containerBag->expects($this->never())->method('resolveValue');
$containerBag->expects(self::never())->method('resolveValue');

return $containerBag;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ConfigurationProvider/Attribute/LoggableOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public function testOptionsArrayHasPrecedenceOverArguments(): void
->getOptions()
;

$this->assertSame('yes', $options['filename']);
$this->assertFalse($options['bubble']);
self::assertSame('yes', $options['filename']);
self::assertFalse($options['bubble']);
}

/**
* @dataProvider validLevels
*/
public function testLevelIsOKWhenStringOrInt($expected, array $arguments): void
{
$this->assertSame($expected, (new LoggableOutput(...$arguments))->getOptions()['level']);
self::assertSame($expected, (new LoggableOutput(...$arguments))->getOptions()['level']);
}

public function validLevels(): iterable
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testNullValuesAreFiltered(): void
{
$loggableOutput = new LoggableOutput([], 'name', null, 'stream', null, true, null, 0775);

$this->assertSame([
self::assertSame([
'filename' => 'name',
'type' => 'stream',
'bubble' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testProviderReturnsExpectedConfigWhenAttributeIsFound(): void
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyLoggableOutputWithAttribute())
);
Expand All @@ -46,7 +46,7 @@ public function testProviderReturnsExpectedConfigWhenParentAndChildAttributesAre
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyChildLoggableOutputWithAttribute())
);
Expand All @@ -60,7 +60,7 @@ public function testProviderReturnsExpectedConfigWhenParentAttributeIsFound(): v
$this->createContainerBagWithResolveValueMethodCalled($handlerOptions)
);

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyChildLoggableOutputWithParentAttribute())
);
Expand All @@ -72,7 +72,7 @@ public function testProviderReturnsEmptyConfigWhenAttributeIsNotFound(): void
$this->createContainerBagWithoutResolveValueMethodCalled()
);

$this->assertSame([], $provider(new DummyLoggableOutput()));
self::assertSame([], $provider(new DummyLoggableOutput()));
}

public function testProviderResolvesConfigParameters(): void
Expand All @@ -85,7 +85,7 @@ public function testProviderResolvesConfigParameters(): void

$container->setParameter('kernel.logs_dir', '/var/log');

$this->assertSame(
self::assertSame(
$handlerOptions,
$provider(new DummyLoggableOutputWithAttributeAndParam())
);
Expand All @@ -99,10 +99,10 @@ private function createConfigurationProvider(ContainerBagInterface $containerBag
private function createContainerBagWithResolveValueMethodCalled(array $handlerOptions): ContainerBagInterface
{
$containerBag = $this->createMock(ContainerBagInterface::class);
$containerBag->expects($this->once())
$containerBag->expects(self::once())
->method('resolveValue')
->with($handlerOptions)
->willReturn($this->returnArgument(0))
->willReturn(self::returnArgument(0))
;

return $containerBag;
Expand All @@ -111,7 +111,7 @@ private function createContainerBagWithResolveValueMethodCalled(array $handlerOp
private function createContainerBagWithoutResolveValueMethodCalled(): ContainerBagInterface
{
$containerBag = $this->createMock(ContainerBagInterface::class);
$containerBag->expects($this->never())->method('resolveValue');
$containerBag->expects(self::never())->method('resolveValue');

return $containerBag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testProviderReturnsDefaultConfig(): void

$provider = $this->createConfigurationProvider($handlerOptions);

$this->assertSame($handlerOptions, $provider(new DummyLoggableOutput()));
self::assertSame($handlerOptions, $provider(new DummyLoggableOutput()));
}

private function createConfigurationProvider(array $handlerOptions): ConfigurationProviderInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testConfigsAreMergedAsExpected(): void
]]
);

$this->assertSame(
self::assertSame(
['filename' => 'annotation-test', 'level' => LogLevel::CRITICAL, 'max_files' => 4, 'bubble' => true, 'extra_options' => [
'foo' => 'one',
'bar' => 'two',
Expand All @@ -50,7 +50,7 @@ private function createConfigurationProvider(

foreach ($handlerOptionsGroups as $handlerOptions) {
$handler = $this->createMock(ConfigurationProviderInterface::class);
$handler->expects($this->once())
$handler->expects(self::once())
->method('__invoke')
->with($loggableOutput)
->willReturn($handlerOptions)
Expand Down
Loading

0 comments on commit 54c67f5

Please sign in to comment.