Skip to content
Open
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
14 changes: 13 additions & 1 deletion Spryker/Traits/SignatureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,24 @@ protected function getMethodSignature(File $phpCsFile, int $stackPtr): array
$typehint = substr($typehint, 1);
}

// Determine if parameter accepts null (nullable or explicit null)
$nullable = $parameter['nullable_type'];
if ($nullable === false && $typehint != '') {
for ($i = $parameter['type_hint_token']; $i <= $parameter['type_hint_end_token']; $i++) {
if ($tokens[$i]['code'] === T_NULL) {
$nullable = true;

break;
}
}
}

$arguments[] = [
'variableIndex' => $parameter['token'],
'variable' => $parameter['name'],
'typehint' => $typehint,
'typehintFull' => $parameter['type_hint'],
'nullable' => $parameter['nullable_type'],
'nullable' => $nullable,
'defaultIndex' => $defaultIndex,
'default' => $default,
];
Expand Down
10 changes: 10 additions & 0 deletions tests/_data/DocBlockParamAllowDefaultValue/after.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,14 @@ public function registerTableMapClass(string $tableMapClass): void
public function toPHP(mixed $value): mixed {
return $value;
}

/**
* This typehint is correct and should not change. See issue #368.
*
* @param int|string|null $value
* @return void
*/
public function multipleUnion(int|string|null $value): void
{
}
}
10 changes: 10 additions & 0 deletions tests/_data/DocBlockParamAllowDefaultValue/before.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,14 @@ public function registerTableMapClass(string $tableMapClass): void
public function toPHP(mixed $value): mixed {
return $value;
}

/**
* This typehint is correct and should not change. See issue #368.
*
* @param int|string|null $value
* @return void
*/
public function multipleUnion(int|string|null $value): void
{
}
}