1
0
Fork 0

Introduce phpstan-type about autoload array type to be DRY (#10516)

pull/10541/head
sasezaki 2022-02-16 22:34:10 +09:00 committed by GitHub
parent 53810b0cfb
commit 0c4cefaaa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View File

@ -20,6 +20,9 @@ use Composer\Util\ComposerMirror;
* Core package definitions that are needed to resolve dependencies and install packages
*
* @author Nils Adermann <naderman@naderman.de>
*
* @phpstan-import-type AutoloadRules from PackageInterface
* @phpstan-import-type DevAutoloadRules from PackageInterface
*/
class Package extends BasePackage
{
@ -79,9 +82,15 @@ class Package extends BasePackage
protected $devRequires = array();
/** @var array<string, string> */
protected $suggests = array();
/** @var array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} */
/**
* @var array
* @phpstan-var AutoloadRules
*/
protected $autoload = array();
/** @var array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} */
/**
* @var array
* @phpstan-var DevAutoloadRules
*/
protected $devAutoload = array();
/** @var string[] */
protected $includePaths = array();
@ -598,7 +607,7 @@ class Package extends BasePackage
*
* @return void
*
* @phpstan-param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $autoload
* @phpstan-param AutoloadRules $autoload
*/
public function setAutoload(array $autoload)
{
@ -620,7 +629,7 @@ class Package extends BasePackage
*
* @return void
*
* @phpstan-param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $devAutoload
* @phpstan-param DevAutoloadRules $devAutoload
*/
public function setDevAutoload(array $devAutoload)
{

View File

@ -18,6 +18,9 @@ use Composer\Repository\RepositoryInterface;
* Defines the essential information a package has that is used during solving/installation
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @phpstan-type AutoloadRules array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>, exclude-from-classmap?: list<string>}
* @phpstan-type DevAutoloadRules array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>}
*/
interface PackageInterface
{
@ -303,7 +306,7 @@ interface PackageInterface
* directories for autoloading using the type specified.
*
* @return array Mapping of autoloading rules
* @phpstan-return array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>}
* @phpstan-return AutoloadRules
*/
public function getAutoload();
@ -316,7 +319,7 @@ interface PackageInterface
* directories for autoloading using the type specified.
*
* @return array Mapping of dev autoloading rules
* @phpstan-return array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>}
* @phpstan-return DevAutoloadRules
*/
public function getDevAutoload();

View File

@ -16,6 +16,9 @@ namespace Composer\Package;
* Defines additional fields that are only needed for the root package
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @phpstan-import-type AutoloadRules from PackageInterface
* @phpstan-import-type DevAutoloadRules from PackageInterface
*/
interface RootPackageInterface extends CompletePackageInterface
{
@ -122,7 +125,8 @@ interface RootPackageInterface extends CompletePackageInterface
/**
* Set the autoload mapping
*
* @param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $autoload Mapping of autoloading rules
* @param array $autoload Mapping of autoloading rules
* @phpstan-param AutoloadRules $autoload
*
* @return void
*/
@ -131,7 +135,8 @@ interface RootPackageInterface extends CompletePackageInterface
/**
* Set the dev autoload mapping
*
* @param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $devAutoload Mapping of dev autoloading rules
* @param array $devAutoload Mapping of dev autoloading rules
* @phpstan-param DevAutoloadRules $devAutoload
*
* @return void
*/