nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Missing support for importing namespaces in PhpFile #38

Closed Nazariy closed 5 years ago

Nazariy commented 6 years ago

Seems like it's not possible to import namespaces via Nette\PhpGenerator\PhpFile for example:

<?php
use My\Full\Classname as Another, My\Full\NSname;

$obj = new Another; // instantiates object of class My\Full\Classname
NSname\subns\func(); // calls function My\Full\NSname\subns\func
?>

http://php.net/manual/en/language.namespaces.importing.php

Currently it's only possible via PhpNamespace class

duxthefux commented 5 years ago

Jep seems like.

+1 for that

JanTvrdik commented 5 years ago

Can't use just use PhpNamespace with empty namespace?

duxthefux commented 5 years ago

can you give an example? @JanTvrdik