These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of Dedipanel project |
||
5 | * |
||
6 | * (c) 2010-2015 Dedipanel <http://www.dedicated-panel.net> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace DP\Core\MachineBundle\Form; |
||
13 | |||
14 | use DP\Core\MachineBundle\Entity\MachineRepository; |
||
15 | use DP\Core\UserBundle\Service\UserGroupResolver; |
||
16 | use Symfony\Component\Form\AbstractType; |
||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
18 | use Symfony\Component\Security\Core\SecurityContext; |
||
19 | use DP\Core\UserBundle\Entity\User; |
||
20 | |||
21 | class MachineEntityType extends AbstractType |
||
22 | { |
||
23 | private $repository; |
||
24 | private $groupResolver; |
||
25 | private $context; |
||
26 | private $choices; |
||
27 | |||
28 | public function __construct(MachineRepository $repository, UserGroupResolver $groupResolver, SecurityContext $context) |
||
29 | { |
||
30 | $this->repository = $repository; |
||
31 | $this->groupResolver = $groupResolver; |
||
32 | $this->context = $context; |
||
33 | } |
||
34 | |||
35 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
||
36 | { |
||
37 | $choices = array(); |
||
0 ignored issues
–
show
|
|||
38 | |||
39 | if ($this->context->isGranted(User::ROLE_SUPER_ADMIN)) { |
||
40 | $choices = $this->repository->findAll(); |
||
41 | } |
||
42 | else { |
||
43 | $groups = $this->groupResolver->getAccessibleGroupsId(); |
||
44 | $choices = $this->repository->findByGroups($groups); |
||
45 | } |
||
46 | |||
47 | $resolver |
||
48 | ->setDefaults(array( |
||
49 | 'label' => 'game.selectMachine', |
||
50 | 'class' => 'DPMachineBundle:Machine', |
||
51 | 'choices' => $choices, |
||
52 | )) |
||
53 | ; |
||
54 | } |
||
55 | |||
56 | public function getParent() |
||
57 | { |
||
58 | return 'entity'; |
||
59 | } |
||
60 | |||
61 | public function getName() |
||
62 | { |
||
63 | return 'dedipanel_machine_entity'; |
||
64 | } |
||
65 | } |
||
66 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.