Skip to content

Commit c6ee417

Browse files
committed
Update coding standard
1 parent 553b859 commit c6ee417

14 files changed

+40
-62
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"phpstan/phpstan": "^0.9.0",
1919
"phpunit/phpunit": "^6.4",
2020
"phpstan/phpstan-phpunit": "^0.9.0",
21-
"lookyman/coding-standard": "^0.0.6",
2221
"symfony/framework-bundle": "^4.0",
23-
"phpstan/phpstan-strict-rules": "^0.9.0"
22+
"phpstan/phpstan-strict-rules": "^0.9.0",
23+
"lookyman/coding-standard": "0.1.0"
2424
},
2525
"autoload": {
2626
"psr-4": {

phpcs.xml.dist

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ruleset name="PHPStan Symfony">
3-
<rule ref="vendor/lookyman/coding-standard/LookymanCodingStandard/ruleset-7.0.xml">
4-
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName"/>
5-
</rule>
3+
<rule ref="vendor/lookyman/coding-standard/LookymanCodingStandard/ruleset.xml"/>
64
</ruleset>

src/Exception/XmlContainerNotExistsException.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Exception;
65

src/Rules/ContainerInterfacePrivateServiceRule.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Rules;
65

src/Rules/ContainerInterfaceUnknownServiceRule.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Rules;
65

src/ServiceMap.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony;
65

@@ -56,21 +55,13 @@ public function __construct(string $containerXml)
5655
}
5756
}
5857

59-
/**
60-
* @param Node $node
61-
* @return array|null
62-
*/
63-
public function getServiceFromNode(Node $node)
58+
public function getServiceFromNode(Node $node): ?array
6459
{
6560
$serviceId = self::getServiceIdFromNode($node);
6661
return $serviceId !== \null && \array_key_exists($serviceId, $this->services) ? $this->services[$serviceId] : \null;
6762
}
6863

69-
/**
70-
* @param Node $node
71-
* @return string|null
72-
*/
73-
public static function getServiceIdFromNode(Node $node)
64+
public static function getServiceIdFromNode(Node $node): ?string
7465
{
7566
if ($node instanceof String_) {
7667
return $node->value;

src/Type/ContainerInterfaceDynamicReturnTypeExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Type;
65

src/Type/ControllerDynamicReturnTypeExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Type;
65

tests/Rules/ContainerInterfacePrivateServiceRuleTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Rules;
65

@@ -17,12 +16,12 @@ protected function getRule(): Rule
1716
return new ContainerInterfacePrivateServiceRule($serviceMap);
1817
}
1918

20-
public function testGetPrivateService()
19+
public function testGetPrivateService(): void
2120
{
2221
$this->analyse([__DIR__ . '/data/ExampleController.php'], [
2322
[
2423
'Service "private" is private.',
25-
15,
24+
14,
2625
],
2726
]);
2827
}

tests/Rules/ContainerInterfaceUnknownServiceRuleTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Rules;
65

@@ -17,20 +16,20 @@ protected function getRule(): Rule
1716
return new ContainerInterfaceUnknownServiceRule($serviceMap);
1817
}
1918

20-
public function testGetUnknownService()
19+
public function testGetUnknownService(): void
2120
{
2221
$this->analyse([__DIR__ . '/data/ExampleController.php'], [
2322
[
2423
'Service "service.not.found" is not registered in the container.',
25-
21,
24+
20,
2625
],
2726
[
2827
'Service "Lookyman\PHPStan\Symfony\ServiceMap" is not registered in the container.',
29-
27,
28+
26,
3029
],
3130
[
3231
'Service "service.Lookyman\PHPStan\Symfony\ServiceMap" is not registered in the container.',
33-
39,
32+
38,
3433
],
3534
]);
3635
}

tests/Rules/data/ExampleController.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Rules\data;
65

@@ -10,37 +9,37 @@
109
final class ExampleController extends Controller
1110
{
1211

13-
public function getPrivateServiceAction()
12+
public function getPrivateServiceAction(): void
1413
{
1514
$service = $this->get('private');
1615
$service->noMethod();
1716
}
1817

19-
public function getUnknownService()
18+
public function getUnknownService(): void
2019
{
2120
$service = $this->get('service.not.found');
2221
$service->noMethod();
2322
}
2423

25-
public function getUnknownServiceByClass()
24+
public function getUnknownServiceByClass(): void
2625
{
2726
$service = $this->get(ServiceMap::class);
2827
$service->noMethod();
2928
}
3029

31-
public function getVariableService(string $serviceKey)
30+
public function getVariableService(string $serviceKey): void
3231
{
3332
$service = $this->get($serviceKey);
3433
$service->noMethod();
3534
}
3635

37-
public function getConcatenatedService()
36+
public function getConcatenatedService(): void
3837
{
3938
$service = $this->get('service.' . ServiceMap::class);
4039
$service->noMethod();
4140
}
4241

43-
public function getSelfService()
42+
public function getSelfService(): void
4443
{
4544
$service = $this->get(self::class);
4645
$service->noMethod();

tests/ServiceMapTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony;
65

@@ -18,7 +17,7 @@ final class ServiceMapTest extends TestCase
1817
/**
1918
* @dataProvider getServiceFromNodeProvider
2019
*/
21-
public function testGetServiceFromNode(array $service)
20+
public function testGetServiceFromNode(array $service): void
2221
{
2322
$serviceMap = new ServiceMap(__DIR__ . '/container.xml');
2423
self::assertEquals($service, $serviceMap->getServiceFromNode(new String_($service['id'])));
@@ -27,7 +26,7 @@ public function testGetServiceFromNode(array $service)
2726
/**
2827
* @expectedException \Lookyman\PHPStan\Symfony\Exception\XmlContainerNotExistsException
2928
*/
30-
public function testFileNotExists()
29+
public function testFileNotExists(): void
3130
{
3231
new ServiceMap(__DIR__ . '/foo.xml');
3332
}
@@ -45,7 +44,7 @@ public function getServiceFromNodeProvider(): array
4544
];
4645
}
4746

48-
public function testGetServiceIdFromNode()
47+
public function testGetServiceIdFromNode(): void
4948
{
5049
self::assertEquals('foo', ServiceMap::getServiceIdFromNode(new String_('foo')));
5150
self::assertEquals('bar', ServiceMap::getServiceIdFromNode(new ClassConstFetch(new Name('bar'), '')));

tests/Type/ContainerInterfaceDynamicReturnTypeExtensionTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Type;
65

@@ -22,21 +21,21 @@
2221
final class ContainerInterfaceDynamicReturnTypeExtensionTest extends TestCase
2322
{
2423

25-
public function testImplementsDynamicMethodReturnTypeExtension()
24+
public function testImplementsDynamicMethodReturnTypeExtension(): void
2625
{
2726
self::assertInstanceOf(
2827
DynamicMethodReturnTypeExtension::class,
2928
new ContainerInterfaceDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'))
3029
);
3130
}
3231

33-
public function testGetClass()
32+
public function testGetClass(): void
3433
{
3534
$extension = new ContainerInterfaceDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'));
3635
self::assertEquals('Symfony\Component\DependencyInjection\ContainerInterface', $extension->getClass());
3736
}
3837

39-
public function testIsMethodSupported()
38+
public function testIsMethodSupported(): void
4039
{
4140
$methodGet = $this->createMock(MethodReflection::class);
4241
$methodGet->expects(self::once())->method('getName')->willReturn('get');
@@ -52,7 +51,7 @@ public function testIsMethodSupported()
5251
/**
5352
* @dataProvider getTypeFromMethodCallProvider
5453
*/
55-
public function testGetTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Type $expectedType)
54+
public function testGetTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Type $expectedType): void
5655
{
5756
$extension = new ContainerInterfaceDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'));
5857
$type = $extension->getTypeFromMethodCall(

tests/Type/ControllerDynamicReturnTypeExtensionTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
declare(strict_types = 1);
2+
declare(strict_types=1);
43

54
namespace Lookyman\PHPStan\Symfony\Type;
65

@@ -22,21 +21,21 @@
2221
final class ControllerDynamicReturnTypeExtensionTest extends TestCase
2322
{
2423

25-
public function testImplementsDynamicMethodReturnTypeExtension()
24+
public function testImplementsDynamicMethodReturnTypeExtension(): void
2625
{
2726
self::assertInstanceOf(
2827
DynamicMethodReturnTypeExtension::class,
2928
new ControllerDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'))
3029
);
3130
}
3231

33-
public function testGetClass()
32+
public function testGetClass(): void
3433
{
3534
$extension = new ControllerDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'));
3635
self::assertEquals('Symfony\Bundle\FrameworkBundle\Controller\Controller', $extension->getClass());
3736
}
3837

39-
public function testIsMethodSupported()
38+
public function testIsMethodSupported(): void
4039
{
4140
$methodGet = $this->createMock(MethodReflection::class);
4241
$methodGet->expects(self::once())->method('getName')->willReturn('get');
@@ -52,7 +51,7 @@ public function testIsMethodSupported()
5251
/**
5352
* @dataProvider getTypeFromMethodCallProvider
5453
*/
55-
public function testGetTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Type $expectedType)
54+
public function testGetTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Type $expectedType): void
5655
{
5756
$extension = new ControllerDynamicReturnTypeExtension(new ServiceMap(__DIR__ . '/../container.xml'));
5857
$type = $extension->getTypeFromMethodCall(

0 commit comments

Comments
 (0)