Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP Fatal error in Squiz.Commenting.FunctionComment #3785

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$suggestedTypeNames = [];

foreach ($typeNames as $typeName) {
if ($typeName === '') {
continue;
}

// Strip nullable operator.
jrfnl marked this conversation as resolved.
Show resolved Hide resolved
if ($typeName[0] === '?') {
$typeName = substr($typeName, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,11 @@ public function ignored() {
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
* @param stdClass||null $object While invalid, this should not throw a PHP Fatal error.
* @return void
*/
function doublePipeFatalError(?stdClass $object) {}
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,11 @@ public function ignored() {
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
* @param stdClass|null $object While invalid, this should not throw a PHP Fatal error.
* @return void
*/
function doublePipeFatalError(?stdClass $object) {}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function getErrorList()
1004 => 2,
1006 => 1,
1029 => 1,
1053 => 1,
];

// Scalar type hints only work from PHP 7 onwards.
Expand Down