These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Travis CI plugin for HiDev |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hidev-travis |
||
6 | * @package hidev-travis |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hidev\travis\components; |
||
12 | |||
13 | /** |
||
14 | * `.travis.yml` config file. |
||
15 | */ |
||
16 | class TravisYaml extends \hidev\base\ConfigFile |
||
17 | { |
||
18 | protected $_file = '.travis.yml'; |
||
19 | |||
20 | protected $_bin; |
||
21 | |||
22 | public $sudo = false; |
||
23 | |||
24 | public function getBin() |
||
25 | { |
||
26 | if ($this->_bin === null) { |
||
27 | $this->_bin = $this->detectBin(); |
||
28 | } |
||
29 | |||
30 | return $this->_bin; |
||
31 | } |
||
32 | |||
33 | public function detectBin() |
||
34 | { |
||
35 | if ($this->take('package')->fullName === 'hiqdev/hidev') { |
||
36 | return './bin/hidev'; |
||
37 | } |
||
38 | if ($this->take('package')->hasRequireAny('hiqdev/hidev')) { |
||
39 | return './vendor/bin/hidev'; |
||
40 | } |
||
41 | |||
42 | return './hidev.phar'; |
||
43 | } |
||
44 | |||
45 | public function getBeforeInstall() |
||
46 | { |
||
47 | $commands = $this->get('before_install'); |
||
48 | if ($this->getItem('language') !== 'php') { |
||
49 | $this->sudo = true; |
||
50 | $commands[] = 'sudo add-apt-repository --yes ppa:ondrej/php'; |
||
51 | $commands[] = 'sudo apt-get update'; |
||
52 | $commands[] = 'sudo apt-get install php5.6-cli php5.6-mbstring'; |
||
53 | $commands[] = 'env php -v'; |
||
54 | } |
||
55 | if ($this->bin === './hidev.phar') { |
||
0 ignored issues
–
show
|
|||
56 | $commands[] = 'wget http://hiqdev.com/hidev/hidev.phar -O hidev.phar && chmod a+x hidev.phar'; |
||
57 | } else { |
||
58 | $commands[] = 'composer install --no-interaction'; |
||
59 | } |
||
60 | $commands[] = $this->getBin() . ' --version'; |
||
61 | $commands[] = $this->getBin() . ' travis/before-install'; |
||
62 | |||
63 | return array_values(array_unique($commands)); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Reorders config elements. |
||
68 | */ |
||
69 | public function save() |
||
70 | { |
||
71 | $this->addActionItems(); |
||
72 | $this->prependLanguageOptions(); |
||
73 | |||
74 | return parent::save(); |
||
75 | } |
||
76 | |||
77 | public function addActionItems() |
||
78 | { |
||
79 | $add_items = [ |
||
80 | 'sudo' => false, |
||
81 | 'before_install' => $this->getBeforeInstall(), |
||
82 | ]; |
||
83 | foreach (['install', 'before-script', 'script', 'after-success', 'after-failure', 'after-script'] as $event) { |
||
84 | $tname = strtr($event, '-', '_'); |
||
85 | if ($this->take('travis')->{$tname}) { |
||
86 | $add_items[$tname] = [$this->getBin() . ' travis/' . $event]; |
||
87 | } |
||
88 | } |
||
89 | $this->setItems($add_items); |
||
90 | } |
||
91 | |||
92 | public function prependLanguageOptions() |
||
93 | { |
||
94 | $items = $this->_items; |
||
95 | $language = $items['language'] ?: $this->take('package')->getLanguage(); |
||
96 | $lang_ops = $items[$language]; |
||
97 | unset($items['language'], $items[$language]); |
||
98 | $this->_items = [ |
||
99 | 'language' => $language, |
||
100 | $language => $lang_ops, |
||
101 | ] + $items; |
||
102 | $this->setItem('sudo', $this->sudo); |
||
0 ignored issues
–
show
$this->sudo is of type boolean , but the function expects a array|null .
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...
|
|||
103 | } |
||
104 | } |
||
105 |
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.