for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* Task runner, code generator and build tool for easier continuos integration
*
* @link https://github.com/hiqdev/hidev
* @package hidev
* @license BSD-3-Clause
* @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
*/
namespace hidev\controllers;
/**
* Goal for HiDev own version management: show and bump.
class VersionController extends FileController
{
protected $_file = '@hidev/../version';
public $version;
public function actionMake()
$v = trim($this->getFile()->read());
list($version, $date, $time, $zone, $hash) = explode(' ', $v);
$zone
list($first,,$third)
This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.
list(...)
Consider the following code example.
<?php function returnThreeValues() { return array('a', 'b', 'c'); } list($a, $b, $c) = returnThreeValues(); print $a . " - " . $c;
Only the variables $a and $c are used. There was no need to assign $b.
$a
$c
$b
Instead, the list call could have been.
list($a,, $c) = returnThreeValues();
echo "HiDev version $version $date $time $hash\n";
}
public function actionBump($version = null)
$gitinfo = reset($this->exec('git', ['log', '-n', 1, '--pretty=%ai %H']));
$this->exec('git', array... 1, '--pretty=%ai %H'))
reset()
$array
array('log', '-n', 1, '--pretty=%ai %H')
array<integer,string|int...integer","3":"string"}>
string
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$version = $version ?: $this->version ?: $this->takeGoal('bump')->version ?: 'dev';
$this->getFile()->write("$version $gitinfo\n");
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.