Check for conflicting imported classes with local classes.
1 | <?php |
||
2 | |||
3 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | /** @var \Apps\ActiveRecord\User $user */ |
||
6 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
7 | /** @var \Apps\Model\Front\Profile\FormAvatarUpload $model */ |
||
8 | |||
9 | $this->layout('_layouts/default', [ |
||
10 | 'title' => __('Avatar change'), |
||
11 | 'breadcrumbs' => [ |
||
12 | Url::to('main/index') => __('Home'), |
||
13 | Url::to('profile/show', [\App::$User->identity()->getId()]) => __('Profile'), |
||
14 | __('Avatar settings') |
||
15 | ] |
||
16 | ]); |
||
17 | ?> |
||
18 | |||
19 | <?php $this->start('body') ?> |
||
20 | |||
21 | <?php $this->insert('profile/menus/settings') ?> |
||
22 | |||
23 | <h1><?= __('Avatar settings') ?></h1> |
||
24 | <hr /> |
||
25 | |||
26 | <?php $form = $this->form($model, ['enctype' => 'multipart/form-data', 'method' => 'POST']) ?> |
||
27 | |||
28 | <?= $form->start() ?> |
||
29 | |||
30 | <?= $form->fieldset()->file('file', null, __('Select jpg, png or gif avatar')) ?> |
||
31 | <?= $form->button()->submit(__('Change'), ['class' => 'btn btn-primary']) ?> |
||
32 | |||
33 | <?= $form->stop() ?> |
||
34 | |||
35 | <?php $this->stop() ?> |
||
36 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: