diff --git a/custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php b/custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php index 3d92aea..6271637 100644 --- a/custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php +++ b/custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php @@ -20,10 +20,22 @@ class ReturnTypeSniff implements Sniff 'bool[]', 'int[]', 'string[]', - 'float[]', + 'float[]', 'null' ]; + /** + * @var array + */ + private $returnTypeClassWhitelist = [ + 'mysqli', + 'mysqli_driver', + 'mysqli_result', + 'mysqli_stmt', + 'mysqli_sql_exception', + 'mysqli_warning', + ]; + /** * @return array */ @@ -50,7 +62,10 @@ public function process(File $phpcsFile, $stackPtr) foreach ($returnTypes as $returnType) { $returnType = trim($returnType); - if (in_array($returnType, $this->returnTypeScalarWhitelist)) { + if (in_array($returnType, $this->returnTypeScalarWhitelist, true)) { + continue; + } + if (in_array($returnType, $this->returnTypeClassWhitelist, true)) { continue; } if ($this->isStartingWithUppercaseLetter($returnType)) { diff --git a/tests/rules/doc/allowed/ReturnTypeMysqli.php b/tests/rules/doc/allowed/ReturnTypeMysqli.php new file mode 100644 index 0000000..8412441 --- /dev/null +++ b/tests/rules/doc/allowed/ReturnTypeMysqli.php @@ -0,0 +1,50 @@ +