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 cf52a0e commit 243ea26
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
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 243ea26

Please sign in to comment.