-
-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassType->getNamespace() should not be deprecated #134
Comments
To create a new class, I create the $namespace = new PhpNamespace('Testing');
$namespace->addUse(\DateTimeInterface::class);
$class = $namespace->addClass('Test'); To create from existing, you can import the $file = PhpFile::fromCode(file_get_contents('src/'.str_replace('\\', '/', $myClass).'.php));
$namespace = $file->getNamespaces()[0];
$class = $namespace->getClasses()[0];
$namespace->addUse(DateTimeInterface::class);
|
@GromNaN No, i want to use ClassType::from, not PhpFile::fromCode, and also I'd like to avoid [0] when I can be sure that one class will always have one or no namespace. |
What do you do with the |
Ok, let's forget about getting rid of ClassType::from. (but it makes me cry) If i use Also, using [0] indexes makes for a code that is way harder to statically analyze. I really don't see the benefit of removing this method. It makes things so much harder for my use case. |
Seconded, I can't see how I would achieve what I do in the following code easily. It would require way more complexity, passing around the namespace with the |
I can't find a substitution for this piece of code without using the
getNamespace()
method:Alternative method should at least be mentioned in documention.
The text was updated successfully, but these errors were encountered: