Skip to content
This repository has been archived by the owner on Apr 10, 2020. It is now read-only.

Commit

Permalink
Bugfix: fixed an issue where different aliases of certain internal ty…
Browse files Browse the repository at this point in the history
…pes could not resolved

This caused an incorrect exception.
  • Loading branch information
mfrankruijter committed Jan 12, 2020
1 parent 6efd0e7 commit 669bc18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## 1.0.3 - 2020-01-12
### Fixed
- Renamed file InvalidParameterTypeException so it can be autoloaded.
- Translated internal type aliases to the same result as gettype returns.

## 1.0.2 - 2019-11-17
### Added
Expand Down
17 changes: 16 additions & 1 deletion src/Component/Analyser/ClassAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@

class ClassAnalyser implements ClassAnalyserInterface
{
/**
* A translation array to equalize the expected types of the gettype method.
*
* @var array
*/
private $translations = [
'bool' => 'boolean',
'int' => 'integer',
'float' => 'double'
];

/**
* Contains the previously analysed classes.
*
Expand Down Expand Up @@ -69,7 +80,11 @@ private function reflect(string $class): array
foreach ($constructor->getParameters() as $parameter) {
$type = $parameter->getType();
$parameters[$parameter->getName()] = [
'type' => $type !== null ? $type->getName() : 'mixed',
'type' => $type !== null ?
(array_key_exists($type->getName(), $this->translations)
? $this->translations[$type->getName()]
: $type->getName())
: 'mixed',
'builtin' => $type !== null ? $type->isBuiltin(): true,
'allowsNull' => $parameter->allowsNull(),
'isOptional' => $parameter->isOptional(),
Expand Down

0 comments on commit 669bc18

Please sign in to comment.