PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.3 4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 All 66 releases
← All changes | vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php +15 -6 3.0.0 → trunk View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace Composer\Installers;
3 4
4 5 /**
5 6 * Plugin/theme installer for majima
@@ -6,8 +7,9 @@
6 7 * @author David Neustadt
7 8 */
8 9 class MajimaInstaller extends BaseInstaller
9 10 {
11 + /** @var array<string, string> */
10 12 protected $locations = array(
11 13 'plugin' => 'plugins/{$name}/',
12 14 );
13 15
@@ -12,12 +14,13 @@
12 14 );
13 15
14 16 /**
15 17 * Transforms the names
16 - * @param array $vars
17 - * @return array
18 + *
19 + * @param array<string, string> $vars
20 + * @return array<string, string>
18 21 */
19 - public function inflectPackageVars($vars)
22 + public function inflectPackageVars(array $vars): array
20 23 {
21 24 return $this->correctPluginName($vars);
22 25 }
23 26
@@ -22,16 +25,22 @@
22 25 }
23 26
24 27 /**
25 28 * Change hyphenated names to camelcase
26 - * @param array $vars
27 - * @return array
29 + *
30 + * @param array<string, string> $vars
31 + * @return array<string, string>
28 32 */
29 - private function correctPluginName($vars)
33 + private function correctPluginName(array $vars): array
30 34 {
31 35 $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
32 36 return strtoupper($matches[0][1]);
33 37 }, $vars['name']);
38 +
39 + if (null === $camelCasedName) {
40 + throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
41 + }
42 +
34 43 $vars['name'] = ucfirst($camelCasedName);
35 44 return $vars;
36 45 }
37 46 }