← All changes
|
vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php
+11
-12
3.0.0
→
trunk
View file →
| @@ -1,9 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Composer\Installers; |
| 3 | 4 | |
| 4 | 5 | class PxcmsInstaller extends BaseInstaller |
| 5 | 6 | { |
| 7 | + /** @var array<string, string> */ | |
| 6 | 8 | protected $locations = array( |
| 7 | 9 | 'module' => 'app/Modules/{$name}/', |
| 8 | 10 | 'theme' => 'themes/{$name}/', |
| 9 | 11 | ); |
| @@ -9,14 +11,10 @@ | ||
| 9 | 11 | ); |
| 10 | 12 | |
| 11 | 13 | /** |
| 12 | 14 | * Format package name. |
| 13 | - * | |
| 14 | - * @param array $vars | |
| 15 | - * | |
| 16 | - * @return array | |
| 17 | 15 | */ |
| 18 | - public function inflectPackageVars($vars) | |
| 16 | + public function inflectPackageVars(array $vars): array | |
| 19 | 17 | { |
| 20 | 18 | if ($vars['type'] === 'pxcms-module') { |
| 21 | 19 | return $this->inflectModuleVars($vars); |
| 22 | 20 | } |
| @@ -30,15 +28,16 @@ | ||
| 30 | 28 | |
| 31 | 29 | /** |
| 32 | 30 | * For package type pxcms-module, cut off a trailing '-plugin' if present. |
| 33 | 31 | * |
| 34 | - * return string | |
| 32 | + * @param array<string, string> $vars | |
| 33 | + * @return array<string, string> | |
| 35 | 34 | */ |
| 36 | - protected function inflectModuleVars($vars) | |
| 35 | + protected function inflectModuleVars(array $vars): array | |
| 37 | 36 | { |
| 38 | 37 | $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) |
| 39 | 38 | $vars['name'] = str_replace('module-', '', $vars['name']); // strip out module- |
| 40 | - $vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module | |
| 39 | + $vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']); // strip out -module | |
| 41 | 40 | $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s |
| 42 | 41 | $vars['name'] = ucwords($vars['name']); // make module name camelcased |
| 43 | 42 | |
| 44 | 43 | return $vars; |
| @@ -43,19 +42,19 @@ | ||
| 43 | 42 | |
| 44 | 43 | return $vars; |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | - | |
| 48 | 46 | /** |
| 49 | 47 | * For package type pxcms-module, cut off a trailing '-plugin' if present. |
| 50 | 48 | * |
| 51 | - * return string | |
| 49 | + * @param array<string, string> $vars | |
| 50 | + * @return array<string, string> | |
| 52 | 51 | */ |
| 53 | - protected function inflectThemeVars($vars) | |
| 52 | + protected function inflectThemeVars(array $vars): array | |
| 54 | 53 | { |
| 55 | 54 | $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) |
| 56 | 55 | $vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme- |
| 57 | - $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme | |
| 56 | + $vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); // strip out -theme | |
| 58 | 57 | $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s |
| 59 | 58 | $vars['name'] = ucwords($vars['name']); // make module name camelcased |
| 60 | 59 | |
| 61 | 60 | return $vars; |