1
0
Fork 0

Add type info to many properties/methods

pull/10086/head
Jordi Boggiano 2021-08-30 14:14:19 +02:00
parent fc04c86f82
commit 0761474599
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
26 changed files with 77 additions and 26 deletions

View File

@ -36,8 +36,11 @@ parameters:
- '~^Call to an undefined method (PHPUnit\\Framework\\MockObject\\MockObject|Prophecy\\Prophecy\\ObjectProphecy)::.*$~' - '~^Call to an undefined method (PHPUnit\\Framework\\MockObject\\MockObject|Prophecy\\Prophecy\\ObjectProphecy)::.*$~'
# Level 6 TODO # Level 6 TODO
#- '~parameter .*? with no return typehint specified.$~' #- '~parameter .*? with no typehint specified.$~'
#- '~parameter .*? with no value type specified in iterable type array.$~'
#- '~has no return typehint specified.$~' #- '~has no return typehint specified.$~'
#- '~return type has no value type specified in iterable type array.$~'
#- '~ignorePlatformReqs~'
bootstrapFiles: bootstrapFiles:
- ../tests/bootstrap.php - ../tests/bootstrap.php

View File

@ -33,7 +33,7 @@ class ClassMapGenerator
/** /**
* Generate a class map file * Generate a class map file
* *
* @param \Traversable|string[] $dirs Directories or a single path to search in * @param \Traversable|array<string> $dirs Directories or a single path to search in
* @param string $file The name of the class map file * @param string $file The name of the class map file
*/ */
public static function dump($dirs, $file) public static function dump($dirs, $file)
@ -50,7 +50,7 @@ class ClassMapGenerator
/** /**
* Iterate over all files in the given directory searching for classes * Iterate over all files in the given directory searching for classes
* *
* @param \Traversable|string|string[] $path The path to search in or an iterator * @param \Traversable|string|array<string> $path The path to search in or an iterator
* @param string $excluded Regex that matches file paths to be excluded from the classmap * @param string $excluded Regex that matches file paths to be excluded from the classmap
* @param ?IOInterface $io IO object * @param ?IOInterface $io IO object
* @param ?string $namespace Optional namespace prefix to filter by * @param ?string $namespace Optional namespace prefix to filter by

View File

@ -40,6 +40,7 @@ class BaseDependencyCommand extends BaseCommand
const OPTION_RECURSIVE = 'recursive'; const OPTION_RECURSIVE = 'recursive';
const OPTION_TREE = 'tree'; const OPTION_TREE = 'tree';
/** @var ?string[] */
protected $colors; protected $colors;
/** /**

View File

@ -46,7 +46,7 @@ class InitCommand extends BaseCommand
/** @var ?CompositeRepository */ /** @var ?CompositeRepository */
protected $repos; protected $repos;
/** @var array */ /** @var array<string, string> */
private $gitConfig; private $gitConfig;
/** @var RepositorySet[] */ /** @var RepositorySet[] */

View File

