for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Fabrica.
*
* (c) Alexandre Salomé <[email protected]>
* (c) Julien DIDIER <[email protected]>
* This source file is subject to the GPL license that is bundled
* with this source code in the file LICENSE.
*/
namespace Fabrica\Component\Requirements;
* @author Alexandre Salomé <[email protected]>
class FabricaRequirements extends RequirementCollection
{
public function __construct()
// PHP Version
$this->addRequirement(
version_compare(PHP_VERSION, '5.3.7', '>='),
'Your PHP must be greater than 5.3.7 ('.PHP_VERSION.' installed)'
);
// Git command
list($gitInstalled, $gitVersion) = $this->findGit();
$gitInstalled && version_compare($gitVersion, '1.7', '>='),
'Your git must be greater than 1.7 ('.$gitVersion.' installed)'
}
protected function findGit()
$proc = proc_open(
'git --version',
array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
), $pipes
$res = preg_match('/^git version ([0-9\.]+)(.+)?\n$/', stream_get_contents($pipes[1]), $vars);
$rtn = proc_close($proc);
$rtn
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
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.
$myVar
$higher
if (!$res) {
return array(false, 'none');
$version = $vars[1];
return array(true, $version);
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.