BurningFlipside /
VolunteerSystem
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | require_once('class.SecurePage.php'); |
||
| 3 | require_once('class.FlipSession.php'); |
||
| 4 | require_once('app/VolunteerAutoload.php'); |
||
| 5 | class VolunteerPage extends SecurePage |
||
|
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. Loading history...
|
|||
| 6 | { |
||
| 7 | public $volunteerRoot; |
||
| 8 | |||
| 9 | function __construct($title) |
||
|
0 ignored issues
–
show
__construct uses the super-global variable $_SERVER which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
|
|||
| 10 | { |
||
| 11 | parent::__construct($title); |
||
| 12 | $root = $_SERVER['DOCUMENT_ROOT']; |
||
| 13 | $script_dir = dirname(__FILE__); |
||
| 14 | $this->volunteerRoot = substr($script_dir, strlen($root)); |
||
| 15 | $this->addJSByURI($this->volunteerRoot.'/js/volunteer.js', false); |
||
| 16 | } |
||
| 17 | |||
| 18 | function print_page($header=true) |
||
|
0 ignored issues
–
show
|
|||
| 19 | { |
||
| 20 | if($this->user === false || $this->user === null) |
||
| 21 | { |
||
| 22 | $this->body = ' |
||
| 23 | <div id="content"> |
||
| 24 | <h1>You must <a href="https://profiles.burningflipside.com/login.php?return='.$this->current_url().'">log in <span class="fa fa-sign-in"></span></a> to access the Burning Flipside Volunteer system!</h1> |
||
|
0 ignored issues
–
show
The method
WebPage::current_url() has been deprecated with message: 1.0.0 This funciton is deprectated and will be remoted. Please use currentURL() instead
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. Loading history...
|
|||
| 25 | </div>'; |
||
| 26 | $this->add_login_form(); |
||
| 27 | } |
||
| 28 | parent::print_page($header); |
||
|
0 ignored issues
–
show
The call to
SecurePage::print_page() has too many arguments starting with $header.
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
The method
WebPage::print_page() has been deprecated with message: 1.0.0 This funciton is deprectated and will be remoted. Please use printPage() instead
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. Loading history...
|
|||
| 29 | } |
||
| 30 | |||
| 31 | function isAdmin() |
||
|
0 ignored issues
–
show
|
|||
| 32 | { |
||
| 33 | if($this->user === false || $this->user === null) |
||
| 34 | { |
||
| 35 | return false; |
||
| 36 | } |
||
| 37 | return $this->user->isInGroupNamed('VolunteerAdmins'); |
||
| 38 | } |
||
| 39 | |||
| 40 | function isLead() |
||
|
0 ignored issues
–
show
|
|||
| 41 | { |
||
| 42 | if($this->user === false || $this->user === null) |
||
| 43 | { |
||
| 44 | return false; |
||
| 45 | } |
||
| 46 | return $this->user->isInGroupNamed('Leads'); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | ?> |
||
|
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|
|||
| 50 |
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.