diff --git a/CakePHP/Sniffs/Commenting/TypeHintSniff.php b/CakePHP/Sniffs/Commenting/TypeHintSniff.php
index 9e522a1..affdc84 100644
--- a/CakePHP/Sniffs/Commenting/TypeHintSniff.php
+++ b/CakePHP/Sniffs/Commenting/TypeHintSniff.php
@@ -101,11 +101,16 @@ public function process(File $phpcsFile, $stackPtr)
continue;
}
- if ($valueNode->type instanceof UnionTypeNode) {
- $types = $valueNode->type->types;
- } elseif ($valueNode->type instanceof ArrayTypeNode) {
- $types = [$valueNode->type];
+ if (isset($valueNode->type)) {
+ if ($valueNode->type instanceof UnionTypeNode) {
+ $types = $valueNode->type->types;
+ } elseif ($valueNode->type instanceof ArrayTypeNode) {
+ $types = [$valueNode->type];
+ } else {
+ continue;
+ }
} else {
+ $phpcsFile->addWarning('@param type hint is missing', $tag, 'MissingParamType');
continue;
}
diff --git a/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc b/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc
index 90c5a29..d57471c 100644
--- a/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc
+++ b/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc
@@ -22,6 +22,14 @@ class Foo
public function testFunctionAnotations()
{
}
+
+ /**
+ * @param $test
+ * @return void
+ */
+ public function testNoParamTypeHint(string $test)
+ {
+ }
}
function test()
diff --git a/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed b/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed
index d965b5a..61ca897 100644
--- a/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed
+++ b/CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed
@@ -22,6 +22,14 @@ class Foo
public function testFunctionAnotations()
{
}
+
+ /**
+ * @param $test
+ * @return void
+ */
+ public function testNoParamTypeHint(string $test)
+ {
+ }
}
function test()
diff --git a/CakePHP/Tests/Commenting/TypeHintUnitTest.php b/CakePHP/Tests/Commenting/TypeHintUnitTest.php
index 8900a98..0cdd01e 100644
--- a/CakePHP/Tests/Commenting/TypeHintUnitTest.php
+++ b/CakePHP/Tests/Commenting/TypeHintUnitTest.php
@@ -29,8 +29,9 @@ public function getWarningList($testFile = '')
9 => 1,
12 => 1,
15 => 1,
- 29 => 1,
- 34 => 1,
+ 27 => 1,
+ 37 => 1,
+ 42 => 1,
];
default:
diff --git a/CakePHP/ruleset.xml b/CakePHP/ruleset.xml
index c5eaf3d..c37562e 100644
--- a/CakePHP/ruleset.xml
+++ b/CakePHP/ruleset.xml
@@ -148,6 +148,7 @@
+
diff --git a/README.md b/README.md
index 3ed3a28..736486e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# CakePHP Code Sniffer
-
+
[](https://packagist.org/packages/cakephp/cakephp-codesniffer)
[](https://packagist.org/packages/cakephp/cakephp-codesniffer)
[](LICENSE)