Can I inherit namespaces?

Asked

Viewed 21 times

0

I’m using composer with autoload in class namespaces, assuming I have the parent class Model:

Model.php

<?php
namespace App\Model;

use App\Utils;
use \PDO;

class Model {}

And the daughter class Item: Item.php

<?php
namespace App\Model;

class Item extends Model {}

Would there be some way for me to "inherit" imports of parent-class namespaces as well(App\Utils and \PDO)?

I ask because I would need to use several classes that use App\Utils and \PDO, and I would like to know if there is any way that I do not need to repeat every time the use in each class.

Thank you!

1 answer

1


I researched and studied on the subject, and did not find a "concrete" way to inherit namespasces. Because of this, I will make use of several namespaces on the same line:

<?php
namespasce App\Principal;

use App\Exemplo\{NamespaceUm, NamespaceDois, NamespaceTres}

...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.