These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * Travis CI plugin for HiDev |
||
5 | * |
||
6 | * @link https://github.com/hiqdev/hidev-travis |
||
7 | * @package hidev-travis |
||
8 | * @license BSD-3-Clause |
||
9 | * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
||
10 | */ |
||
11 | |||
12 | namespace hidev\travis\controllers; |
||
13 | |||
14 | /** |
||
15 | * Goal for .travis.yml config file. |
||
16 | */ |
||
17 | class TravisYamlController extends \hidev\controllers\FileController |
||
18 | { |
||
19 | protected $_file = '.travis.yml'; |
||
20 | |||
21 | protected $_bin; |
||
22 | |||
23 | public function getBin() |
||
24 | { |
||
25 | if ($this->_bin === null) { |
||
26 | $this->_bin = $this->detectBin(); |
||
27 | } |
||
28 | |||
29 | return $this->_bin; |
||
30 | } |
||
31 | |||
32 | public function detectBin() |
||
33 | { |
||
34 | if ($this->takePackage()->fullName === 'hiqdev/hidev') { |
||
35 | return './bin/hidev'; |
||
36 | } |
||
37 | if ($this->takePackage()->hasRequireAny('hiqdev/hidev')) { |
||
38 | return './vendor/bin/hidev'; |
||
39 | } |
||
40 | |||
41 | return './hidev.phar'; |
||
42 | } |
||
43 | |||
44 | public function getBeforeInstall() |
||
45 | { |
||
46 | $commands = $this->get('before_install'); |
||
47 | if ($this->bin === './hidev.phar') { |
||
0 ignored issues
–
show
|
|||
48 | $commands[] = 'wget http://hiqdev.com/hidev/hidev.phar -O hidev.phar && chmod a+x hidev.phar'; |
||
49 | } else { |
||
50 | $commands[] = 'composer install --no-interaction'; |
||
51 | } |
||
52 | $commands[] = $this->getBin() . ' --version'; |
||
53 | $commands[] = $this->getBin() . ' travis/before_install'; |
||
54 | |||
55 | return array_values(array_unique($commands)); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Reorders config elements. |
||
60 | */ |
||
61 | public function actionSave() |
||
62 | { |
||
63 | $add_items = [ |
||
64 | 'sudo' => false, |
||
65 | 'before_install' => $this->getBeforeInstall(), |
||
66 | ]; |
||
67 | foreach (['install', 'before_script', 'script', 'after_success', 'after_failure', 'after_script'] as $event) { |
||
68 | if ($this->getTravis()->{$event}) { |
||
69 | $add_items[$event] = [$this->getBin() . ' travis/' . $event]; |
||
70 | } |
||
71 | } |
||
72 | $this->setItems($add_items); |
||
73 | $items = $this->_items; |
||
74 | $lang = $items['language']; |
||
75 | $lops = $items[$lang]; |
||
76 | unset($items['language'], $items[$lang]); |
||
77 | $this->_items = [ |
||
78 | 'language' => $lang, |
||
79 | $lang => $lops, |
||
80 | ] + $items; |
||
81 | return parent::actionSave(); |
||
82 | } |
||
83 | |||
84 | public function getTravis() |
||
85 | { |
||
86 | return $this->takeGoal('travis'); |
||
87 | } |
||
88 | } |
||
89 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.