Skip to content

Commit d0e860a

Browse files
committed
Apply doctrine coding standards
1 parent 207842a commit d0e860a

35 files changed

+562
-519
lines changed

.github/main.workflow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ action "composer-require-checker" {
2929
}
3030

3131
action "Code style check" {
32-
uses = "docker://oskarstark/phpcs-ga"
32+
uses = "docker://phpdoc/phpcs-ga:latest"
3333
secrets = ["GITHUB_TOKEN"]
34-
args = "-d memory_limit=1024M"
34+
args = "-d memory_limit=1024M -s"
3535
needs = ["composer"]
3636
}
3737

phpcs.xml.dist

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@
66
<file>tests/unit</file>
77
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
88
<arg value="p"/>
9-
<rule ref="PSR2">
10-
<include-pattern>*\.php</include-pattern>
11-
</rule>
12-
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
13-
<exclude-pattern>*/src/*_.php</exclude-pattern>
14-
</rule>
9+
<rule ref="PSR2">
10+
<include-pattern>*\.php</include-pattern>
11+
</rule>
12+
13+
<rule ref="Doctrine">
14+
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment" />
15+
</rule>
16+
17+
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
18+
<exclude-pattern>*/src/*_.php</exclude-pattern>
19+
</rule>
20+
21+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
22+
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
23+
</rule>
24+
25+
<rule ref="Generic.Formatting.SpaceAfterNot">
26+
<properties>
27+
<property name="spacing" value="0" />
28+
</properties>
29+
</rule>
1530
</ruleset>

src/FqsenResolver.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* This file is part of phpDocumentor.
47
*
58
* For the full copyright and license information, please view the LICENSE
69
* file that was distributed with this source code.
710
*
8-
* @copyright 2010-2018 Mike van Riel<[email protected]>
9-
* @license http://www.opensource.org/licenses/mit-license.php MIT
1011
* @link http://phpdoc.org
1112
*/
1213

1314
namespace phpDocumentor\Reflection;
1415

16+
use InvalidArgumentException;
1517
use phpDocumentor\Reflection\Types\Context;
18+
use function explode;
19+
use function implode;
20+
use function strpos;
1621

1722
class FqsenResolver
1823
{
1924
/** @var string Definition of the NAMESPACE operator in PHP */
2025
private const OPERATOR_NAMESPACE = '\\';
2126

22-
public function resolve(string $fqsen, Context $context = null): Fqsen
27+
public function resolve(string $fqsen, ?Context $context = null) : Fqsen
2328
{
2429
if ($context === null) {
2530
$context = new Context('');
@@ -34,12 +39,8 @@ public function resolve(string $fqsen, Context $context = null): Fqsen
3439

3540
/**
3641
* Tests whether the given type is a Fully Qualified Structural Element Name.
37-
*
38-
* @param string $type
39-
*
40-
* @return bool
4142
*/
42-
private function isFqsen(string $type): bool
43+
private function isFqsen(string $type) : bool
4344
{
4445
return strpos($type, self::OPERATOR_NAMESPACE) === 0;
4546
}
@@ -48,11 +49,9 @@ private function isFqsen(string $type): bool
4849
* Resolves a partial Structural Element Name (i.e. `Reflection\DocBlock`) to its FQSEN representation
4950
* (i.e. `\phpDocumentor\Reflection\DocBlock`) based on the Namespace and aliases mentioned in the Context.
5051
*
51-
* @param string $type
52-
* @return Fqsen
53-
* @throws \InvalidArgumentException when type is not a valid FQSEN.
52+
* @throws InvalidArgumentException When type is not a valid FQSEN.
5453
*/
55-
private function resolvePartialStructuralElementName(string $type, Context $context): Fqsen
54+
private function resolvePartialStructuralElementName(string $type, Context $context) : Fqsen
5655
{
5756
$typeParts = explode(self::OPERATOR_NAMESPACE, $type, 2);
5857

@@ -61,7 +60,7 @@ private function resolvePartialStructuralElementName(string $type, Context $cont
6160
// if the first segment is not an alias; prepend namespace name and return
6261
if (!isset($namespaceAliases[$typeParts[0]])) {
6362
$namespace = $context->getNamespace();
64-
if ('' !== $namespace) {
63+
if ($namespace !== '') {
6564
$namespace .= self::OPERATOR_NAMESPACE;
6665
}
6766

src/Type.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* This file is part of phpDocumentor.
47
*
58
* For the full copyright and license information, please view the LICENSE
69
* file that was distributed with this source code.
710
*
8-
* @copyright 2010-2018 Mike van Riel<[email protected]>
9-
* @license http://www.opensource.org/licenses/mit-license.php MIT
1011
* @link http://phpdoc.org
1112
*/
1213

@@ -16,8 +17,6 @@ interface Type
1617
{
1718
/**
1819
* Returns a rendered output of the Type as it would be used in a DocBlock.
19-
*
20-
* @return string
2120
*/
22-
public function __toString(): string;
21+
public function __toString() : string;
2322
}

0 commit comments

Comments
 (0)