1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Automation tool mixed with code generator for easier continuous development |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hidev |
7
|
|
|
* @package hidev |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hidev\controllers; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Goal for version file management. |
16
|
|
|
*/ |
17
|
|
|
class VersionController extends FileController |
18
|
|
|
{ |
19
|
|
|
protected $_file = 'version'; |
20
|
|
|
|
21
|
|
|
public $fileVersion; |
22
|
|
|
|
23
|
|
|
public $version; |
24
|
|
|
public $date; |
25
|
|
|
public $time; |
26
|
|
|
public $zone; |
27
|
|
|
public $hash; |
28
|
|
|
public $commit; |
29
|
|
|
|
30
|
|
|
public function init() |
31
|
|
|
{ |
32
|
|
|
if ($this->exists()) { |
33
|
|
|
$line = trim($this->getFile()->read()); |
34
|
|
|
list($this->version, $this->date, $this->time, $this->zone, $this->hash) = explode(' ', $line); |
35
|
|
|
$this->fileVersion = $this->version; |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function actionMake($version = null) |
40
|
|
|
{ |
41
|
|
|
$this->setVersion($version); |
42
|
|
|
$this->actionLoad(); |
43
|
|
|
$this->actionSave(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function actionLoad() |
47
|
|
|
{ |
48
|
|
|
$line = trim($this->exec('git', ['log', '-n', '1', '--pretty=%ai %H %s'])[0]); |
|
|
|
|
49
|
|
|
list($this->date, $this->time, $this->zone, $this->hash, $this->commit) = explode(' ', $line, 5); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function actionSave() |
53
|
|
|
{ |
54
|
|
|
$this->getFile()->write(implode(' ', [$this->version, $this->date, $this->time, $this->zone, $this->hash]) . "\n"); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function setVersion($version = null) |
58
|
|
|
{ |
59
|
|
|
$this->version = $this->getVersion($version); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getVersion($version = null) |
63
|
|
|
{ |
64
|
|
|
return $version ?: $this->version ?: 'dev'; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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: