Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
19 | class UpdateAclCommand extends ContainerAwareCommand |
||
|
|||
20 | { |
||
21 | /** @var AclManager */ |
||
22 | private $aclManager; |
||
23 | |||
24 | /** @var PermissionMapInterface */ |
||
25 | private $permissionMap; |
||
26 | |||
27 | /** @var EntityManagerInterface */ |
||
28 | private $em; |
||
29 | |||
30 | /** @var array */ |
||
31 | private $roles; |
||
32 | |||
33 | public function __construct(/*AclManager*/ $aclManager = null, EntityManagerInterface $em = null, PermissionMapInterface $permissionMap = null, array $roles = null) |
||
34 | { |
||
35 | parent::__construct(); |
||
36 | |||
37 | View Code Duplication | if (!$aclManager instanceof AclManager) { |
|
38 | @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version symfony 3.4 and will be removed in symfony 4.0. If the command was registered by convention, make it a service instead. ', __METHOD__), E_USER_DEPRECATED); |
||
39 | |||
40 | $this->setName(null === $aclManager ? 'kuma:acl:update' : $aclManager); |
||
41 | |||
42 | return; |
||
43 | } |
||
44 | |||
45 | $this->aclManager = $aclManager; |
||
46 | $this->em = $em; |
||
47 | $this->permissionMap = $permissionMap; |
||
48 | $this->roles = $roles; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | protected function configure() |
||
55 | { |
||
56 | parent::configure(); |
||
57 | |||
58 | $this->setName('kuma:acl:update') |
||
59 | ->setDescription('Permissions update of ACL entries for all nodes for given role') |
||
60 | ->setHelp('The <info>kuma:acl:update</info> will update ACL entries for the nodes of the current project' . |
||
61 | 'with given role and permissions'); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | protected function execute(InputInterface $input, OutputInterface $output) |
||
106 | } |
||
107 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.