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
5 changes: 5 additions & 0 deletions src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

if (empty($tokens[$stackPtr]['nested_attributes']) === false) {
// Class instantiation in attribute, not function call.
return;
}

$function = strtolower($tokens[$stackPtr]['content']);
$pattern = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ function mymodule_form_callback(SizeOf $sizeof) {
}

$size = $class?->sizeof($array);

#[SizeOf(10)]
function doSomething() {}
5 changes: 5 additions & 0 deletions src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function process(File $phpcsFile, $stackPtr)
}

// Make sure this is a function call or a use statement.
if (empty($tokens[$stackPtr]['nested_attributes']) === false) {
// Class instantiation in attribute, not function call.
return;
}

$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($next === false) {
// Not a function call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
error_log('test');
print_r($array);
var_dump($array);
?>

#[Var_Dump(10)]
function debugMe() {}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ $callToNamespacedFunction = namespace\STR_REPEAT($a, 2); // Could potentially be
$filePath = new \File($path);

$count = $object?->Count();

class AttributesShouldBeIgnored
{
#[Putenv('FOO', 'foo')]
public function foo(): void
{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ $callToNamespacedFunction = namespace\STR_REPEAT($a, 2); // Could potentially be
$filePath = new \File($path);

$count = $object?->Count();

class AttributesShouldBeIgnored
{
#[Putenv('FOO', 'foo')]
public function foo(): void
{}
}