Skip to content

Commit

Permalink
Fixed bug #3277 : Nullable static return typehint causes whitespace e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
gsherwood committed Mar 21, 2021
1 parent 18c27ed commit 2bd19c2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis
- Fixed bug #3277 : Nullable static return typehint causes whitespace error
</notes>
<contents>
<dir name="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

if ($prevToken !== false
&& $tokens[$prevToken]['code'] === T_NULLABLE
) {
// Not a scope keyword, but a return type.
return;
}

if ($prevToken !== false
&& $tokens[$prevToken]['code'] === T_COLON
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public static function fCreate($attributes = []): static
return static::factory()->create($attributes);
}

public static function fCreate($attributes = []): ?static
{
return static::factory()->create($attributes);
}

// Also account for static used within union types.
public function fCreate($attributes = []): object|static
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public static function fCreate($attributes = []): static
return static::factory()->create($attributes);
}

public static function fCreate($attributes = []): ?static
{
return static::factory()->create($attributes);
}

// Also account for static used within union types.
public function fCreate($attributes = []): object|static
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public function getErrorList()
64 => 1,
67 => 1,
71 => 1,
98 => 1,
101 => 1,
103 => 1,
106 => 1,
114 => 1,
116 => 1,
122 => 2,
111 => 1,
119 => 1,
121 => 1,
127 => 2,
];

}//end getErrorList()
Expand Down

0 comments on commit 2bd19c2

Please sign in to comment.