Add types to `Plugin` (#10194)
parent
a921d9b233
commit
aa4c2ab63c
|
@ -45,8 +45,8 @@ class CommandEvent extends Event
|
|||
* @param string $commandName The command name
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @param array $args Arguments passed by the user
|
||||
* @param array $flags Optional flags to pass data not as argument
|
||||
* @param mixed[] $args Arguments passed by the user
|
||||
* @param mixed[] $flags Optional flags to pass data not as argument
|
||||
*/
|
||||
public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
|
||||
{
|
||||
|
|
|
@ -73,6 +73,8 @@ class PluginManager
|
|||
|
||||
/**
|
||||
* Loads all plugins from currently installed plugin packages
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadInstalledPlugins()
|
||||
{
|
||||
|
@ -91,7 +93,7 @@ class PluginManager
|
|||
/**
|
||||
* Gets all currently active plugin instances
|
||||
*
|
||||
* @return array plugins
|
||||
* @return array<PluginInterface> plugins
|
||||
*/
|
||||
public function getPlugins()
|
||||
{
|
||||
|
@ -118,6 +120,8 @@ class PluginManager
|
|||
* @param bool $failOnMissingClasses By default this silently skips plugins that can not be found, but if set to true it fails with an exception
|
||||
* @param bool $isGlobalPlugin Set to true to denote plugins which are installed in the global Composer directory
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
|
||||
|
@ -242,6 +246,8 @@ class PluginManager
|
|||
*
|
||||
* @param PackageInterface $package
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function deactivatePackage(PackageInterface $package)
|
||||
|
@ -276,6 +282,8 @@ class PluginManager
|
|||
*
|
||||
* @param PackageInterface $package
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function uninstallPackage(PackageInterface $package)
|
||||
|
@ -318,7 +326,10 @@ class PluginManager
|
|||
* to do it.
|
||||
*
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
* @param bool $isGlobalPlugin
|
||||
* @param ?PackageInterface $sourcePackage Package from which the plugin comes from
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
|
||||
{
|
||||
|
@ -346,6 +357,8 @@ class PluginManager
|
|||
* to do it.
|
||||
*
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removePlugin(PluginInterface $plugin)
|
||||
{
|
||||
|
@ -369,6 +382,8 @@ class PluginManager
|
|||
* to do it.
|
||||
*
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function uninstallPlugin(PluginInterface $plugin)
|
||||
{
|
||||
|
@ -386,6 +401,9 @@ class PluginManager
|
|||
* call this method as early as possible.
|
||||
*
|
||||
* @param RepositoryInterface $repo Repository to scan for plugins to install
|
||||
* @param bool $isGlobalRepo
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
|
@ -409,11 +427,11 @@ class PluginManager
|
|||
/**
|
||||
* Recursively generates a map of package names to packages for all deps
|
||||
*
|
||||
* @param InstalledRepository $installedRepo Set of local repos
|
||||
* @param array $collected Current state of the map for recursion
|
||||
* @param PackageInterface $package The package to analyze
|
||||
* @param InstalledRepository $installedRepo Set of local repos
|
||||
* @param array<string, PackageInterface> $collected Current state of the map for recursion
|
||||
* @param PackageInterface $package The package to analyze
|
||||
*
|
||||
* @return array Map of package names to packages
|
||||
* @return array<string, PackageInterface> Map of package names to packages
|
||||
*/
|
||||
private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
|
||||
{
|
||||
|
@ -479,7 +497,7 @@ class PluginManager
|
|||
* @param PluginInterface $plugin
|
||||
* @param class-string<CapabilityClass> $capabilityClassName The fully qualified name of the API interface which the plugin may provide
|
||||
* an implementation of.
|
||||
* @param array $ctorArgs Arguments passed to Capability's constructor.
|
||||
* @param array<mixed> $ctorArgs Arguments passed to Capability's constructor.
|
||||
* Keeping it an array will allow future values to be passed w\o changing the signature.
|
||||
* @return null|Capability
|
||||
* @phpstan-param class-string<CapabilityClass> $capabilityClassName
|
||||
|
@ -512,7 +530,7 @@ class PluginManager
|
|||
* @template CapabilityClass of Capability
|
||||
* @param class-string<CapabilityClass> $capabilityClassName The fully qualified name of the API interface which the plugin may provide
|
||||
* an implementation of.
|
||||
* @param array $ctorArgs Arguments passed to Capability's constructor.
|
||||
* @param array<mixed> $ctorArgs Arguments passed to Capability's constructor.
|
||||
* Keeping it an array will allow future values to be passed w\o changing the signature.
|
||||
* @return CapabilityClass[]
|
||||
*/
|
||||
|
|
|
@ -92,6 +92,8 @@ class PreFileDownloadEvent extends Event
|
|||
* Sets the processed URL that will be downloaded.
|
||||
*
|
||||
* @param string $processedUrl New processed URL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setProcessedUrl($processedUrl)
|
||||
{
|
||||
|
@ -112,6 +114,8 @@ class PreFileDownloadEvent extends Event
|
|||
* Sets a custom package cache key for this download.
|
||||
*
|
||||
* @param string|null $customCacheKey New cache key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomCacheKey($customCacheKey)
|
||||
{
|
||||
|
@ -146,7 +150,7 @@ class PreFileDownloadEvent extends Event
|
|||
*
|
||||
* Only available for events with type metadata, for packages set the transport options on the package itself.
|
||||
*
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTransportOptions()
|
||||
{
|
||||
|
@ -158,7 +162,9 @@ class PreFileDownloadEvent extends Event
|
|||
*
|
||||
* Only available for events with type metadata, for packages set the transport options on the package itself.
|
||||
*
|
||||
* @param array $options
|
||||
* @param mixed[] $options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTransportOptions(array $options)
|
||||
{
|
||||
|
|
|
@ -160,6 +160,8 @@ class PrePoolCreateEvent extends Event
|
|||
|
||||
/**
|
||||
* @param BasePackage[] $packages
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPackages(array $packages)
|
||||
{
|
||||
|
@ -168,6 +170,8 @@ class PrePoolCreateEvent extends Event
|
|||
|
||||
/**
|
||||
* @param BasePackage[] $packages
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUnacceptableFixedPackages(array $packages)
|
||||
{
|
||||
|
|
|
@ -144,7 +144,7 @@ class PluginInstallerTest extends TestCase
|
|||
$installer->install($this->repository, $this->packages[0]);
|
||||
|
||||
$plugins = $this->pm->getPlugins();
|
||||
$this->assertEquals('installer-v1', $plugins[0]->version);
|
||||
$this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('activate v1'.PHP_EOL, $this->io->getOutput());
|
||||
}
|
||||
|
||||
|
@ -160,10 +160,10 @@ class PluginInstallerTest extends TestCase
|
|||
$installer->install($this->repository, $this->packages[3]);
|
||||
|
||||
$plugins = $this->pm->getPlugins();
|
||||
$this->assertEquals('plugin1', $plugins[0]->name);
|
||||
$this->assertEquals('installer-v4', $plugins[0]->version);
|
||||
$this->assertEquals('plugin2', $plugins[1]->name);
|
||||
$this->assertEquals('installer-v4', $plugins[1]->version);
|
||||
$this->assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore-line
|
||||
$this->assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore-line
|
||||
$this->assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput());
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ class PluginInstallerTest extends TestCase
|
|||
|
||||
$plugins = $this->pm->getPlugins();
|
||||
$this->assertCount(1, $plugins);
|
||||
$this->assertEquals('installer-v2', $plugins[1]->version);
|
||||
$this->assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput());
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class PluginInstallerTest extends TestCase
|
|||
$installer->update($this->repository, $this->packages[1], $this->packages[2]);
|
||||
|
||||
$plugins = $this->pm->getPlugins();
|
||||
$this->assertEquals('installer-v3', $plugins[1]->version);
|
||||
$this->assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput());
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ class PluginInstallerTest extends TestCase
|
|||
|
||||
$plugins = $this->pm->getPlugins();
|
||||
$this->assertCount(1, $plugins);
|
||||
$this->assertEquals('installer-v1', $plugins[0]->version);
|
||||
$this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line
|
||||
$this->assertEquals('activate v1'.PHP_EOL, $this->io->getOutput());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue