-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from greg0ire/generate_proper_object_return_type
Generate proper object return type
- Loading branch information
Showing
5 changed files
with
135 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Prophecy\Doubler\Generator; | ||
|
||
/** | ||
* Tells whether a keyword refers to a class or to a built-in type for the | ||
* current version of php | ||
*/ | ||
final class TypeHintReference | ||
{ | ||
public function isBuiltInParamTypeHint($type) | ||
{ | ||
switch ($type) { | ||
case 'self': | ||
case 'array': | ||
return true; | ||
|
||
case 'callable': | ||
return PHP_VERSION_ID >= 50400; | ||
|
||
case 'bool': | ||
case 'float': | ||
case 'int': | ||
case 'string': | ||
return PHP_VERSION_ID >= 70000; | ||
|
||
case 'iterable': | ||
return PHP_VERSION_ID >= 70100; | ||
|
||
case 'object': | ||
return PHP_VERSION_ID >= 70200; | ||
|
||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public function isBuiltInReturnTypeHint($type) | ||
{ | ||
if ($type === 'void') { | ||
return PHP_VERSION_ID >= 70100; | ||
} | ||
|
||
return $this->isBuiltInParamTypeHint($type); | ||
} | ||
} |