Add PHPStan configuration for Symfony4 tests

- Created a new phpstan.neon file in the Symfony4 tests directory.
- Configured paths and excluded Symfony3 directory.
- Added bootstrap files for autoloading.
- Set dynamic constant names and adjusted reporting settings.
- Established PHPStan level to 6 for stricter analysis.
This commit is contained in:
2026-02-09 23:14:09 +01:00
parent 58947ad589
commit 3bd8164d3d
169 changed files with 4964 additions and 3877 deletions

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class AglInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'More/{$name}/',
);
@@ -10,12 +12,18 @@ class AglInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
$name = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
return strtoupper($matches[1]);
}, $vars['name']);
if (null === $name) {
throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
}
$vars['name'] = $name;
return $vars;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Composer\Installers;
class AkauntingInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class AnnotateCmsInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'addons/modules/{$name}/',
'component' => 'addons/components/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class AsgardInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'Modules/{$name}/',
'theme' => 'Themes/{$name}/'
@@ -14,9 +16,8 @@ class AsgardInstaller extends BaseInstaller
* For package type asgard-module, cut off a trailing '-plugin' if present.
*
* For package type asgard-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'asgard-module') {
return $this->inflectPluginVars($vars);
@@ -29,18 +30,26 @@ class AsgardInstaller extends BaseInstaller
return $vars;
}
protected function inflectPluginVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectPluginVars(array $vars): array
{
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
protected function inflectThemeVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class AttogramInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
use Composer\IO\IOInterface;
@@ -7,19 +8,19 @@ use Composer\Package\PackageInterface;
abstract class BaseInstaller
{
/** @var array<string, string> */
protected $locations = array();
/** @var Composer */
protected $composer;
/** @var PackageInterface */
protected $package;
/** @var IOInterface */
protected $io;
/**
* Initializes base installer.
*
* @param PackageInterface $package
* @param Composer $composer
* @param IOInterface $io
*/
public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
public function __construct(PackageInterface $package, Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->package = $package;
@@ -28,12 +29,8 @@ abstract class BaseInstaller
/**
* Return the install path based on package type.
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string
{
$type = $this->package->getType();
@@ -52,18 +49,16 @@ abstract class BaseInstaller
$availableVars['name'] = $extra['installer-name'];
}
if ($this->composer->getPackage()) {
$extra = $this->composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
if ($customPath !== false) {
return $this->templatePath($customPath, $availableVars);
}
$extra = $this->composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
if ($customPath !== false) {
return $this->templatePath($customPath, $availableVars);
}
}
$packageType = substr($type, strlen($frameworkType) + 1);
$locations = $this->getLocations();
$locations = $this->getLocations($frameworkType);
if (!isset($locations[$packageType])) {
throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
}
@@ -77,7 +72,7 @@ abstract class BaseInstaller
* @param array<string, string> $vars This will normally receive array{name: string, vendor: string, type: string}
* @return array<string, string>
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
return $vars;
}
@@ -87,7 +82,7 @@ abstract class BaseInstaller
*
* @return array<string, string> map of package types => install path
*/
public function getLocations()
public function getLocations(string $frameworkType)
{
return $this->locations;
}
@@ -95,11 +90,9 @@ abstract class BaseInstaller
/**
* Replace vars in a path
*
* @param string $path
* @param array<string, string> $vars
* @return string
*/
protected function templatePath($path, array $vars = array())
protected function templatePath(string $path, array $vars = array()): string
{
if (strpos($path, '{') !== false) {
extract($vars);
@@ -117,13 +110,10 @@ abstract class BaseInstaller
/**
* Search through a passed paths array for a custom install path.
*
* @param array $paths
* @param string $name
* @param string $type
* @param string $vendor = NULL
* @param array<string, string[]|string> $paths
* @return string|false
*/
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
protected function mapCustomInstallPaths(array $paths, string $name, string $type, ?string $vendor = null)
{
foreach ($paths as $path => $names) {
$names = (array) $names;
@@ -134,4 +124,14 @@ abstract class BaseInstaller
return false;
}
protected function pregReplace(string $pattern, string $replacement, string $subject): string
{
$result = preg_replace($pattern, $replacement, $subject);
if (null === $result) {
throw new \RuntimeException('Failed to run preg_replace with '.$pattern.': '.preg_last_error());
}
return $result;
}
}

View File

@@ -9,9 +9,9 @@ use Composer\Util\Filesystem;
* - `bitrix-d7-module` — copy the module to directory `bitrix/modules/<vendor>.<name>`.
* - `bitrix-d7-component` — copy the component to directory `bitrix/components/<vendor>/<name>`.
* - `bitrix-d7-template` — copy the template to directory `bitrix/templates/<vendor>_<name>`.
*
*
* You can set custom path to directory with Bitrix kernel in `composer.json`:
*
*
* ```json
* {
* "extra": {
@@ -25,6 +25,7 @@ use Composer\Util\Filesystem;
*/
class BitrixInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
@@ -35,15 +36,13 @@ class BitrixInstaller extends BaseInstaller
);
/**
* @var array Storage for informations about duplicates at all the time of installation packages.
* @var string[] Storage for informations about duplicates at all the time of installation packages.
*/
private static $checkedDuplicates = array();
/**
* {@inheritdoc}
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
/** @phpstan-ignore-next-line */
if ($this->composer->getPackage()) {
$extra = $this->composer->getPackage()->getExtra();
@@ -62,7 +61,7 @@ class BitrixInstaller extends BaseInstaller
/**
* {@inheritdoc}
*/
protected function templatePath($path, array $vars = array())
protected function templatePath(string $path, array $vars = array()): string
{
$templatePath = parent::templatePath($path, $vars);
$this->checkDuplicates($templatePath, $vars);
@@ -73,10 +72,9 @@ class BitrixInstaller extends BaseInstaller
/**
* Duplicates search packages.
*
* @param string $path
* @param array $vars
* @param array<string, string> $vars
*/
protected function checkDuplicates($path, array $vars = array())
protected function checkDuplicates(string $path, array $vars = array()): void
{
$packageType = substr($vars['type'], strlen('bitrix') + 1);
$localDir = explode('/', $vars['bitrix_dir']);
@@ -94,8 +92,7 @@ class BitrixInstaller extends BaseInstaller
return;
}
if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) {
if ($oldPath !== $path && file_exists($oldPath) && $this->io->isInteractive()) {
$this->io->writeError(' <error>Duplication of packages:</error>');
$this->io->writeError(' <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>');

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class BonefishInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'package' => 'Packages/{$vendor}/{$name}/'
);

View File

@@ -0,0 +1,12 @@
<?php
namespace Composer\Installers;
class BotbleInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'platform/plugins/{$name}/',
'theme' => 'platform/themes/{$name}/',
);
}

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
use Composer\DependencyResolver\Pool;
@@ -6,6 +7,7 @@ use Composer\Semver\Constraint\Constraint;
class CakePHPInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'Plugin/{$name}/',
);
@@ -13,7 +15,7 @@ class CakePHPInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($this->matchesCakeVersion('>=', '3.0.0')) {
return $vars;
@@ -21,7 +23,7 @@ class CakePHPInstaller extends BaseInstaller
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}
@@ -33,7 +35,7 @@ class CakePHPInstaller extends BaseInstaller
/**
* Change the default plugin location when cakephp >= 3.0
*/
public function getLocations()
public function getLocations(string $frameworkType): array
{
if ($this->matchesCakeVersion('>=', '3.0.0')) {
$this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
@@ -44,19 +46,18 @@ class CakePHPInstaller extends BaseInstaller
/**
* Check if CakePHP version matches against a version
*
* @param string $matcher
* @param string $version
* @return bool
* @phpstan-param Constraint::STR_OP_* $matcher
* @phpstan-param '='|'=='|'<'|'<='|'>'|'>='|'<>'|'!=' $matcher
*/
protected function matchesCakeVersion($matcher, $version)
protected function matchesCakeVersion(string $matcher, string $version): bool
{
$repositoryManager = $this->composer->getRepositoryManager();
if (! $repositoryManager) {
/** @phpstan-ignore-next-line */
if (!$repositoryManager) {
return false;
}
$repos = $repositoryManager->getLocalRepository();
/** @phpstan-ignore-next-line */
if (!$repos) {
return false;
}

View File

@@ -1,11 +1,12 @@
<?php
namespace Composer\Installers;
class ChefInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'cookbook' => 'Chef/{$vendor}/{$name}/',
'role' => 'Chef/roles/{$name}/',
);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class CiviCrmInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'ext' => 'ext/{$name}/'
);

View File

@@ -1,10 +1,12 @@
<?php
namespace Composer\Installers;
class ClanCatsFrameworkInstaller extends BaseInstaller
{
protected $locations = array(
'ship' => 'CCF/orbit/{$name}/',
'theme' => 'CCF/app/themes/{$name}/',
);
}
/** @var array<string, string> */
protected $locations = array(
'ship' => 'CCF/orbit/{$name}/',
'theme' => 'CCF/app/themes/{$name}/',
);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class CockpitInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'cockpit/modules/addons/{$name}/',
);
@@ -11,10 +13,8 @@ class CockpitInstaller extends BaseInstaller
* Format module name.
*
* Strip `module-` prefix from package name.
*
* {@inheritDoc}
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] == 'cockpit-module') {
return $this->inflectModuleVars($vars);
@@ -23,9 +23,13 @@ class CockpitInstaller extends BaseInstaller
return $vars;
}
public function inflectModuleVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
public function inflectModuleVars(array $vars): array
{
$vars['name'] = ucfirst(preg_replace('/cockpit-/i', '', $vars['name']));
$vars['name'] = ucfirst($this->pregReplace('/cockpit-/i', '', $vars['name']));
return $vars;
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class CodeIgniterInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'library' => 'application/libraries/{$name}/',
'third-party' => 'application/third_party/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class Concrete5Installer extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'core' => 'concrete/',
'block' => 'application/blocks/{$name}/',

View File

@@ -0,0 +1,15 @@
<?php
namespace Composer\Installers;
class ConcreteCMSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'core' => 'concrete/',
'block' => 'application/blocks/{$name}/',
'package' => 'packages/{$name}/',
'theme' => 'application/themes/{$name}/',
'update' => 'updates/{$name}/',
);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class CroogoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'Plugin/{$name}/',
'theme' => 'View/Themed/{$name}/',
@@ -11,7 +13,7 @@ class CroogoInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -1,9 +1,11 @@
<?php
namespace Composer\Installers;
class DecibelInstaller extends BaseInstaller
{
/** @var array */
/** @var array<string, string> */
protected $locations = array(
'app' => 'app/{$name}/',
);

View File

@@ -4,6 +4,7 @@ namespace Composer\Installers;
class DframeInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$vendor}/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class DokuWikiInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'lib/plugins/{$name}/',
'template' => 'lib/tpl/{$name}/',
@@ -11,15 +13,13 @@ class DokuWikiInstaller extends BaseInstaller
/**
* Format package name.
*
* For package type dokuwiki-plugin, cut off a trailing '-plugin',
* For package type dokuwiki-plugin, cut off a trailing '-plugin',
* or leading dokuwiki_ if present.
*
* For package type dokuwiki-template, cut off a trailing '-template' if present.
*
* For package type dokuwiki-template, cut off a trailing '-template' if present.
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'dokuwiki-plugin') {
return $this->inflectPluginVars($vars);
}
@@ -31,20 +31,27 @@ class DokuWikiInstaller extends BaseInstaller
return $vars;
}
protected function inflectPluginVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectPluginVars(array $vars): array
{
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-plugin$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/^dokuwiki_?-?/', '', $vars['name']);
return $vars;
}
protected function inflectTemplateVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectTemplateVars(array $vars): array
{
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-template$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/^dokuwiki_?-?/', '', $vars['name']);
return $vars;
}
}

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -10,6 +11,7 @@ namespace Composer\Installers;
class DolibarrInstaller extends BaseInstaller
{
//TODO: Add support for scripts and themes
/** @var array<string, string> */
protected $locations = array(
'module' => 'htdocs/custom/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class DrupalInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'core' => 'core/',
'module' => 'modules/{$name}/',
@@ -18,5 +20,6 @@ class DrupalInstaller extends BaseInstaller
'console' => 'console/{$name}/',
'console-language' => 'console/language/{$name}/',
'config' => 'config/sync/',
'recipe' => 'recipes/{$name}',
);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ElggInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'mod/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class EliasisInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'component' => 'components/{$name}/',
'module' => 'modules/{$name}/',

View File

@@ -1,29 +1,31 @@
<?php
namespace Composer\Installers;
use Composer\Package\PackageInterface;
class ExpressionEngineInstaller extends BaseInstaller
{
protected $locations = array();
/** @var array<string, string> */
private $ee2Locations = array(
'addon' => 'system/expressionengine/third_party/{$name}/',
'theme' => 'themes/third_party/{$name}/',
);
/** @var array<string, string> */
private $ee3Locations = array(
'addon' => 'system/user/addons/{$name}/',
'theme' => 'themes/user/{$name}/',
);
public function getInstallPath(PackageInterface $package, $frameworkType = '')
public function getLocations(string $frameworkType): array
{
if ($frameworkType === 'ee2') {
$this->locations = $this->ee2Locations;
} else {
$this->locations = $this->ee3Locations;
}
$version = "{$frameworkType}Locations";
$this->locations = $this->$version;
return parent::getInstallPath($package, $frameworkType);
return $this->locations;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class EzPlatformInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'meta-assets' => 'web/assets/ezplatform/',
'assets' => 'web/assets/ezplatform/{$name}/',

View File

@@ -0,0 +1,58 @@
<?php
namespace Composer\Installers;
class ForkCMSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = [
'module' => 'src/Modules/{$name}/',
'theme' => 'src/Themes/{$name}/'
];
/**
* Format package name.
*
* For package type fork-cms-module, cut off a trailing '-plugin' if present.
*
* For package type fork-cms-theme, cut off a trailing '-theme' if present.
*/
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'fork-cms-module') {
return $this->inflectModuleVars($vars);
}
if ($vars['type'] === 'fork-cms-theme') {
return $this->inflectThemeVars($vars);
}
return $vars;
}
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars(array $vars): array
{
$vars['name'] = $this->pregReplace('/^fork-cms-|-module|ForkCMS|ForkCms|Forkcms|forkcms|Module$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); // replace hyphens with spaces
$vars['name'] = str_replace(' ', '', ucwords($vars['name'])); // make module name camelcased
return $vars;
}
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = $this->pregReplace('/^fork-cms-|-theme|ForkCMS|ForkCms|Forkcms|forkcms|Theme$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); // replace hyphens with spaces
$vars['name'] = str_replace(' ', '', ucwords($vars['name'])); // make theme name camelcased
return $vars;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class FuelInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'fuel/app/modules/{$name}/',
'package' => 'fuel/packages/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class FuelphpInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'component' => 'components/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class GravInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'user/plugins/{$name}/',
'theme' => 'user/themes/{$name}/',
@@ -10,17 +12,14 @@ class GravInstaller extends BaseInstaller
/**
* Format package name
*
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$restrictedWords = implode('|', array_keys($this->locations));
$vars['name'] = strtolower($vars['name']);
$vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
$vars['name'] = $this->pregReplace(
'/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
'$1',
$vars['name']
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class HuradInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
'theme' => 'plugins/{$name}/',
@@ -11,11 +13,11 @@ class HuradInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ImageCMSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'template' => 'templates/{$name}/',
'module' => 'application/modules/{$name}/',

View File

@@ -6,6 +6,7 @@ use Composer\Composer;
use Composer\Installer\BinaryInstaller;
use Composer\Installer\LibraryInstaller;
use Composer\IO\IOInterface;
use Composer\Package\Package;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Util\Filesystem;
@@ -13,19 +14,19 @@ use React\Promise\PromiseInterface;
class Installer extends LibraryInstaller
{
/**
* Package types to installer class map
*
* @var array
* @var array<string, string>
*/
private $supportedTypes = array(
'aimeos' => 'AimeosInstaller',
'akaunting' => 'AkauntingInstaller',
'asgard' => 'AsgardInstaller',
'attogram' => 'AttogramInstaller',
'agl' => 'AglInstaller',
'annotatecms' => 'AnnotateCmsInstaller',
'bitrix' => 'BitrixInstaller',
'botble' => 'BotbleInstaller',
'bonefish' => 'BonefishInstaller',
'cakephp' => 'CakePHPInstaller',
'chef' => 'ChefInstaller',
@@ -34,7 +35,7 @@ class Installer extends LibraryInstaller
'cockpit' => 'CockpitInstaller',
'codeigniter' => 'CodeIgniterInstaller',
'concrete5' => 'Concrete5Installer',
'craft' => 'CraftInstaller',
'concretecms' => 'ConcreteCMSInstaller',
'croogo' => 'CroogoInstaller',
'dframe' => 'DframeInstaller',
'dokuwiki' => 'DokuWikiInstaller',
@@ -46,6 +47,7 @@ class Installer extends LibraryInstaller
'ee3' => 'ExpressionEngineInstaller',
'ee2' => 'ExpressionEngineInstaller',
'ezplatform' => 'EzPlatformInstaller',
'fork' => 'ForkCMSInstaller',
'fuel' => 'FuelInstaller',
'fuelphp' => 'FuelphpInstaller',
'grav' => 'GravInstaller',
@@ -53,13 +55,11 @@ class Installer extends LibraryInstaller
'tastyigniter' => 'TastyIgniterInstaller',
'imagecms' => 'ImageCMSInstaller',
'itop' => 'ItopInstaller',
'joomla' => 'JoomlaInstaller',
'kanboard' => 'KanboardInstaller',
'kirby' => 'KirbyInstaller',
'known' => 'KnownInstaller',
'kodicms' => 'KodiCMSInstaller',
'kohana' => 'KohanaInstaller',
'lms' => 'LanManagementSystemInstaller',
'lms' => 'LanManagementSystemInstaller',
'laravel' => 'LaravelInstaller',
'lavalite' => 'LavaLiteInstaller',
'lithium' => 'LithiumInstaller',
@@ -67,6 +67,7 @@ class Installer extends LibraryInstaller
'majima' => 'MajimaInstaller',
'mantisbt' => 'MantisBTInstaller',
'mako' => 'MakoInstaller',
'matomo' => 'MatomoInstaller',
'maya' => 'MayaInstaller',
'mautic' => 'MauticInstaller',
'mediawiki' => 'MediaWikiInstaller',
@@ -82,7 +83,6 @@ class Installer extends LibraryInstaller
'osclass' => 'OsclassInstaller',
'pxcms' => 'PxcmsInstaller',
'phpbb' => 'PhpBBInstaller',
'pimcore' => 'PimcoreInstaller',
'piwik' => 'PiwikInstaller',
'plentymarkets'=> 'PlentymarketsInstaller',
'ppi' => 'PPIInstaller',
@@ -103,12 +103,9 @@ class Installer extends LibraryInstaller
'starbug' => 'StarbugInstaller',
'sydes' => 'SyDESInstaller',
'sylius' => 'SyliusInstaller',
'symfony1' => 'Symfony1Installer',
'tao' => 'TaoInstaller',
'thelia' => 'TheliaInstaller',
'tusk' => 'TuskInstaller',
'typo3-cms' => 'TYPO3CmsInstaller',
'typo3-flow' => 'TYPO3FlowInstaller',
'userfrosting' => 'UserFrostingInstaller',
'vanilla' => 'VanillaInstaller',
'whmcs' => 'WHMCSInstaller',
@@ -122,26 +119,17 @@ class Installer extends LibraryInstaller
);
/**
* Installer constructor.
*
* Disables installers specified in main composer extra installer-disable
* list
*
* @param IOInterface $io
* @param Composer $composer
* @param string $type
* @param Filesystem|null $filesystem
* @param BinaryInstaller|null $binaryInstaller
*/
public function __construct(
IOInterface $io,
Composer $composer,
$type = 'library',
Filesystem $filesystem = null,
BinaryInstaller $binaryInstaller = null
string $type = 'library',
?Filesystem $filesystem = null,
?BinaryInstaller $binaryInstaller = null
) {
parent::__construct($io, $composer, $type, $filesystem,
$binaryInstaller);
parent::__construct($io, $composer, $type, $filesystem, $binaryInstaller);
$this->removeDisabledInstallers();
}
@@ -160,9 +148,17 @@ class Installer extends LibraryInstaller
}
$class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
/**
* @var BaseInstaller
*/
$installer = new $class($package, $this->composer, $this->getIO());
return $installer->getInstallPath($package, $frameworkType);
$path = $installer->getInstallPath($package, $frameworkType);
if (!$this->filesystem->isAbsolutePath($path)) {
$path = getcwd() . '/' . $path;
}
return $path;
}
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
@@ -188,6 +184,8 @@ class Installer extends LibraryInstaller
/**
* {@inheritDoc}
*
* @param string $packageType
*/
public function supports($packageType)
{
@@ -205,10 +203,9 @@ class Installer extends LibraryInstaller
/**
* Finds a supported framework type if it exists and returns it
*
* @param string $type
* @return string|false
*/
protected function findFrameworkType($type)
protected function findFrameworkType(string $type)
{
krsort($this->supportedTypes);
@@ -224,30 +221,24 @@ class Installer extends LibraryInstaller
/**
* Get the second part of the regular expression to check for support of a
* package type
*
* @param string $frameworkType
* @return string
*/
protected function getLocationPattern($frameworkType)
protected function getLocationPattern(string $frameworkType): string
{
$pattern = false;
$pattern = null;
if (!empty($this->supportedTypes[$frameworkType])) {
$frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
/** @var BaseInstaller $framework */
$framework = new $frameworkClass(null, $this->composer, $this->getIO());
$locations = array_keys($framework->getLocations());
$pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
$framework = new $frameworkClass(new Package('dummy/pkg', '1.0.0.0', '1.0.0'), $this->composer, $this->getIO());
$locations = array_keys($framework->getLocations($frameworkType));
if ($locations) {
$pattern = '(' . implode('|', $locations) . ')';
}
}
return $pattern ? : '(\w+)';
return $pattern ?: '(\w+)';
}
/**
* Get I/O object
*
* @return IOInterface
*/
private function getIO()
private function getIO(): IOInterface
{
return $this->io;
}
@@ -260,10 +251,8 @@ class Installer extends LibraryInstaller
* - true, "all", and "*" - disable all installers.
* - false - enable all installers (useful with
* wikimedia/composer-merge-plugin or similar)
*
* @return void
*/
protected function removeDisabledInstallers()
protected function removeDisabledInstallers(): void
{
$extra = $this->composer->getPackage()->getExtra();
@@ -286,12 +275,13 @@ class Installer extends LibraryInstaller
if (!empty($intersect)) {
// Disable all installers
$this->supportedTypes = array();
} else {
// Disable specified installers
foreach ($disable as $key => $installer) {
if (is_string($installer) && key_exists($installer, $this->supportedTypes)) {
unset($this->supportedTypes[$installer]);
}
return;
}
// Disable specified installers
foreach ($disable as $key => $installer) {
if (is_string($installer) && key_exists($installer, $this->supportedTypes)) {
unset($this->supportedTypes[$installer]);
}
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ItopInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'extension' => 'extensions/{$name}/',
);

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -12,6 +13,7 @@ namespace Composer\Installers;
*/
class KanboardInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class KnownInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'IdnoPlugins/{$name}/',
'theme' => 'Themes/{$name}/',

View File

@@ -1,10 +1,12 @@
<?php
namespace Composer\Installers;
class KodiCMSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'cms/plugins/{$name}/',
'media' => 'cms/media/vendor/{$name}/'
);
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class KohanaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);

View File

@@ -5,6 +5,7 @@ namespace Composer\Installers;
class LanManagementSystemInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
'template' => 'templates/{$name}/',
@@ -15,13 +16,12 @@ class LanManagementSystemInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class LaravelInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'library' => 'libraries/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class LavaLiteInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'package' => 'packages/{$vendor}/{$name}/',
'theme' => 'public/themes/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class LithiumInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'library' => 'libraries/{$name}/',
'source' => 'libraries/_source/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MODULEWorkInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -6,6 +7,7 @@ namespace Composer\Installers;
*/
class MODXEvoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'snippet' => 'assets/snippets/{$name}/',
'plugin' => 'assets/plugins/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MagentoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'theme' => 'app/design/frontend/{$name}/',
'skin' => 'skin/frontend/default/{$name}/',

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -7,30 +8,38 @@ namespace Composer\Installers;
*/
class MajimaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Transforms the names
* @param array $vars
* @return array
*
* @param array<string, string> $vars
* @return array<string, string>
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
return $this->correctPluginName($vars);
}
/**
* Change hyphenated names to camelcase
* @param array $vars
* @return array
*
* @param array<string, string> $vars
* @return array<string, string>
*/
private function correctPluginName($vars)
private function correctPluginName(array $vars): array
{
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
return strtoupper($matches[0][1]);
}, $vars['name']);
if (null === $camelCasedName) {
throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
}
$vars['name'] = ucfirst($camelCasedName);
return $vars;
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MakoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'package' => 'app/packages/{$name}/',
);

View File

@@ -1,10 +1,12 @@
<?php
namespace Composer\Installers;
use Composer\DependencyResolver\Pool;
class MantisBTInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
@@ -12,9 +14,9 @@ class MantisBTInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -0,0 +1,28 @@
<?php
namespace Composer\Installers;
/**
* Class MatomoInstaller
*
* @package Composer\Installers
*/
class MatomoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View File

@@ -1,17 +1,19 @@
<?php
namespace Composer\Installers;
use Composer\Package\PackageInterface;
class MauticInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
'theme' => 'themes/{$name}/',
'core' => 'app/',
);
private function getDirectoryName()
private function getDirectoryName(): string
{
$extra = $this->package->getExtra();
if (!empty($extra['install-directory-name'])) {
@@ -21,12 +23,7 @@ class MauticInstaller extends BaseInstaller
return $this->toCamelCase($this->package->getPrettyName());
}
/**
* @param string $packageName
*
* @return string
*/
private function toCamelCase($packageName)
private function toCamelCase(string $packageName): string
{
return str_replace(' ', '', ucwords(str_replace('-', ' ', basename($packageName))));
}
@@ -34,9 +31,8 @@ class MauticInstaller extends BaseInstaller
/**
* Format package name of mautic-plugins to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] == 'mautic-plugin' || $vars['type'] == 'mautic-theme') {
$directoryName = $this->getDirectoryName();
$vars['name'] = $directoryName;
@@ -44,5 +40,4 @@ class MauticInstaller extends BaseInstaller
return $vars;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MayaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);
@@ -11,9 +13,8 @@ class MayaInstaller extends BaseInstaller
* Format package name.
*
* For package type maya-module, cut off a trailing '-module' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'maya-module') {
return $this->inflectModuleVars($vars);
@@ -22,9 +23,13 @@ class MayaInstaller extends BaseInstaller
return $vars;
}
protected function inflectModuleVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars(array $vars): array
{
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MediaWikiInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'core' => 'core/',
'extension' => 'extensions/{$name}/',
@@ -16,11 +18,9 @@ class MediaWikiInstaller extends BaseInstaller
* to CamelCase keeping existing uppercase chars.
*
* For package type mediawiki-skin, cut off a trailing '-skin' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'mediawiki-extension') {
return $this->inflectExtensionVars($vars);
}
@@ -32,20 +32,27 @@ class MediaWikiInstaller extends BaseInstaller
return $vars;
}
protected function inflectExtensionVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectExtensionVars(array $vars): array
{
$vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-extension$/', '', $vars['name']);
$vars['name'] = str_replace('-', ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
protected function inflectSkinVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectSkinVars(array $vars): array
{
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-skin$/', '', $vars['name']);
return $vars;
}
}

View File

@@ -4,6 +4,7 @@ namespace Composer\Installers;
class MiaoxingInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MicroweberInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'userfiles/modules/{$install_item_dir}/',
'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/',
@@ -18,13 +20,10 @@ class MicroweberInstaller extends BaseInstaller
* For package type microweber-module, cut off a trailing '-module' if present
*
* For package type microweber-template, cut off a trailing '-template' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($this->package->getTargetDir()) {
if ($this->package->getTargetDir() !== null && $this->package->getTargetDir() !== '') {
$vars['install_item_dir'] = $this->package->getTargetDir();
} else {
$vars['install_item_dir'] = $vars['name'];
@@ -54,65 +53,92 @@ class MicroweberInstaller extends BaseInstaller
}
}
return $vars;
}
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectTemplateVars(array $vars): array
{
$vars['install_item_dir'] = $this->pregReplace('/-template$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/template-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectTemplateVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectTemplatesVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-template$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/template-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-templates$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/templates-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectTemplatesVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectCoreVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-templates$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/templates-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-providers$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-provider$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-adapter$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectCoreVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-providers$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/-provider$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/-adapter$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-module$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/module-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectModuleVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModulesVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-module$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/module-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-modules$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/modules-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectModulesVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectSkinVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-modules$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/modules-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-skin$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/skin-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectSkinVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectElementVars(array $vars): array
{
$vars['install_item_dir'] = preg_replace('/-skin$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/skin-$/', '', $vars['install_item_dir']);
return $vars;
}
protected function inflectElementVars($vars)
{
$vars['install_item_dir'] = preg_replace('/-elements$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/elements-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/-element$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = preg_replace('/element-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-elements$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/elements-$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/-element$/', '', $vars['install_item_dir']);
$vars['install_item_dir'] = $this->pregReplace('/element-$/', '', $vars['install_item_dir']);
return $vars;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -6,6 +7,7 @@ namespace Composer\Installers;
*/
class ModxInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'extra' => 'core/packages/{$name}/'
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class MoodleInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'mod' => 'mod/{$name}/',
'admin_report' => 'admin/report/{$name}/',
@@ -11,6 +13,7 @@ class MoodleInstaller extends BaseInstaller
'assignment' => 'mod/assignment/type/{$name}/',
'assignsubmission' => 'mod/assign/submission/{$name}/',
'assignfeedback' => 'mod/assign/feedback/{$name}/',
'antivirus' => 'lib/antivirus/{$name}/',
'auth' => 'auth/{$name}/',
'availability' => 'availability/condition/{$name}/',
'block' => 'blocks/{$name}/',
@@ -18,27 +21,37 @@ class MoodleInstaller extends BaseInstaller
'cachestore' => 'cache/stores/{$name}/',
'cachelock' => 'cache/locks/{$name}/',
'calendartype' => 'calendar/type/{$name}/',
'communication' => 'communication/provider/{$name}/',
'customfield' => 'customfield/field/{$name}/',
'fileconverter' => 'files/converter/{$name}/',
'format' => 'course/format/{$name}/',
'coursereport' => 'course/report/{$name}/',
'contenttype' => 'contentbank/contenttype/{$name}/',
'customcertelement' => 'mod/customcert/element/{$name}/',
'datafield' => 'mod/data/field/{$name}/',
'dataformat' => 'dataformat/{$name}/',
'datapreset' => 'mod/data/preset/{$name}/',
'editor' => 'lib/editor/{$name}/',
'enrol' => 'enrol/{$name}/',
'filter' => 'filter/{$name}/',
'forumreport' => 'mod/forum/report/{$name}/',
'gradeexport' => 'grade/export/{$name}/',
'gradeimport' => 'grade/import/{$name}/',
'gradereport' => 'grade/report/{$name}/',
'gradingform' => 'grade/grading/form/{$name}/',
'h5plib' => 'h5p/h5plib/{$name}/',
'local' => 'local/{$name}/',
'logstore' => 'admin/tool/log/store/{$name}/',
'ltisource' => 'mod/lti/source/{$name}/',
'ltiservice' => 'mod/lti/service/{$name}/',
'media' => 'media/player/{$name}/',
'message' => 'message/output/{$name}/',
'mlbackend' => 'lib/mlbackend/{$name}/',
'mnetservice' => 'mnet/service/{$name}/',
'paygw' => 'payment/gateway/{$name}/',
'plagiarism' => 'plagiarism/{$name}/',
'portfolio' => 'portfolio/{$name}/',
'qbank' => 'question/bank/{$name}/',
'qbehaviour' => 'question/behaviour/{$name}/',
'qformat' => 'question/format/{$name}/',
'qtype' => 'question/type/{$name}/',
@@ -49,6 +62,7 @@ class MoodleInstaller extends BaseInstaller
'scormreport' => 'mod/scorm/report/{$name}/',
'search' => 'search/engine/{$name}/',
'theme' => 'theme/{$name}/',
'tiny' => 'lib/editor/tiny/plugins/{$name}/',
'tinymce' => 'lib/editor/tinymce/plugins/{$name}/',
'profilefield' => 'user/profile/field/{$name}/',
'webservice' => 'webservice/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class OctoberInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
'plugin' => 'plugins/{$vendor}/{$name}/',
@@ -15,9 +17,8 @@ class OctoberInstaller extends BaseInstaller
* For package type october-plugin, cut off a trailing '-plugin' if present.
*
* For package type october-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'october-plugin') {
return $this->inflectPluginVars($vars);
@@ -30,18 +31,26 @@ class OctoberInstaller extends BaseInstaller
return $vars;
}
protected function inflectPluginVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectPluginVars(array $vars): array
{
$vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']);
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = $this->pregReplace('/^oc-|-plugin$/', '', $vars['name']);
$vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']);
return $vars;
}
protected function inflectThemeVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = preg_replace('/^oc-|-theme$/', '', $vars['name']);
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = $this->pregReplace('/^oc-|-theme$/', '', $vars['name']);
$vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']);
return $vars;
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class OntoWikiInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'extension' => 'extensions/{$name}/',
'theme' => 'extensions/themes/{$name}/',
@@ -12,12 +14,12 @@ class OntoWikiInstaller extends BaseInstaller
/**
* Format package name to lower case and remove ".ontowiki" suffix
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower($vars['name']);
$vars['name'] = preg_replace('/.ontowiki$/', '', $vars['name']);
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
$vars['name'] = preg_replace('/-translation$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/.ontowiki$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-translation$/', '', $vars['name']);
return $vars;
}

View File

@@ -1,14 +1,14 @@
<?php
namespace Composer\Installers;
class OsclassInstaller extends BaseInstaller
class OsclassInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'oc-content/plugins/{$name}/',
'theme' => 'oc-content/themes/{$name}/',
'language' => 'oc-content/languages/{$name}/',
);
}

View File

@@ -1,59 +1,49 @@
<?php
namespace Composer\Installers;
use Composer\Package\PackageInterface;
class OxidInstaller extends BaseInstaller
{
const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
'theme' => 'application/views/{$name}/',
'out' => 'out/{$name}/',
);
/**
* getInstallPath
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
$installPath = parent::getInstallPath($package, $frameworkType);
$type = $this->package->getType();
if ($type === 'oxid-module') {
$this->prepareVendorDirectory($installPath);
}
return $installPath;
}
public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string
{
$installPath = parent::getInstallPath($package, $frameworkType);
$type = $this->package->getType();
if ($type === 'oxid-module') {
$this->prepareVendorDirectory($installPath);
}
return $installPath;
}
/**
* prepareVendorDirectory
*
* Makes sure there is a vendormetadata.php file inside
* the vendor folder if there is a vendor folder.
*
* @param string $installPath
* @return void
*/
protected function prepareVendorDirectory($installPath)
{
$matches = '';
$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
if (!$hasVendorDirectory) {
return;
}
/**
* Makes sure there is a vendormetadata.php file inside
* the vendor folder if there is a vendor folder.
*/
protected function prepareVendorDirectory(string $installPath): void
{
$matches = '';
$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
if (!$hasVendorDirectory) {
return;
}
$vendorDirectory = $matches['vendor'];
$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
if (!file_exists($vendorPath)) {
mkdir($vendorPath, 0755, true);
}
$vendorDirectory = $matches['vendor'];
$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
if (!file_exists($vendorPath)) {
mkdir($vendorPath, 0755, true);
}
$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
touch($vendorMetaDataPath);
}
$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
touch($vendorMetaDataPath);
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PPIInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PhiftyInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'bundle' => 'bundles/{$name}/',
'library' => 'libraries/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PhpBBInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'extension' => 'ext/{$vendor}/{$name}/',
'language' => 'language/{$name}/',

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -8,22 +9,17 @@ namespace Composer\Installers;
*/
class PiwikInstaller extends BaseInstaller
{
/**
* @var array
*/
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -1,28 +1,27 @@
<?php
namespace Composer\Installers;
class PlentymarketsInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => '{$name}/'
);
/**
* Remove hyphen, "plugin" and format to camelcase
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = explode("-", $vars['name']);
foreach ($vars['name'] as $key => $name) {
$vars['name'][$key] = ucfirst($vars['name'][$key]);
$nameBits = explode("-", $vars['name']);
foreach ($nameBits as $key => $name) {
$nameBits[$key] = ucfirst($name);
if (strcasecmp($name, "Plugin") == 0) {
unset($vars['name'][$key]);
unset($nameBits[$key]);
}
}
$vars['name'] = implode("",$vars['name']);
$vars['name'] = implode('', $nameBits);
return $vars;
}

View File

@@ -8,20 +8,21 @@ use Composer\Plugin\PluginInterface;
class Plugin implements PluginInterface
{
/** @var Installer */
private $installer;
public function activate(Composer $composer, IOInterface $io)
public function activate(Composer $composer, IOInterface $io): void
{
$this->installer = new Installer($io, $composer);
$composer->getInstallationManager()->addInstaller($this->installer);
}
public function deactivate(Composer $composer, IOInterface $io)
public function deactivate(Composer $composer, IOInterface $io): void
{
$composer->getInstallationManager()->removeInstaller($this->installer);
}
public function uninstall(Composer $composer, IOInterface $io)
public function uninstall(Composer $composer, IOInterface $io): void
{
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PortoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'container' => 'app/Containers/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PrestashopInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
'theme' => 'themes/{$name}/',

View File

@@ -4,6 +4,7 @@ namespace Composer\Installers;
class ProcessWireInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'site/modules/{$name}/',
);
@@ -11,9 +12,9 @@ class ProcessWireInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -5,6 +5,7 @@ namespace Composer\Installers;
class PuppetInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class PxcmsInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'app/Modules/{$name}/',
'theme' => 'themes/{$name}/',
@@ -10,12 +12,8 @@ class PxcmsInstaller extends BaseInstaller
/**
* Format package name.
*
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'pxcms-module') {
return $this->inflectModuleVars($vars);
@@ -31,30 +29,31 @@ class PxcmsInstaller extends BaseInstaller
/**
* For package type pxcms-module, cut off a trailing '-plugin' if present.
*
* return string
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars($vars)
protected function inflectModuleVars(array $vars): array
{
$vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
$vars['name'] = str_replace('module-', '', $vars['name']); // strip out module-
$vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module
$vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']); // strip out -module
$vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
$vars['name'] = ucwords($vars['name']); // make module name camelcased
return $vars;
}
/**
* For package type pxcms-module, cut off a trailing '-plugin' if present.
*
* return string
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars($vars)
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
$vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme-
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme
$vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); // strip out -theme
$vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
$vars['name'] = ucwords($vars['name']); // make module name camelcased

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class RadPHPInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'bundle' => 'src/{$name}/'
);
@@ -10,11 +12,11 @@ class RadPHPInstaller extends BaseInstaller
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ReIndexInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'theme' => 'themes/{$name}/',
'plugin' => 'plugins/{$name}/'

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class Redaxo5Installer extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'addon' => 'redaxo/src/addons/{$name}/',
'bestyle-plugin' => 'redaxo/src/addons/be_style/plugins/{$name}/'

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class RedaxoInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'addon' => 'redaxo/include/addons/{$name}/',
'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/'

View File

@@ -1,19 +1,18 @@
<?php
namespace Composer\Installers;
class RoundcubeInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Lowercase name and changes the name to a underscores
*
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(str_replace('-', '_', $vars['name']));

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class SMFInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'Sources/{$name}/',
'theme' => 'Themes/{$name}/',

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -7,6 +8,7 @@ namespace Composer\Installers;
*/
class ShopwareInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/',
@@ -18,29 +20,32 @@ class ShopwareInstaller extends BaseInstaller
/**
* Transforms the names
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'shopware-theme') {
return $this->correctThemeName($vars);
}
return $this->correctPluginName($vars);
return $this->correctPluginName($vars);
}
/**
* Changes the name to a camelcased combination of vendor and name
* @param array $vars
* @return array
*
* @param array<string, string> $vars
* @return array<string, string>
*/
private function correctPluginName($vars)
private function correctPluginName(array $vars): array
{
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
return strtoupper($matches[0][1]);
}, $vars['name']);
if (null === $camelCasedName) {
throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
}
$vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
return $vars;
@@ -48,10 +53,11 @@ class ShopwareInstaller extends BaseInstaller
/**
* Changes the name to a underscore separated name
* @param array $vars
* @return array
*
* @param array<string, string> $vars
* @return array<string, string>
*/
private function correctThemeName($vars)
private function correctThemeName(array $vars): array
{
$vars['name'] = str_replace('-', '_', $vars['name']);

View File

@@ -1,10 +1,12 @@
<?php
namespace Composer\Installers;
use Composer\Package\PackageInterface;
class SilverStripeInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => '{$name}/',
'theme' => 'themes/{$name}/',
@@ -15,12 +17,8 @@ class SilverStripeInstaller extends BaseInstaller
*
* Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
* must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string
{
if (
$package->getName() == 'silverstripe/framework'

View File

@@ -4,17 +4,26 @@ namespace Composer\Installers;
class SiteDirectInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$vendor}/{$name}/',
'plugin' => 'plugins/{$vendor}/{$name}/'
);
public function inflectPackageVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
public function inflectPackageVars(array $vars): array
{
return $this->parseVars($vars);
}
protected function parseVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function parseVars(array $vars): array
{
$vars['vendor'] = strtolower($vars['vendor']) == 'sitedirect' ? 'SiteDirect' : $vars['vendor'];
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class StarbugInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
'theme' => 'themes/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class SyDESInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'app/modules/{$name}/',
'theme' => 'themes/{$name}/',
@@ -12,10 +14,8 @@ class SyDESInstaller extends BaseInstaller
* Format module name.
*
* Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present.
*
* {@inerhitDoc}
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] == 'sydes-module') {
return $this->inflectModuleVars($vars);
@@ -28,18 +28,26 @@ class SyDESInstaller extends BaseInstaller
return $vars;
}
public function inflectModuleVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
public function inflectModuleVars(array $vars): array
{
$vars['name'] = preg_replace('/(^sydes-|-module$)/i', '', $vars['name']);
$vars['name'] = $this->pregReplace('/(^sydes-|-module$)/i', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
protected function inflectThemeVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = preg_replace('/(^sydes-|-theme$)/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/(^sydes-|-theme$)/', '', $vars['name']);
$vars['name'] = strtolower($vars['name']);
return $vars;

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class SyliusInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'theme' => 'themes/{$name}/',
);

View File

@@ -1,4 +1,5 @@
<?php
namespace Composer\Installers;
/**
@@ -8,11 +9,12 @@ class TaoInstaller extends BaseInstaller
{
const EXTRA_TAO_EXTENSION_NAME = 'tao-extension-name';
/** @var array<string, string> */
protected $locations = array(
'extension' => '{$name}'
);
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$extra = $this->package->getExtra();

View File

@@ -4,10 +4,12 @@ namespace Composer\Installers;
class TastyIgniterInstaller extends BaseInstaller
{
protected $locations = array(
/** @var array<string, string> */
protected $locations = [
'module' => 'app/{$name}/',
'extension' => 'extensions/{$vendor}/{$name}/',
'theme' => 'themes/{$name}/',
);
];
/**
* Format package name.
@@ -16,17 +18,68 @@ class TastyIgniterInstaller extends BaseInstaller
* Strip vendor name of characters that is not alphanumeric or an underscore
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$extra = $this->package->getExtra();
if ($vars['type'] === 'tastyigniter-module') {
return $this->inflectModuleVars($vars);
}
if ($vars['type'] === 'tastyigniter-extension') {
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = preg_replace('/^ti-ext-/', '', $vars['name']);
return $this->inflectExtensionVars($vars, $extra);
}
if ($vars['type'] === 'tastyigniter-theme') {
$vars['name'] = preg_replace('/^ti-theme-/', '', $vars['name']);
return $this->inflectThemeVars($vars, $extra);
}
return $vars;
}
}
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars(array $vars): array
{
$vars['name'] = $this->pregReplace('/^ti-module-/', '', $vars['name']);
return $vars;
}
/**
* @param array<string, string> $vars
* @param array<string, mixed> $extra
* @return array<string, string>
*/
protected function inflectExtensionVars(array $vars, array $extra): array
{
if (!empty($extra['tastyigniter-extension']['code'])) {
$parts = explode('.', $extra['tastyigniter-extension']['code']);
$vars['vendor'] = (string)$parts[0];
$vars['name'] = (string)($parts[1] ?? '');
}
$vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = $this->pregReplace('/^ti-ext-/', '', $vars['name']);
return $vars;
}
/**
* @param array<string, string> $vars
* @param array<string, mixed> $extra
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars, array $extra): array
{
if (!empty($extra['tastyigniter-theme']['code'])) {
$vars['name'] = $extra['tastyigniter-theme']['code'];
}
$vars['name'] = $this->pregReplace('/^ti-theme-/', '', $vars['name']);
return $vars;
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class TheliaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'local/modules/{$name}/',
'frontoffice-template' => 'templates/frontOffice/{$name}/',

View File

@@ -1,14 +1,17 @@
<?php
namespace Composer\Installers;
/**
* Composer installer for 3rd party Tusk utilities
* @author Drew Ewing <drew@phenocode.com>
*/
class TuskInstaller extends BaseInstaller
{
protected $locations = array(
'task' => '.tusk/tasks/{$name}/',
'command' => '.tusk/commands/{$name}/',
'asset' => 'assets/tusk/{$name}/',
);
}
namespace Composer\Installers;
/**
* Composer installer for 3rd party Tusk utilities
* @author Drew Ewing <drew@phenocode.com>
*/
class TuskInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'task' => '.tusk/tasks/{$name}/',
'command' => '.tusk/commands/{$name}/',
'asset' => 'assets/tusk/{$name}/',
);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class UserFrostingInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'sprinkle' => 'app/sprinkles/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class VanillaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'plugins/{$name}/',
'theme' => 'themes/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class VgmcpInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'bundle' => 'src/{$vendor}/{$name}/',
'theme' => 'themes/{$name}/'
@@ -16,7 +18,7 @@ class VgmcpInstaller extends BaseInstaller
* For package type vgmcp-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'vgmcp-bundle') {
return $this->inflectPluginVars($vars);
@@ -29,18 +31,26 @@ class VgmcpInstaller extends BaseInstaller
return $vars;
}
protected function inflectPluginVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectPluginVars(array $vars): array
{
$vars['name'] = preg_replace('/-bundle$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-bundle$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
protected function inflectThemeVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']);
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

View File

@@ -4,6 +4,7 @@ namespace Composer\Installers;
class WHMCSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'addons' => 'modules/addons/{$vendor}_{$name}/',
'fraud' => 'modules/fraud/{$vendor}_{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class WinterInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$name}/',
'plugin' => 'plugins/{$vendor}/{$name}/',
@@ -15,9 +17,8 @@ class WinterInstaller extends BaseInstaller
* For package type winter-plugin, cut off a trailing '-plugin' if present.
*
* For package type winter-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
if ($vars['type'] === 'winter-module') {
return $this->inflectModuleVars($vars);
@@ -34,24 +35,36 @@ class WinterInstaller extends BaseInstaller
return $vars;
}
protected function inflectModuleVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectModuleVars(array $vars): array
{
$vars['name'] = preg_replace('/^wn-|-module$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/^wn-|-module$/', '', $vars['name']);
return $vars;
}
protected function inflectPluginVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectPluginVars(array $vars): array
{
$vars['name'] = preg_replace('/^wn-|-plugin$/', '', $vars['name']);
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
$vars['name'] = $this->pregReplace('/^wn-|-plugin$/', '', $vars['name']);
$vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']);
return $vars;
}
protected function inflectThemeVars($vars)
/**
* @param array<string, string> $vars
* @return array<string, string>
*/
protected function inflectThemeVars(array $vars): array
{
$vars['name'] = preg_replace('/^wn-|-theme$/', '', $vars['name']);
$vars['name'] = $this->pregReplace('/^wn-|-theme$/', '', $vars['name']);
return $vars;
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class WolfCMSInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'wolf/plugins/{$name}/',
);

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class WordPressInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'wp-content/plugins/{$name}/',
'theme' => 'wp-content/themes/{$name}/',

View File

@@ -1,32 +1,23 @@
<?php
/**
* Created by PhpStorm.
* User: cbleek
* Date: 25.03.16
* Time: 20:55
*/
namespace Composer\Installers;
class YawikInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'module/{$name}/',
);
/**
* Format package name to CamelCase
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
public function inflectPackageVars(array $vars): array
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}
}

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ZendInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'library' => 'library/{$name}/',
'extra' => 'extras/library/{$name}/',

View File

@@ -1,8 +1,10 @@
<?php
namespace Composer\Installers;
class ZikulaInstaller extends BaseInstaller
{
/** @var array<string, string> */
protected $locations = array(
'module' => 'modules/{$vendor}-{$name}/',
'theme' => 'themes/{$vendor}-{$name}/'

View File

@@ -1,9 +1,14 @@
<?php
function includeIfExists($file)
use Composer\Autoload\ClassLoader;
function includeIfExists(string $file): ?ClassLoader
{
if (file_exists($file)) {
return include $file;
}
return null;
}
if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.