Skip to content

Commit fd50d1d

Browse files
authored
Merge pull request #77 from php-api-clients/small-corrections
Hydrator namespace fix
2 parents 615e49e + 676230b commit fd50d1d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Generator/Client.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,32 @@ public static function generate(string $namespace, array $clients, SchemaRegistr
311311
// yield new Node\Stmt\Echo_([new Node\Scalar\String_('/**' . @var_export($operationCall, true) . '*/')]);
312312
}
313313
})($operationCalls))
314+
))->addStmt(
315+
new Node\Stmt\Throw_(
316+
new Node\Expr\New_(
317+
new Node\Name('\InvalidArgumentException')
318+
)
319+
)
320+
)
321+
);
322+
323+
$class->addStmt(
324+
$factory->method('hydrateObject')->makePublic()->setReturnType('object')->addParam(
325+
(new Param('className'))->setType('string')
326+
)->addParam(
327+
(new Param('data'))->setType('array')
328+
)->addStmt(new Node\Stmt\Return_(
329+
new Node\Expr\MethodCall(
330+
new Node\Expr\PropertyFetch(
331+
new Node\Expr\Variable('this'),
332+
'hydrator'
333+
),
334+
new Node\Name('hydrateObject'),
335+
[
336+
new Node\Arg(new Node\Expr\Variable('className')),
337+
new Node\Arg(new Node\Expr\Variable('data')),
338+
]
339+
)
314340
))
315341
);
316342

src/Generator/WebHooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function generate(string $namespace, string $baseNamespace, array
5353
Class_::MODIFIER_PUBLIC
5454
)
5555
)->addStmt(
56-
$factory->property('hydrator')->setType('\\' . $namespace . 'OptimizedHydratorMapper')->makeReadonly()->makePrivate()
56+
$factory->property('hydrator')->setType('\\' . $baseNamespace . 'OptimizedHydratorMapper')->makeReadonly()->makePrivate()
5757
)->addStmt(
5858
$factory->method('__construct')->makePublic()->addStmt(
5959
new Node\Expr\Assign(
@@ -62,7 +62,7 @@ public static function generate(string $namespace, string $baseNamespace, array
6262
'hydrator'
6363
),
6464
new Node\Expr\New_(
65-
new Node\Name('\\' . $namespace . 'OptimizedHydratorMapper'),
65+
new Node\Name('\\' . $baseNamespace . 'OptimizedHydratorMapper'),
6666
[
6767
]
6868
),

0 commit comments

Comments
 (0)