diff --git a/src/Factory/Reflection/ReflectionMethodFactory.php b/src/Factory/Reflection/ReflectionMethodFactory.php index 403e86c..0f845a1 100644 --- a/src/Factory/Reflection/ReflectionMethodFactory.php +++ b/src/Factory/Reflection/ReflectionMethodFactory.php @@ -152,7 +152,11 @@ protected function addParamAnnotation($name, $value) : void if (!$this->parameters->containsKey($param)) { - throw new \Exception(); + throw new \Exception + ( + 'Tried to set param annotation for non existant ' + . 'parameter: ' . $param + ); } $comparator = new TypeComparator(); @@ -162,7 +166,7 @@ protected function addParamAnnotation($name, $value) : void if (!$comparator->compatible($nativeType, $type)) { - throw new \Exception(); + throw new \Exception('Types are incompatible'); } $param->setRawValue('type', $type); @@ -182,7 +186,7 @@ protected function addParameter { $parameter = new ReflectionParameter(); $accessor = new RawPropertyAccessor($parameter); - $type = $this->typeParser->parse((string)$reflect->getType()); + $type = (new TypeParser())->parse((string)$reflect->getType()); $this->parameters['$' . $reflect->getName()] = $accessor; $this->accessor->rawAddToValue('parameters', $parameter); diff --git a/src/Service/PropertyAccessor.php b/src/Service/PropertyAccessor.php index a637f64..813b632 100644 --- a/src/Service/PropertyAccessor.php +++ b/src/Service/PropertyAccessor.php @@ -112,14 +112,14 @@ public function constructObject(...$args) */ protected function buildProperty(ReflectionProperty $property) { - if ($property->type instanceof ObjectType) + if (!$property->type instanceof ObjectType) { - $class = $property->type->classname; - $this->setRawValue($property->name, new $class()); + $this->setAnyValue($property, 0); } - else + elseif ($property->builtInConstructor) { - $this->setAnyValue($property, 0); + $class = $property->type->classname; + $this->setRawValue($property->name, new $class()); } }