A
A
anna_makeenko2020-03-18 01:38:12
PHP
anna_makeenko, 2020-03-18 01:38:12

What is the correct way to name classes?

1.

/src/

<?php

namespace App\Entity;

class Unit
{
}


<?php

namespace App\Entity;

class UnitType
{
}


2.

/src/

<?php

namespace App\Entity;

class Unit
{
}


/src/Unit

<?php

namespace App\Entity\Unit;

class Type
{
}


The second option is more logical, but there is information that the first is preferable, is it?

It seems like when using the first option, there will be conflicts when establishing links, for example

use App\Entity\Foo\Type;
use App\Entity\Bar\Type;


Those. will need to be written

use App\Entity\Foo\Type as FooType;
use App\Entity\Bar\Type as BarType;


I would like to get an answer from experienced developers. How is it better? Can't find PSR advice on this

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question