1 | <?php |
||
22 | class InitController extends TemplateController |
||
23 | { |
||
24 | protected $_file = '.hidev/config.yml'; |
||
25 | |||
26 | public $name; |
||
27 | public $vendor; |
||
28 | public $package; |
||
29 | |||
30 | 3 | public function prepareData($name) |
|
31 | { |
||
32 | 3 | $this->name = $name; |
|
33 | 3 | list($vendor, $package) = explode('/', $name, 2); |
|
34 | 3 | if ($vendor) { |
|
35 | 3 | $this->vendor = $vendor; |
|
36 | 3 | $vendorPlugin = "$vendor/hidev-$vendor"; |
|
37 | try { |
||
38 | 3 | $exists = @file_get_contents("https://packagist.org/packages/$vendorPlugin.json"); |
|
39 | 3 | } catch (Exception $e) { |
|
40 | $exists = false; |
||
41 | } |
||
42 | 3 | if ($exists) { |
|
43 | 1 | $this->setItem('vendorRequire', $vendorPlugin); |
|
44 | 1 | $this->setItem('novendor', true); |
|
|
|||
45 | 1 | } |
|
46 | 3 | } |
|
47 | 3 | if ($package) { |
|
48 | 3 | $this->package = $package; |
|
49 | 3 | } |
|
50 | 3 | if (!$this->package || !$this->vendor) { |
|
51 | throw new InvalidParamException('Wrong vendor/package given: ' . $name); |
||
52 | } |
||
53 | 3 | } |
|
54 | |||
55 | 3 | public function actionPerform($name = null, $template = '.hidev/config') |
|
56 | { |
||
57 | 3 | $this->_template = $template; |
|
58 | 3 | $this->prepareData($name); |
|
59 | 3 | if (!file_exists($this->dirname)) { |
|
60 | 3 | mkdir($this->dirname); |
|
61 | 3 | } |
|
62 | 3 | if (!$this->nocomposer) { |
|
63 | 2 | $this->actionComposer(); |
|
64 | 2 | } |
|
65 | |||
66 | 3 | return parent::actionPerform(); |
|
67 | } |
||
68 | |||
69 | 2 | public function actionComposer() |
|
70 | { |
||
71 | 2 | $file = new File(['path' => 'composer.json']); |
|
72 | 2 | $data = array_filter([ |
|
73 | 2 | 'name' => $this->name, |
|
74 | 2 | 'type' => $this->getType(), |
|
75 | 2 | 'description' => $this->getTitle(), |
|
76 | 2 | 'keywords' => preg_split('/\s*,\s*/', $this->getKeywords()), |
|
77 | 2 | 'require-dev' => $this->getPlugins(), |
|
78 | 2 | 'license' => $this->getItem('license'), |
|
79 | 2 | ]); |
|
80 | 2 | $file->save($data); |
|
81 | 2 | $this->setItem('norequire', true); |
|
82 | 2 | } |
|
83 | |||
84 | 3 | public function options($actionId) |
|
88 | |||
89 | 3 | public function getType() |
|
93 | |||
94 | 3 | public function getTitle() |
|
98 | |||
99 | 3 | public function getKeywords() |
|
103 | |||
104 | /// TODO think of better getting nick |
||
105 | 3 | public function getNick() |
|
109 | |||
110 | 2 | public function getAuthor() |
|
114 | |||
115 | 2 | public function getEmail() |
|
119 | |||
120 | /** |
||
121 | * Returns list of plugins in composer requirements format: name => version. |
||
122 | * @return array |
||
123 | */ |
||
124 | 3 | public function getPlugins() |
|
138 | } |
||
139 |
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: