Completed
Push — master ( 896e5a...43f4f7 )
by Andrii
02:34
created

VersionController::actionMake()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * Task runner, code generator and build tool for easier continuos integration
5
 *
6
 * @link      https://github.com/hiqdev/hidev
7
 * @package   hidev
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\controllers;
13
14
/**
15
 * Goal for HiDev own version management: show and bump.
16
 */
17
class VersionController extends FileController
18
{
19
    protected $_file = '@hidev/../version';
20
21
    public $version;
22
    public $date;
23
    public $time;
24
    public $zone;
25
    public $hash;
26
27
    public function init()
28
    {
29
        $v = trim($this->getFile()->read());
30
        list($this->version, $this->date, $this->time, $this->zone, $this->hash) = explode(' ', $v);
31
    }
32
33
    public function actionMake()
34
    {
35
        echo "HiDev version $this->version $this->date $this->time $this->hash\n";
36
    }
37
38
    public function actionBump($version = null)
39
    {
40
        $gitinfo = reset($this->exec('git', ['log', '-n', 1, '--pretty=%ai %H']));
0 ignored issues
show
Bug introduced by
$this->exec('git', array... 1, '--pretty=%ai %H')) cannot be passed to reset() as the parameter $array expects a reference.
Loading history...
Documentation introduced by
array('log', '-n', 1, '--pretty=%ai %H') is of type array<integer,string|int...integer","3":"string"}>, but the function expects a 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);
Loading history...
41
        $version = $version ?: $this->takeGoal('bump')->version ?: $this->version ?: 'dev';
42
        $this->getFile()->write("$version $gitinfo\n");
43
    }
44
}
45