Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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)) {
Expand Down
50 changes: 50 additions & 0 deletions tests/rules/doc/allowed/ReturnTypeMysqli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

// @expectedPass

namespace flyeralarm\Test;

class FooTest
{
/**
* @return mysqli
*/
public function testMysqli()
{
}

/**
* @return mysqli_driver
*/
public function testMysqliDriver()
{
}

/**
* @return mysqli_result
*/
public function testMysqliResult()
{
}

/**
* @return mysqli_stmt
*/
public function testMysqliStmt()
{
}

/**
* @return mysqli_sql_exception
*/
public function testMysqliSqlException()
{
}

/**
* @return mysqli_warning
*/
public function testMysqliWarning()
{
}
}