@ -38,10 +38,15 @@ use Composer\Util\Silencer;
*/ */
class RequireCommand extends InitCommand class RequireCommand extends InitCommand
{ {
/** @var bool */
private $newlyCreated; private $newlyCreated;
/** @var bool */
private $firstRequire; private $firstRequire;
/** @var JsonFile */
private $json; private $json;
/** @var string */
private $file; private $file;
/** @var string */
private $composerBackup; private $composerBackup;
/** @var string file name */ /** @var string file name */
private $lock; private $lock;

View File

@ -27,7 +27,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class RunScriptCommand extends BaseCommand class RunScriptCommand extends BaseCommand
{ {
/** /**
* @var array Array with command events * @var string[] Array with command events
*/ */
protected $scriptEvents = array( protected $scriptEvents = array(
ScriptEvents::PRE_INSTALL_CMD, ScriptEvents::PRE_INSTALL_CMD,

View File

@ -22,7 +22,9 @@ use Symfony\Component\Console\Output\OutputInterface;
*/ */
class ScriptAliasCommand extends BaseCommand class ScriptAliasCommand extends BaseCommand
{ {
/** @var string */
private $script; private $script;
/** @var string */
private $description; private $description;
public function __construct($script, $description) public function __construct($script, $description)

View File

@ -29,12 +29,6 @@ use Composer\Plugin\PluginEvents;
*/ */
class SearchCommand extends BaseCommand class SearchCommand extends BaseCommand
{ {
protected $matches;
protected $lowMatches = array();
protected $tokens;
protected $output;
protected $onlyName;
protected function configure() protected function configure()
{ {
$this $this

View File

@ -52,6 +52,7 @@ class ShowCommand extends BaseCommand
{ {
/** @var VersionParser */ /** @var VersionParser */
protected $versionParser; protected $versionParser;
/** @var string[] */
protected $colors; protected $colors;
/** @var ?RepositorySet */ /** @var ?RepositorySet */

View File

@ -56,6 +56,7 @@ class Application extends BaseApplication
*/ */
protected $io; protected $io;
/** @var string */
private static $logo = ' ______ private static $logo = ' ______
/ ____/___ ____ ___ ____ ____ ________ _____ / ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
@ -64,7 +65,9 @@ class Application extends BaseApplication
/_/ /_/
'; ';
/** @var bool */
private $hasPluginCommands = false; private $hasPluginCommands = false;
/** @var bool */
private $disablePluginsByDefault = false; private $disablePluginsByDefault = false;
/** /**

View File

@ -19,6 +19,7 @@ use Symfony\Component\Console\Formatter\OutputFormatter;
*/ */
class HtmlOutputFormatter extends OutputFormatter class HtmlOutputFormatter extends OutputFormatter
{ {
/** @var array<int, string> */
private static $availableForegroundColors = array( private static $availableForegroundColors = array(
30 => 'black', 30 => 'black',
31 => 'red', 31 => 'red',
@ -29,6 +30,7 @@ class HtmlOutputFormatter extends OutputFormatter
36 => 'cyan', 36 => 'cyan',
37 => 'white', 37 => 'white',
); );
/** @var array<int, string> */
private static $availableBackgroundColors = array( private static $availableBackgroundColors = array(
40 => 'black', 40 => 'black',
41 => 'red', 41 => 'red',
@ -39,6 +41,7 @@ class HtmlOutputFormatter extends OutputFormatter
46 => 'cyan', 46 => 'cyan',
47 => 'white', 47 => 'white',
); );
/** @var array<int, string> */
private static $availableOptions = array( private static $availableOptions = array(
1 => 'bold', 1 => 'bold',
4 => 'underscore', 4 => 'underscore',

View File

@ -59,8 +59,11 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
protected $process; protected $process;
/** /**
* @private this is only public for php 5.3 support in closures * @private this is only public for php 5.3 support in closures
*
* @var array<string, string> Map of package name to cache key
*/ */
public $lastCacheWrites = array(); public $lastCacheWrites = array();
/** @var array<string, string[]> Map of package name to list of paths */
private $additionalCleanupPaths = array(); private $additionalCleanupPaths = array();
/** /**

View File

@ -23,6 +23,7 @@ use Composer\Util\ProcessExecutor;
*/ */
class SvnDownloader extends VcsDownloader class SvnDownloader extends VcsDownloader
{ {
/** @var bool */
protected $cacheCredentials = true; protected $cacheCredentials = true;
/** /**

View File

@ -25,12 +25,12 @@ class Event
protected $name; protected $name;
/** /**
* @var array Arguments passed by the user, these will be forwarded to CLI script handlers * @var string[] Arguments passed by the user, these will be forwarded to CLI script handlers
*/ */
protected $args; protected $args;
/** /**
* @var array Flags usable in PHP script handlers * @var mixed[] Flags usable in PHP script handlers
*/ */
protected $flags; protected $flags;
@ -43,8 +43,8 @@ class Event
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
* @param array $args Arguments passed by the user * @param string[] $args Arguments passed by the user
* @param array $flags Optional flags to pass data not as argument * @param mixed[] $flags Optional flags to pass data not as argument
*/ */
public function __construct($name, array $args = array(), array $flags = array()) public function __construct($name, array $args = array(), array $flags = array())
{ {
@ -66,7 +66,7 @@ class Event
/** /**
* Returns the event's arguments. * Returns the event's arguments.
* *
* @return array The event arguments * @return string[] The event arguments
*/ */
public function getArguments() public function getArguments()
{ {
@ -76,7 +76,7 @@ class Event
/** /**
* Returns the event's flags. * Returns the event's flags.
* *
* @return array The event flags * @return mixed[] The event flags
*/ */
public function getFlags() public function getFlags()
{ {

View File

@ -18,6 +18,7 @@ use Psr\Log\LogLevel;
abstract class BaseIO implements IOInterface abstract class BaseIO implements IOInterface
{ {
/** @var array<string, array{username: string, password: string}> */
protected $authentications = array(); protected $authentications = array();
/** /**

View File

@ -36,16 +36,19 @@ class JsonFile
const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json'; const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
/** @var string */
private $path; private $path;
/** @var ?HttpDownloader */
private $httpDownloader; private $httpDownloader;
/** @var ?IOInterface */
private $io; private $io;
/** /**
* Initializes json file reader/parser. * Initializes json file reader/parser.
* *
* @param string $path path to a lockfile * @param string $path path to a lockfile
* @param HttpDownloader $httpDownloader required for loading http/https json files * @param ?HttpDownloader $httpDownloader required for loading http/https json files
* @param IOInterface $io * @param ?IOInterface $io
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null) public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)

View File

@ -19,6 +19,7 @@ use Composer\Repository\PlatformRepository;
*/ */
class JsonManipulator class JsonManipulator
{ {
/** @var string */
private static $DEFINES = '(?(DEFINE) private static $DEFINES = '(?(DEFINE)
(?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? ) (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
(?<boolean> true | false | null ) (?<boolean> true | false | null )
@ -29,8 +30,11 @@ class JsonManipulator
(?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) ) (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
)'; )';
/** @var string */
private $contents; private $contents;
/** @var string */
private $newline; private $newline;
/** @var string */
private $indent; private $indent;
public function __construct($contents) public function __construct($contents)

View File

@ -19,14 +19,24 @@ use Exception;
*/ */
class JsonValidationException extends Exception class JsonValidationException extends Exception
{ {
/**
* @var string[]
*/
protected $errors; protected $errors;
/**
* @param string $message
* @param string[] $errors
*/
public function __construct($message, $errors = array(), Exception $previous = null) public function __construct($message, $errors = array(), Exception $previous = null)
{ {
$this->errors = $errors; $this->errors = $errors;
parent::__construct((string) $message, 0, $previous); parent::__construct((string) $message, 0, $previous);
} }
/**
* @return string[]
*/
public function getErrors() public function getErrors()
{ {
return $this->errors; return $this->errors;

View File

@ -24,7 +24,9 @@ use Symfony\Component\Console\Question\Question;
*/ */
class StrictConfirmationQuestion extends Question class StrictConfirmationQuestion extends Question
{ {
/** @var string */
private $trueAnswerRegex; private $trueAnswerRegex;
/** @var string */
private $falseAnswerRegex; private $falseAnswerRegex;
/** /**

View File

@ -20,11 +20,16 @@ use Composer\Config;
*/ */
class Versions class Versions
{ {
/** @var string[] */
public static $channels = array('stable', 'preview', 'snapshot', '1', '2'); public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
/** @var HttpDownloader */
private $httpDownloader; private $httpDownloader;
/** @var Config */
private $config; private $config;
/** @var string */
private $channel; private $channel;
/** @var array<string, array<int, array{path: string, version: string, min-php: int}>> */
private $versionsData; private $versionsData;
public function __construct(Config $config, HttpDownloader $httpDownloader) public function __construct(Config $config, HttpDownloader $httpDownloader)

View File

@ -21,8 +21,11 @@ use Composer\Downloader\TransportException;
*/ */
class AuthHelper class AuthHelper
{ {
/** @var IOInterface */
protected $io; protected $io;
/** @var Config */
protected $config; protected $config;
/** @var array<string, string> Map of origins to message displayed */
private $displayedOriginAuthentications = array(); private $displayedOriginAuthentications = array();
public function __construct(IOInterface $io, Config $config) public function __construct(IOInterface $io, Config $config)

View File

@ -30,6 +30,7 @@ class ConfigValidator
{ {
const CHECK_VERSION = 1; const CHECK_VERSION = 1;
/** @var IOInterface */
private $io; private $io;
public function __construct(IOInterface $io) public function __construct(IOInterface $io)

View File

@ -21,6 +21,7 @@ use Composer\IO\IOInterface;
*/ */
class ErrorHandler class ErrorHandler
{ {
/** @var ?IOInterface */
private static $io; private static $io;
/** /**

View File

@ -20,6 +20,7 @@ use Composer\IO\IOInterface;
*/ */
class Git class Git
{ {
/** @var string|false|null */
private static $version = false; private static $version = false;
/** @var IOInterface */ /** @var IOInterface */

View File

@ -20,6 +20,7 @@ use Composer\IO\IOInterface;
*/ */
class Hg class Hg
{ {
/** @var string|false|null */
private static $version = false; private static $version = false;
/** /**

View File

@ -27,6 +27,9 @@ abstract class TestCase extends PolyfillTestCase
private static $parser; private static $parser;
private static $executableCache = array(); private static $executableCache = array();
/**
* @return string
*/
public static function getUniqueTmpDirectory() public static function getUniqueTmpDirectory()
{ {
$attempts = 5; $attempts = 5;