diff --git a/src/Generator/Client.php b/src/Generator/Client.php index ae4775d..055e89c 100644 --- a/src/Generator/Client.php +++ b/src/Generator/Client.php @@ -311,6 +311,32 @@ public static function generate(string $namespace, array $clients, SchemaRegistr // yield new Node\Stmt\Echo_([new Node\Scalar\String_('/**' . @var_export($operationCall, true) . '*/')]); } })($operationCalls)) + ))->addStmt( + new Node\Stmt\Throw_( + new Node\Expr\New_( + new Node\Name('\InvalidArgumentException') + ) + ) + ) + ); + + $class->addStmt( + $factory->method('hydrateObject')->makePublic()->setReturnType('object')->addParam( + (new Param('className'))->setType('string') + )->addParam( + (new Param('data'))->setType('array') + )->addStmt(new Node\Stmt\Return_( + new Node\Expr\MethodCall( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + 'hydrator' + ), + new Node\Name('hydrateObject'), + [ + new Node\Arg(new Node\Expr\Variable('className')), + new Node\Arg(new Node\Expr\Variable('data')), + ] + ) )) ); diff --git a/src/Generator/WebHooks.php b/src/Generator/WebHooks.php index e67d7af..2e3b303 100644 --- a/src/Generator/WebHooks.php +++ b/src/Generator/WebHooks.php @@ -53,7 +53,7 @@ public static function generate(string $namespace, string $baseNamespace, array Class_::MODIFIER_PUBLIC ) )->addStmt( - $factory->property('hydrator')->setType('\\' . $namespace . 'OptimizedHydratorMapper')->makeReadonly()->makePrivate() + $factory->property('hydrator')->setType('\\' . $baseNamespace . 'OptimizedHydratorMapper')->makeReadonly()->makePrivate() )->addStmt( $factory->method('__construct')->makePublic()->addStmt( new Node\Expr\Assign( @@ -62,7 +62,7 @@ public static function generate(string $namespace, string $baseNamespace, array 'hydrator' ), new Node\Expr\New_( - new Node\Name('\\' . $namespace . 'OptimizedHydratorMapper'), + new Node\Name('\\' . $baseNamespace . 'OptimizedHydratorMapper'), [ ] ),