Skip to content

Commit

Permalink
SDK-4882: SDK-4717: support new return type int (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4onok authored Oct 2, 2023
1 parent 222c675 commit 91022a4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Builder/Creator/AbstractReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class AbstractReflectionClass
*/
protected const RETURN_TYPE_INT = 'int';

/**
* @var string
*/
protected const RETURN_TYPE_FLOAT = 'float';

/**
* @param mixed $value
*
Expand Down
6 changes: 6 additions & 0 deletions src/Builder/Creator/MethodDocBlockCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public function createMethodDocBlock($value): Doc
if (is_bool($value)) {
$docBlockReturnType = static::RETURN_TYPE_BOOL;
}
if (is_int($value)) {
$docBlockReturnType = static::RETURN_TYPE_INT;
}
if (is_float($value)) {
$docBlockReturnType = static::RETURN_TYPE_FLOAT;
}
$docBlockReturnItems[] = ' * @return ' . $docBlockReturnType;
$docBlockReturnItems[] = ' */';

Expand Down
8 changes: 8 additions & 0 deletions src/Builder/Creator/MethodReturnTypeCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public function createMethodReturnType($value): Identifier
$returnType = static::RETURN_TYPE_BOOL;
}

if (is_float($value)) {
$returnType = static::RETURN_TYPE_FLOAT;
}

if (is_int($value)) {
$returnType = static::RETURN_TYPE_INT;
}

return new Identifier($returnType);
}
}

0 comments on commit 91022a4

Please sign in to comment.