For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 12.
The PSR-1: Basic Coding Standard recommends that a file should either introduce
new symbols, that is classes, functions, constants or similar, or have side effects.
Side effects are anything that executes logic, like for example printing output,
changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state
of an application. It also promotes a cleaner style of programming and makes your code
less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the
PSR-1.
Loading history...
2
3
/*
4
* Plugin Name: WP Symfony Form
5
* Plugin URI: http://lin3s.com
6
* Description: WordPress plugin to allow using Symfony form component with ease
The call to the method WPSymfonyForm::__construct() seems un-needed as the method has no side-effects.
PHP Analyzer performs a side-effects analysis of your code. A side-effect is
basically anything that might be visible after the scope of the method is left.
If we look at the getEmail() method, we can see that it has no side-effect.
Whether you call this method or not, no future calls to other methods are affected
by this. As such code as the following is useless:
$user=newUser();$user->getEmail();// This line could safely be removed as it has no effect.
On the hand, if we look at the setEmail(), this method _has_ side-effects.
In the following case, we could not remove the method call:
$user=newUser();$user->setEmail('email@domain');// This line has a side-effect (it changes an// instance variable).
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.