← All changes
|
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php
+10
-9
3.0.0
→
trunk
View file →
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Composer\Installers; |
| 3 | 4 | |
| 4 | 5 | use Composer\DependencyResolver\Pool; |
| 5 | 6 | use Composer\Semver\Constraint\Constraint; |
| @@ -5,8 +6,9 @@ | ||
| 5 | 6 | use Composer\Semver\Constraint\Constraint; |
| 6 | 7 | |
| 7 | 8 | class CakePHPInstaller extends BaseInstaller |
| 8 | 9 | { |
| 10 | + /** @var array<string, string> */ | |
| 9 | 11 | protected $locations = array( |
| 10 | 12 | 'plugin' => 'Plugin/{$name}/', |
| 11 | 13 | ); |
| 12 | 14 | |
| @@ -12,9 +14,9 @@ | ||
| 12 | 14 | |
| 13 | 15 | /** |
| 14 | 16 | * Format package name to CamelCase |
| 15 | 17 | */ |
| 16 | - public function inflectPackageVars($vars) | |
| 18 | + public function inflectPackageVars(array $vars): array | |
| 17 | 19 | { |
| 18 | 20 | if ($this->matchesCakeVersion('>=', '3.0.0')) { |
| 19 | 21 | return $vars; |
| 20 | 22 | } |
| @@ -20,9 +22,9 @@ | ||
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | $nameParts = explode('/', $vars['name']); |
| 23 | 25 | foreach ($nameParts as &$value) { |
| 24 | - $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); | |
| 26 | + $value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value)); | |
| 25 | 27 | $value = str_replace(array('-', '_'), ' ', $value); |
| 26 | 28 | $value = str_replace(' ', '', ucwords($value)); |
| 27 | 29 | } |
| 28 | 30 | $vars['name'] = implode('/', $nameParts); |
| @@ -32,9 +34,9 @@ | ||
| 32 | 34 | |
| 33 | 35 | /** |
| 34 | 36 | * Change the default plugin location when cakephp >= 3.0 |
| 35 | 37 | */ |
| 36 | - public function getLocations() | |
| 38 | + public function getLocations(string $frameworkType): array | |
| 37 | 39 | { |
| 38 | 40 | if ($this->matchesCakeVersion('>=', '3.0.0')) { |
| 39 | 41 | $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
| 40 | 42 | } |
| @@ -43,21 +45,20 @@ | ||
| 43 | 45 | |
| 44 | 46 | /** |
| 45 | 47 | * Check if CakePHP version matches against a version |
| 46 | 48 | * |
| 47 | - * @param string $matcher | |
| 48 | - * @param string $version | |
| 49 | - * @return bool | |
| 50 | - * @phpstan-param Constraint::STR_OP_* $matcher | |
| 49 | + * @phpstan-param '='|'=='|'<'|'<='|'>'|'>='|'<>'|'!=' $matcher | |
| 51 | 50 | */ |
| 52 | - protected function matchesCakeVersion($matcher, $version) | |
| 51 | + protected function matchesCakeVersion(string $matcher, string $version): bool | |
| 53 | 52 | { |
| 54 | 53 | $repositoryManager = $this->composer->getRepositoryManager(); |
| 55 | - if (! $repositoryManager) { | |
| 54 | + /** @phpstan-ignore-next-line */ | |
| 55 | + if (!$repositoryManager) { | |
| 56 | 56 | return false; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $repos = $repositoryManager->getLocalRepository(); |
| 60 | + /** @phpstan-ignore-next-line */ | |
| 60 | 61 | if (!$repos) { |
| 61 | 62 | return false; |
| 62 | 63 | } |
| 63 | 64 | |