From f4e68e7caba72621704125fb65b27245cdbf61d3 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 30 Nov 2024 05:47:12 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -![Build Status](https://github.com/cakephp/cakephp-codesniffer/actions/workflows/ci.yml/badge.svg?branch=master) +![Build Status](https://github.com/cakephp/cakephp-codesniffer/actions/workflows/ci.yml/badge.svg?branch=5.x) [![Total Downloads](https://img.shields.io/packagist/dt/cakephp/cakephp-codesniffer.svg?style=flat-square)](https://packagist.org/packages/cakephp/cakephp-codesniffer) [![Latest Stable Version](https://img.shields.io/packagist/v/cakephp/cakephp-codesniffer.svg?style=flat-square)](https://packagist.org/packages/cakephp/cakephp-codesniffer) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) From cd67ba646dc01977ecff1136da4da77c8499473d Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 17 Dec 2024 22:28:11 +0100 Subject: [PATCH 2/3] fix error when phpdoc param has no type --- CakePHP/Sniffs/Commenting/TypeHintSniff.php | 13 +++++++++---- CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc | 8 ++++++++ .../Tests/Commenting/TypeHintUnitTest.1.inc.fixed | 8 ++++++++ CakePHP/Tests/Commenting/TypeHintUnitTest.php | 5 +++-- 4 files changed, 28 insertions(+), 6 deletions(-) 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: From 63e3db6dd3bf594c6e6aa20f191011e370a55411 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 17 Dec 2024 23:19:31 +0100 Subject: [PATCH 3/3] error on group use declarations --- CakePHP/ruleset.xml | 1 + 1 file changed, 1 insertion(+) 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 @@ +