Extending Base Classes

Hi guys.

As we know, there are some empty classes in Yii2 (like helpers\Html) extending their ‘base’ parents (like helpers\BaseHtml).

AFAIR this was done to allow easy overriding core code.

What’s the right way of doing that?

Should I create my own Html class using the same namespace (yii\helpers\Html) and then inject it using classmap?

Yes.

So basically I’m ruining PSR autoloading (namespace is out of sync with file system) and technically I have two similar classes in one project (that makes IDE to panic).

Is there a way to prevent this problems?

No. PSR-4 allows it.