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 ApplyAclCommand extends ContainerAwareCommand |
||
|
|||
20 | { |
||
21 | /** |
||
22 | * @var EntityManager |
||
23 | */ |
||
24 | private $em = null; |
||
25 | |||
26 | /** |
||
27 | * @var Shell |
||
28 | */ |
||
29 | private $shellHelper = null; |
||
30 | |||
31 | /** @var AclManager */ |
||
32 | private $aclManager = null; |
||
33 | |||
34 | public function __construct(/*AclManager*/ $aclManager = null, EntityManagerInterface $em = null, Shell $shellHelper = null) |
||
35 | { |
||
36 | parent::__construct(); |
||
37 | |||
38 | View Code Duplication | if (!$aclManager instanceof AclManager) { |
|
39 | @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); |
||
40 | |||
41 | $this->setName(null === $aclManager ? 'kuma:acl:apply' : $aclManager); |
||
42 | |||
43 | return; |
||
44 | } |
||
45 | |||
46 | $this->aclManager = $aclManager; |
||
47 | $this->em = $em; |
||
48 | $this->shellHelper = $shellHelper; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Configures the command. |
||
53 | */ |
||
54 | protected function configure() |
||
55 | { |
||
56 | parent::configure(); |
||
57 | |||
58 | $this->setName('kuma:acl:apply') |
||
59 | ->setDescription('Apply ACL changeset.') |
||
60 | ->setHelp('The <info>kuma:acl:apply</info> can be used to apply an ACL changeset recursively, changesets are fetched from the database.'); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Apply the {@link AclChangeSet} with status {@link AclChangeSet::STATUS_NEW} to their entities |
||
65 | * |
||
66 | * @param InputInterface $input The input |
||
67 | * @param OutputInterface $output The output |
||
68 | * |
||
69 | * @return int |
||
70 | */ |
||
71 | protected function execute(InputInterface $input, OutputInterface $output) |
||
92 | |||
93 | /** |
||
94 | * @return bool |
||
95 | */ |
||
96 | private function isRunning() |
||
111 | } |
||
112 |
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.