Sitelet https://github.com/cakephp/cakephp-codesniffer/commit/b80311d066055da7ebfc36f836e9caee2d07334e
Skip to content

Commit b80311d

Browse files
committed
Merge branch '5.x' into 5.next
2 parents fed52b6 + 6d0168a commit b80311d

5 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎CakePHP/Sniffs/Commenting/TypeHintSniff.php‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,16 @@ public function process(File $phpcsFile, $stackPtr)
101101
continue;
102102
}
103103

104-
/** @phpstan-ignore-next-line */
105-
if ($valueNode->type instanceof UnionTypeNode) {
106-
$types = $valueNode->type->types;
107-
} elseif ($valueNode->type instanceof ArrayTypeNode) {
108-
$types = [$valueNode->type];
104+
if (isset($valueNode->type)) {
105+
if ($valueNode->type instanceof UnionTypeNode) {
106+
$types = $valueNode->type->types;
107+
} elseif ($valueNode->type instanceof ArrayTypeNode) {
108+
$types = [$valueNode->type];
109+
} else {
110+
continue;
111+
}
109112
} else {
113+
$phpcsFile->addWarning('@param type hint is missing', $tag, 'MissingParamType');
110114
continue;
111115
}
112116

‎CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Foo
2222
public function testFunctionAnotations()
2323
{
2424
}
25+
26+
/**
27+
* @param $test
28+
* @return void
29+
*/
30+
public function testNoParamTypeHint(string $test)
31+
{
32+
}
2533
}
2634

2735
function test()

‎CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Foo
2222
public function testFunctionAnotations()
2323
{
2424
}
25+
26+
/**
27+
* @param $test
28+
* @return void
29+
*/
30+
public function testNoParamTypeHint(string $test)
31+
{
32+
}
2533
}
2634

2735
function test()

‎CakePHP/Tests/Commenting/TypeHintUnitTest.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public function getWarningList($testFile = '')
2929
9 => 1,
3030
12 => 1,
3131
15 => 1,
32-
29 => 1,
33-
34 => 1,
32+
27 => 1,
33+
37 => 1,
34+
42 => 1,
3435
];
3536

3637
default:

‎CakePHP/ruleset.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
<property name="allowFallbackGlobalConstants" type="boolean" value="true"/>
168168
</properties>
169169
</rule>
170+
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
170171
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
171172
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
172173
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>

0 commit comments

Comments
 (0)