irishdan /
NotificationBundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace IrishDan\NotificationBundle\DependencyInjection\Factory\Broadcaster; |
||
| 4 | |||
| 5 | use IrishDan\NotificationBundle\DependencyInjection\Factory\BroadcasterFactoryInterface; |
||
| 6 | use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
||
| 7 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 8 | use Symfony\Component\DependencyInjection\DefinitionDecorator; |
||
| 9 | use Symfony\Component\DependencyInjection\Reference; |
||
| 10 | |||
| 11 | View Code Duplication | class BroadcasterFactory implements BroadcasterFactoryInterface |
|
|
0 ignored issues
–
show
This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 12 | { |
||
| 13 | public function getKey() |
||
| 14 | { |
||
| 15 | return 'adapter'; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function create(ContainerBuilder $container, $id, array $config) |
||
| 19 | { |
||
| 20 | $container |
||
| 21 | ->setDefinition($id, new DefinitionDecorator('oneup_flysystem.cache.adapter')) |
||
|
0 ignored issues
–
show
The class
Symfony\Component\Depend...ion\DefinitionDecorator has been deprecated with message: The DefinitionDecorator class is deprecated since version 3.3 and will be removed in 4.0. Use the Symfony\Component\DependencyInjection\ChildDefinition class instead.
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. Loading history...
|
|||
| 22 | ->replaceArgument(0, new Reference(sprintf('oneup_flysystem.%s_adapter', $config['adapter']))) |
||
| 23 | // ->replaceArgument(1, $config['key']) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 24 | // ->replaceArgument(2, $config['expires']) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 25 | ; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function addConfiguration(NodeDefinition $node) |
||
| 29 | { |
||
| 30 | $node |
||
|
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
Symfony\Component\Config...\Builder\NodeDefinition as the method children() does only exist in the following sub-classes of Symfony\Component\Config...\Builder\NodeDefinition: Symfony\Component\Config...der\ArrayNodeDefinition. Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 31 | ->children() |
||
| 32 | ->scalarNode('adapter')->isRequired()->end() |
||
| 33 | ->scalarNode('key')->defaultValue('flysystem')->end() |
||
| 34 | ->scalarNode('expires')->defaultNull()->end() |
||
| 35 | ->end() |
||
| 36 | ; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.