File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ trait ResolveNameTrait
2222{
2323 private function resolveName (PhpNamespace $ namespace , string $ name ): string
2424 {
25- return $ namespace ->resolveName ($ name );
25+ if (method_exists (PhpNamespace::class, 'resolveName ' )) { // @phpstan-ignore-line
26+ return $ namespace ->resolveName ($ name );
27+ }
28+
29+ return $ name ;
2630 }
2731}
Original file line number Diff line number Diff line change 1313
1414namespace ApiPlatform \SchemaGenerator ;
1515
16+ use Nette \PhpGenerator \PhpNamespace ;
1617use Nette \PhpGenerator \Printer as NettePrinter ;
1718
1819final class Printer extends NettePrinter
@@ -22,6 +23,10 @@ public function __construct()
2223 parent ::__construct ();
2324
2425 $ this ->linesBetweenMethods = 1 ;
25- $ this ->setTypeResolving (false );
26+ // If the type name cannot be resolved with the namespace and its uses (nette/php-generator >= 4),
27+ // disable type resolving to avoid using the root namespace.
28+ if (!method_exists (PhpNamespace::class, 'resolveName ' )) { // @phpstan-ignore-line
29+ $ this ->setTypeResolving (false );
30+ }
2631 }
2732}
You can’t perform that action at this time.
0 commit comments