1
0
Fork 0

Merge pull request #10565 from Seldaek/add_const_visibility

Add visibility to all consts, fixes #10550
pull/10571/head
Jordi Boggiano 2022-02-23 14:43:28 +01:00 committed by GitHub
commit 1e914f8afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 163 additions and 147 deletions

View File

@ -65,7 +65,7 @@ return $config->setRules([
// TODO later once 2.2 is more stable // TODO later once 2.2 is more stable
// 'array_syntax' => true, // 'array_syntax' => true,
// 'list_syntax' => true, // 'list_syntax' => true,
'visibility_required' => ['elements' => ['property', 'method', /* TODO 'const' but need to review them all */]], 'visibility_required' => ['elements' => ['property', 'method', 'const']],
'non_printable_character' => true, 'non_printable_character' => true,
'combine_nested_dirname' => true, 'combine_nested_dirname' => true,
'random_api_migration' => true, 'random_api_migration' => true,

View File

@ -4415,6 +4415,14 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Repository/PlatformRepository.php path: ../src/Composer/Repository/PlatformRepository.php
-
message: """
#^Fetching deprecated class constant PLATFORM_PACKAGE_REGEX of class Composer\\\\Repository\\\\PlatformRepository\\:
use PlatformRepository\\:\\:isPlatformPackage\\(string \\$name\\) instead$#
"""
count: 1
path: ../src/Composer/Repository/PlatformRepository.php
- -
message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#" message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
count: 1 count: 1

View File

@ -36,10 +36,10 @@ use Symfony\Component\Console\Output\OutputInterface;
*/ */
class BaseDependencyCommand extends BaseCommand class BaseDependencyCommand extends BaseCommand
{ {
const ARGUMENT_PACKAGE = 'package'; protected const ARGUMENT_PACKAGE = 'package';
const ARGUMENT_CONSTRAINT = 'version'; protected const ARGUMENT_CONSTRAINT = 'version';
const OPTION_RECURSIVE = 'recursive'; protected const OPTION_RECURSIVE = 'recursive';
const OPTION_TREE = 'tree'; protected const OPTION_TREE = 'tree';
/** @var ?string[] */ /** @var ?string[] */
protected $colors; protected $colors;

View File

@ -36,8 +36,8 @@ use Symfony\Component\Finder\Finder;
*/ */
class SelfUpdateCommand extends BaseCommand class SelfUpdateCommand extends BaseCommand
{ {
const HOMEPAGE = 'getcomposer.org'; private const HOMEPAGE = 'getcomposer.org';
const OLD_INSTALL_EXT = '-old.phar'; private const OLD_INSTALL_EXT = '-old.phar';
/** /**
* @return void * @return void

View File

@ -32,9 +32,9 @@ use Composer\Util\ProcessExecutor;
*/ */
class StatusCommand extends BaseCommand class StatusCommand extends BaseCommand
{ {
const EXIT_CODE_ERRORS = 1; private const EXIT_CODE_ERRORS = 1;
const EXIT_CODE_UNPUSHED_CHANGES = 2; private const EXIT_CODE_UNPUSHED_CHANGES = 2;
const EXIT_CODE_VERSION_CHANGES = 4; private const EXIT_CODE_VERSION_CHANGES = 4;
/** /**
* @return void * @return void

View File

@ -29,6 +29,8 @@ class Composer extends PartialComposer
/* /*
* Examples of the following constants in the various configurations they can be in * Examples of the following constants in the various configurations they can be in
* *
* You are probably better off using Composer::getVersion() though as that will always return something usable
*
* releases (phar): * releases (phar):
* const VERSION = '1.8.2'; * const VERSION = '1.8.2';
* const BRANCH_ALIAS_VERSION = ''; * const BRANCH_ALIAS_VERSION = '';
@ -46,11 +48,13 @@ class Composer extends PartialComposer
* const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; * const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@';
* const RELEASE_DATE = '@release_date@'; * const RELEASE_DATE = '@release_date@';
* const SOURCE_VERSION = '1.8-dev+source'; * const SOURCE_VERSION = '1.8-dev+source';
*
* @see getVersion()
*/ */
const VERSION = '@package_version@'; public const VERSION = '@package_version@';
const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@';
const RELEASE_DATE = '@release_date@'; public const RELEASE_DATE = '@release_date@';
const SOURCE_VERSION = '2.3.999-dev+source'; public const SOURCE_VERSION = '2.3.999-dev+source';
/** /**
* Version number of the internal composer-runtime-api package * Version number of the internal composer-runtime-api package
@ -61,7 +65,7 @@ class Composer extends PartialComposer
* *
* @var string * @var string
*/ */
const RUNTIME_API_VERSION = '2.2.2'; public const RUNTIME_API_VERSION = '2.2.2';
/** /**
* @return string * @return string

View File

@ -24,11 +24,11 @@ use Composer\Util\ProcessExecutor;
*/ */
class Config class Config
{ {
const SOURCE_DEFAULT = 'default'; public const SOURCE_DEFAULT = 'default';
const SOURCE_COMMAND = 'command'; public const SOURCE_COMMAND = 'command';
const SOURCE_UNKNOWN = 'unknown'; public const SOURCE_UNKNOWN = 'unknown';
const RELATIVE_PATHS = 1; public const RELATIVE_PATHS = 1;
/** @var array<string, mixed> */ /** @var array<string, mixed> */
public static $defaultConfig = array( public static $defaultConfig = array(

View File

@ -20,8 +20,8 @@ namespace Composer\DependencyResolver;
*/ */
class Decisions implements \Iterator, \Countable class Decisions implements \Iterator, \Countable
{ {
const DECISION_LITERAL = 0; public const DECISION_LITERAL = 0;
const DECISION_REASON = 1; public const DECISION_REASON = 1;
/** @var Pool */ /** @var Pool */
protected $pool; protected $pool;

View File

@ -21,7 +21,7 @@ use Composer\Package\PackageInterface;
*/ */
class InstallOperation extends SolverOperation implements OperationInterface class InstallOperation extends SolverOperation implements OperationInterface
{ {
const TYPE = 'install'; protected const TYPE = 'install';
/** /**
* @var PackageInterface * @var PackageInterface

View File

@ -21,7 +21,7 @@ use Composer\Package\AliasPackage;
*/ */
class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
{ {
const TYPE = 'markAliasInstalled'; protected const TYPE = 'markAliasInstalled';
/** /**
* @var AliasPackage * @var AliasPackage

View File

@ -21,7 +21,7 @@ use Composer\Package\AliasPackage;
*/ */
class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
{ {
const TYPE = 'markAliasUninstalled'; protected const TYPE = 'markAliasUninstalled';
/** /**
* @var AliasPackage * @var AliasPackage

View File

@ -19,7 +19,10 @@ namespace Composer\DependencyResolver\Operation;
*/ */
abstract class SolverOperation implements OperationInterface abstract class SolverOperation implements OperationInterface
{ {
const TYPE = null; /**
* @abstract must be redefined by extending classes
*/
protected const TYPE = '';
/** /**
* Returns operation type. * Returns operation type.

View File

@ -21,7 +21,7 @@ use Composer\Package\PackageInterface;
*/ */
class UninstallOperation extends SolverOperation implements OperationInterface class UninstallOperation extends SolverOperation implements OperationInterface
{ {
const TYPE = 'uninstall'; protected const TYPE = 'uninstall';
/** /**
* @var PackageInterface * @var PackageInterface

View File

@ -22,7 +22,7 @@ use Composer\Package\Version\VersionParser;
*/ */
class UpdateOperation extends SolverOperation implements OperationInterface class UpdateOperation extends SolverOperation implements OperationInterface
{ {
const TYPE = 'update'; protected const TYPE = 'update';
/** /**
* @var PackageInterface * @var PackageInterface

View File

@ -26,19 +26,19 @@ class Request
/** /**
* Identifies a partial update for listed packages only, all dependencies will remain at locked versions * Identifies a partial update for listed packages only, all dependencies will remain at locked versions
*/ */
const UPDATE_ONLY_LISTED = 0; public const UPDATE_ONLY_LISTED = 0;
/** /**
* Identifies a partial update for listed packages and recursively all their dependencies, however dependencies * Identifies a partial update for listed packages and recursively all their dependencies, however dependencies
* also directly required by the root composer.json and their dependencies will remain at the locked version. * also directly required by the root composer.json and their dependencies will remain at the locked version.
*/ */
const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1; public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
/** /**
* Identifies a partial update for listed packages and recursively all their dependencies, even dependencies * Identifies a partial update for listed packages and recursively all their dependencies, even dependencies
* also directly required by the root composer.json will be updated. * also directly required by the root composer.json will be updated.
*/ */
const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2; public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
/** @var ?LockArrayRepository */ /** @var ?LockArrayRepository */
protected $lockedRepository; protected $lockedRepository;

View File

@ -29,19 +29,19 @@ use Composer\Semver\Constraint\ConstraintInterface;
abstract class Rule abstract class Rule
{ {
// reason constants and // their reason data contents // reason constants and // their reason data contents
const RULE_ROOT_REQUIRE = 2; // array{packageName: string, constraint: ConstraintInterface} public const RULE_ROOT_REQUIRE = 2; // array{packageName: string, constraint: ConstraintInterface}
const RULE_FIXED = 3; // array{package: BasePackage} public const RULE_FIXED = 3; // array{package: BasePackage}
const RULE_PACKAGE_CONFLICT = 6; // Link public const RULE_PACKAGE_CONFLICT = 6; // Link
const RULE_PACKAGE_REQUIRES = 7; // Link public const RULE_PACKAGE_REQUIRES = 7; // Link
const RULE_PACKAGE_SAME_NAME = 10; // string (package name) public const RULE_PACKAGE_SAME_NAME = 10; // string (package name)
const RULE_LEARNED = 12; // int (rule id) public const RULE_LEARNED = 12; // int (rule id)
const RULE_PACKAGE_ALIAS = 13; // BasePackage public const RULE_PACKAGE_ALIAS = 13; // BasePackage
const RULE_PACKAGE_INVERSE_ALIAS = 14; // BasePackage public const RULE_PACKAGE_INVERSE_ALIAS = 14; // BasePackage
// bitfield defs // bitfield defs
const BITFIELD_TYPE = 0; private const BITFIELD_TYPE = 0;
const BITFIELD_REASON = 8; private const BITFIELD_REASON = 8;
const BITFIELD_DISABLED = 16; private const BITFIELD_DISABLED = 16;
/** @var int */ /** @var int */
protected $bitfield; protected $bitfield;

View File

@ -21,9 +21,9 @@ use Composer\Repository\RepositorySet;
class RuleSet implements \IteratorAggregate, \Countable class RuleSet implements \IteratorAggregate, \Countable
{ {
// highest priority => lowest number // highest priority => lowest number
const TYPE_PACKAGE = 0; public const TYPE_PACKAGE = 0;
const TYPE_REQUEST = 1; public const TYPE_REQUEST = 1;
const TYPE_LEARNED = 4; public const TYPE_LEARNED = 4;
/** /**
* READ-ONLY: Lookup table for rule id to rule object * READ-ONLY: Lookup table for rule id to rule object

View File

@ -23,8 +23,8 @@ use Composer\Package\BasePackage;
*/ */
class Solver class Solver
{ {
const BRANCH_LITERALS = 0; private const BRANCH_LITERALS = 0;
const BRANCH_LEVEL = 1; private const BRANCH_LEVEL = 1;
/** @var PolicyInterface */ /** @var PolicyInterface */
protected $policy; protected $policy;

View File

@ -22,7 +22,7 @@ use Composer\Repository\RepositorySet;
*/ */
class SolverProblemsException extends \RuntimeException class SolverProblemsException extends \RuntimeException
{ {
const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
/** @var Problem[] */ /** @var Problem[] */
protected $problems; protected $problems;

View File

@ -33,8 +33,8 @@ use Composer\DependencyResolver\Operation\UninstallOperation;
*/ */
class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
{ {
const STRATEGY_SYMLINK = 10; private const STRATEGY_SYMLINK = 10;
const STRATEGY_MIRROR = 20; private const STRATEGY_MIRROR = 20;
/** /**
* @inheritDoc * @inheritDoc

View File

@ -22,11 +22,11 @@ use Psr\Log\LoggerInterface;
*/ */
interface IOInterface extends LoggerInterface interface IOInterface extends LoggerInterface
{ {
const QUIET = 1; public const QUIET = 1;
const NORMAL = 2; public const NORMAL = 2;
const VERBOSE = 4; public const VERBOSE = 4;
const VERY_VERBOSE = 8; public const VERY_VERBOSE = 8;
const DEBUG = 16; public const DEBUG = 16;
/** /**
* Is this input means interactive? * Is this input means interactive?

View File

@ -70,12 +70,12 @@ use Composer\Util\Platform;
*/ */
class Installer class Installer
{ {
const ERROR_NONE = 0; // no error/success state public const ERROR_NONE = 0; // no error/success state
const ERROR_GENERIC_FAILURE = 1; public const ERROR_GENERIC_FAILURE = 1;
const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3; public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
const ERROR_LOCK_FILE_INVALID = 4; public const ERROR_LOCK_FILE_INVALID = 4;
// used/declared in SolverProblemsException, carried over here for completeness // used/declared in SolverProblemsException, carried over here for completeness
const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
/** /**
* @var IOInterface * @var IOInterface

View File

@ -22,5 +22,5 @@ class InstallerEvents
* *
* @var string * @var string
*/ */
const PRE_OPERATIONS_EXEC = 'pre-operations-exec'; public const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
} }

View File

@ -26,7 +26,7 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const PRE_PACKAGE_INSTALL = 'pre-package-install'; public const PRE_PACKAGE_INSTALL = 'pre-package-install';
/** /**
* The POST_PACKAGE_INSTALL event occurs after a package is installed. * The POST_PACKAGE_INSTALL event occurs after a package is installed.
@ -35,7 +35,7 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const POST_PACKAGE_INSTALL = 'post-package-install'; public const POST_PACKAGE_INSTALL = 'post-package-install';
/** /**
* The PRE_PACKAGE_UPDATE event occurs before a package is updated. * The PRE_PACKAGE_UPDATE event occurs before a package is updated.
@ -44,7 +44,7 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const PRE_PACKAGE_UPDATE = 'pre-package-update'; public const PRE_PACKAGE_UPDATE = 'pre-package-update';
/** /**
* The POST_PACKAGE_UPDATE event occurs after a package is updated. * The POST_PACKAGE_UPDATE event occurs after a package is updated.
@ -53,7 +53,7 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const POST_PACKAGE_UPDATE = 'post-package-update'; public const POST_PACKAGE_UPDATE = 'post-package-update';
/** /**
* The PRE_PACKAGE_UNINSTALL event occurs before a package has been uninstalled. * The PRE_PACKAGE_UNINSTALL event occurs before a package has been uninstalled.
@ -62,7 +62,7 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall'; public const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
/** /**
* The POST_PACKAGE_UNINSTALL event occurs after a package has been uninstalled. * The POST_PACKAGE_UNINSTALL event occurs after a package has been uninstalled.
@ -71,5 +71,5 @@ class PackageEvents
* *
* @var string * @var string
*/ */
const POST_PACKAGE_UNINSTALL = 'post-package-uninstall'; public const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
} }

View File

@ -25,9 +25,9 @@ use Symfony\Component\Console\Formatter\OutputFormatter;
*/ */
class SuggestedPackagesReporter class SuggestedPackagesReporter
{ {
const MODE_LIST = 1; public const MODE_LIST = 1;
const MODE_BY_PACKAGE = 2; public const MODE_BY_PACKAGE = 2;
const MODE_BY_SUGGESTION = 4; public const MODE_BY_SUGGESTION = 4;
/** /**
* @var array<array{source: string, target: string, reason: string}> * @var array<array{source: string, target: string, reason: string}>

View File

@ -28,8 +28,8 @@ use Composer\Downloader\TransportException;
*/ */
class JsonFile class JsonFile
{ {
const LAX_SCHEMA = 1; public const LAX_SCHEMA = 1;
const STRICT_SCHEMA = 2; public const STRICT_SCHEMA = 2;
/** @deprecated Use \JSON_UNESCAPED_SLASHES */ /** @deprecated Use \JSON_UNESCAPED_SLASHES */
public const JSON_UNESCAPED_SLASHES = 64; public const JSON_UNESCAPED_SLASHES = 64;
@ -38,7 +38,7 @@ class JsonFile
/** @deprecated Use \JSON_UNESCAPED_UNICODE */ /** @deprecated Use \JSON_UNESCAPED_UNICODE */
public const JSON_UNESCAPED_UNICODE = 256; public const JSON_UNESCAPED_UNICODE = 256;
const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json'; public const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json';
/** @var string */ /** @var string */
private $path; private $path;
@ -200,7 +200,7 @@ class JsonFile
$isComposerSchemaFile = false; $isComposerSchemaFile = false;
if (null === $schemaFile) { if (null === $schemaFile) {
$isComposerSchemaFile = true; $isComposerSchemaFile = true;
$schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH; $schemaFile = self::COMPOSER_SCHEMA_PATH;
} }
// Prepend with file:// only when not using a special schema already (e.g. in the phar) // Prepend with file:// only when not using a special schema already (e.g. in the phar)

View File

@ -34,11 +34,11 @@ abstract class BasePackage implements PackageInterface
'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE), 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
); );
const STABILITY_STABLE = 0; public const STABILITY_STABLE = 0;
const STABILITY_RC = 5; public const STABILITY_RC = 5;
const STABILITY_BETA = 10; public const STABILITY_BETA = 10;
const STABILITY_ALPHA = 15; public const STABILITY_ALPHA = 15;
const STABILITY_DEV = 20; public const STABILITY_DEV = 20;
/** @var array<string, self::STABILITY_*> */ /** @var array<string, self::STABILITY_*> */
public static $stabilities = array( public static $stabilities = array(

View File

@ -32,10 +32,7 @@ class Link
* @internal * @internal
*/ */
public const TYPE_DOES_NOT_REQUIRE = 'does not require'; public const TYPE_DOES_NOT_REQUIRE = 'does not require';
/**
* TODO should be marked private once 5.3 is dropped
* @private
*/
private const TYPE_UNKNOWN = 'relates to'; private const TYPE_UNKNOWN = 'relates to';
/** /**

View File

@ -12,7 +12,6 @@
namespace Composer\Package\Loader; namespace Composer\Package\Loader;
use Composer\Package\CompletePackageInterface;
use Composer\Package\CompletePackage; use Composer\Package\CompletePackage;
use Composer\Package\CompleteAliasPackage; use Composer\Package\CompleteAliasPackage;
use Composer\Package\RootAliasPackage; use Composer\Package\RootAliasPackage;

View File

@ -24,9 +24,9 @@ use Composer\Spdx\SpdxLicenses;
*/ */
class ValidatingArrayLoader implements LoaderInterface class ValidatingArrayLoader implements LoaderInterface
{ {
const CHECK_ALL = 3; public const CHECK_ALL = 3;
const CHECK_UNBOUND_CONSTRAINTS = 1; public const CHECK_UNBOUND_CONSTRAINTS = 1;
const CHECK_STRICT_CONSTRAINTS = 2; public const CHECK_STRICT_CONSTRAINTS = 2;
/** @var LoaderInterface */ /** @var LoaderInterface */
private $loader; private $loader;

View File

@ -26,9 +26,9 @@ use Composer\Repository\RepositoryInterface;
*/ */
interface PackageInterface interface PackageInterface
{ {
const DISPLAY_SOURCE_REF_IF_DEV = 0; public const DISPLAY_SOURCE_REF_IF_DEV = 0;
const DISPLAY_SOURCE_REF = 1; public const DISPLAY_SOURCE_REF = 1;
const DISPLAY_DIST_REF = 2; public const DISPLAY_DIST_REF = 2;
/** /**
* Returns the package's name without version info, thus not a unique identifier * Returns the package's name without version info, thus not a unique identifier

View File

@ -19,7 +19,7 @@ namespace Composer\Package;
*/ */
class RootPackage extends CompletePackage implements RootPackageInterface class RootPackage extends CompletePackage implements RootPackageInterface
{ {
const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set'; public const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
/** @var string */ /** @var string */
protected $minimumStability = 'stable'; protected $minimumStability = 'stable';

View File

@ -20,7 +20,7 @@ use Composer\Semver\Constraint\ConstraintInterface;
class VersionParser extends SemverVersionParser class VersionParser extends SemverVersionParser
{ {
const DEFAULT_BRANCH_ALIAS = '9999999-dev'; public const DEFAULT_BRANCH_ALIAS = '9999999-dev';
/** @var array<string, ConstraintInterface> Constraint parsing cache */ /** @var array<string, ConstraintInterface> Constraint parsing cache */
private static $constraints = array(); private static $constraints = array();

View File

@ -27,7 +27,7 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const INIT = 'init'; public const INIT = 'init';
/** /**
* The COMMAND event occurs as a command begins * The COMMAND event occurs as a command begins
@ -37,7 +37,7 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const COMMAND = 'command'; public const COMMAND = 'command';
/** /**
* The PRE_FILE_DOWNLOAD event occurs before downloading a file * The PRE_FILE_DOWNLOAD event occurs before downloading a file
@ -47,7 +47,7 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const PRE_FILE_DOWNLOAD = 'pre-file-download'; public const PRE_FILE_DOWNLOAD = 'pre-file-download';
/** /**
* The POST_FILE_DOWNLOAD event occurs after downloading a package dist file * The POST_FILE_DOWNLOAD event occurs after downloading a package dist file
@ -57,7 +57,7 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const POST_FILE_DOWNLOAD = 'post-file-download'; public const POST_FILE_DOWNLOAD = 'post-file-download';
/** /**
* The PRE_COMMAND_RUN event occurs before a command is executed and lets you modify the input arguments/options * The PRE_COMMAND_RUN event occurs before a command is executed and lets you modify the input arguments/options
@ -67,7 +67,7 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const PRE_COMMAND_RUN = 'pre-command-run'; public const PRE_COMMAND_RUN = 'pre-command-run';
/** /**
* The PRE_POOL_CREATE event occurs before the Pool of packages is created, and lets * The PRE_POOL_CREATE event occurs before the Pool of packages is created, and lets
@ -78,5 +78,5 @@ class PluginEvents
* *
* @var string * @var string
*/ */
const PRE_POOL_CREATE = 'pre-pool-create'; public const PRE_POOL_CREATE = 'pre-pool-create';
} }

View File

@ -32,7 +32,7 @@ interface PluginInterface
* *
* @var string * @var string
*/ */
const PLUGIN_API_VERSION = '2.3.0'; public const PLUGIN_API_VERSION = '2.3.0';
/** /**
* Apply plugin modifications to Composer * Apply plugin modifications to Composer

View File

@ -32,7 +32,11 @@ use Composer\XdebugHandler\XdebugHandler;
*/ */
class PlatformRepository extends ArrayRepository class PlatformRepository extends ArrayRepository
{ {
const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD'; /**
* @deprecated use PlatformRepository::isPlatformPackage(string $name) instead
* @private
*/
public const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD';
/** /**
* @var ?string * @var ?string

View File

@ -25,9 +25,9 @@ use Composer\Semver\Constraint\ConstraintInterface;
*/ */
interface RepositoryInterface extends \Countable interface RepositoryInterface extends \Countable
{ {
const SEARCH_FULLTEXT = 0; public const SEARCH_FULLTEXT = 0;
const SEARCH_NAME = 1; public const SEARCH_NAME = 1;
const SEARCH_VENDOR = 2; public const SEARCH_VENDOR = 2;
/** /**
* Checks if specified package registered (installed). * Checks if specified package registered (installed).

View File

@ -34,11 +34,11 @@ class RepositorySet
/** /**
* Packages are returned even though their stability does not match the required stability * Packages are returned even though their stability does not match the required stability
*/ */
const ALLOW_UNACCEPTABLE_STABILITIES = 1; public const ALLOW_UNACCEPTABLE_STABILITIES = 1;
/** /**
* Packages will be looked up in all repositories, even after they have been found in a higher prio one * Packages will be looked up in all repositories, even after they have been found in a higher prio one
*/ */
const ALLOW_SHADOWED_REPOSITORIES = 2; public const ALLOW_SHADOWED_REPOSITORIES = 2;
/** /**
* @var array[] * @var array[]

View File

@ -82,7 +82,7 @@ class GitLabDriver extends VcsDriver
*/ */
private $hasNonstandardOrigin = false; private $hasNonstandardOrigin = false;
const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#'; private const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
/** /**
* Extracts information from the repository url. * Extracts information from the repository url.

View File

@ -27,7 +27,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const PRE_INSTALL_CMD = 'pre-install-cmd'; public const PRE_INSTALL_CMD = 'pre-install-cmd';
/** /**
* The POST_INSTALL_CMD event occurs after the install command is executed. * The POST_INSTALL_CMD event occurs after the install command is executed.
@ -36,7 +36,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_INSTALL_CMD = 'post-install-cmd'; public const POST_INSTALL_CMD = 'post-install-cmd';
/** /**
* The PRE_UPDATE_CMD event occurs before the update command is executed. * The PRE_UPDATE_CMD event occurs before the update command is executed.
@ -45,7 +45,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const PRE_UPDATE_CMD = 'pre-update-cmd'; public const PRE_UPDATE_CMD = 'pre-update-cmd';
/** /**
* The POST_UPDATE_CMD event occurs after the update command is executed. * The POST_UPDATE_CMD event occurs after the update command is executed.
@ -54,7 +54,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_UPDATE_CMD = 'post-update-cmd'; public const POST_UPDATE_CMD = 'post-update-cmd';
/** /**
* The PRE_STATUS_CMD event occurs before the status command is executed. * The PRE_STATUS_CMD event occurs before the status command is executed.
@ -63,7 +63,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const PRE_STATUS_CMD = 'pre-status-cmd'; public const PRE_STATUS_CMD = 'pre-status-cmd';
/** /**
* The POST_STATUS_CMD event occurs after the status command is executed. * The POST_STATUS_CMD event occurs after the status command is executed.
@ -72,7 +72,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_STATUS_CMD = 'post-status-cmd'; public const POST_STATUS_CMD = 'post-status-cmd';
/** /**
* The PRE_AUTOLOAD_DUMP event occurs before the autoload file is generated. * The PRE_AUTOLOAD_DUMP event occurs before the autoload file is generated.
@ -81,7 +81,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump'; public const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
/** /**
* The POST_AUTOLOAD_DUMP event occurs after the autoload file has been generated. * The POST_AUTOLOAD_DUMP event occurs after the autoload file has been generated.
@ -90,7 +90,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_AUTOLOAD_DUMP = 'post-autoload-dump'; public const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
/** /**
* The POST_ROOT_PACKAGE_INSTALL event occurs after the root package has been installed. * The POST_ROOT_PACKAGE_INSTALL event occurs after the root package has been installed.
@ -99,7 +99,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install'; public const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
/** /**
* The POST_CREATE_PROJECT event occurs after the create-project command has been executed. * The POST_CREATE_PROJECT event occurs after the create-project command has been executed.
@ -109,7 +109,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd'; public const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
/** /**
* The PRE_ARCHIVE_CMD event occurs before the update command is executed. * The PRE_ARCHIVE_CMD event occurs before the update command is executed.
@ -118,7 +118,7 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const PRE_ARCHIVE_CMD = 'pre-archive-cmd'; public const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
/** /**
* The POST_ARCHIVE_CMD event occurs after the status command is executed. * The POST_ARCHIVE_CMD event occurs after the status command is executed.
@ -127,5 +127,5 @@ class ScriptEvents
* *
* @var string * @var string
*/ */
const POST_ARCHIVE_CMD = 'post-archive-cmd'; public const POST_ARCHIVE_CMD = 'post-archive-cmd';
} }

View File

@ -35,7 +35,7 @@ class Bitbucket
/** @var int|null */ /** @var int|null */
private $time; private $time;
const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token'; public const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
/** /**
* Constructor. * Constructor.

View File

@ -29,7 +29,7 @@ use Composer\Spdx\SpdxLicenses;
*/ */
class ConfigValidator class ConfigValidator
{ {
const CHECK_VERSION = 1; public const CHECK_VERSION = 1;
/** @var IOInterface */ /** @var IOInterface */
private $io; private $io;

View File

@ -32,11 +32,11 @@ use React\Promise\PromiseInterface;
*/ */
class HttpDownloader class HttpDownloader
{ {
const STATUS_QUEUED = 1; private const STATUS_QUEUED = 1;
const STATUS_STARTED = 2; private const STATUS_STARTED = 2;
const STATUS_COMPLETED = 3; private const STATUS_COMPLETED = 3;
const STATUS_FAILED = 4; private const STATUS_FAILED = 4;
const STATUS_ABORTED = 5; private const STATUS_ABORTED = 5;
/** @var IOInterface */ /** @var IOInterface */
private $io; private $io;

View File

@ -25,11 +25,11 @@ use React\Promise\PromiseInterface;
*/ */
class ProcessExecutor class ProcessExecutor
{ {
const STATUS_QUEUED = 1; private const STATUS_QUEUED = 1;
const STATUS_STARTED = 2; private const STATUS_STARTED = 2;
const STATUS_COMPLETED = 3; private const STATUS_COMPLETED = 3;
const STATUS_FAILED = 4; private const STATUS_FAILED = 4;
const STATUS_ABORTED = 5; private const STATUS_ABORTED = 5;
/** @var int */ /** @var int */
protected static $timeout = 300; protected static $timeout = 300;

View File

@ -22,7 +22,7 @@ use Composer\Pcre\Preg;
*/ */
class Svn class Svn
{ {
const MAX_QTY_AUTH_TRIES = 5; private const MAX_QTY_AUTH_TRIES = 5;
/** /**
* @var ?array{username: string, password: string} * @var ?array{username: string, password: string}

View File

@ -10,7 +10,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
function includeIfExists(string $file): ?\Composer\Autoload\ClassLoader use Composer\Autoload\ClassLoader;
function includeIfExists(string $file): ?ClassLoader
{ {
return file_exists($file) ? include $file : null; return file_exists($file) ? include $file : null;
} }

View File

@ -82,12 +82,9 @@ class AutoloadGeneratorTest extends TestCase
* Map of setting name => return value configuration for the stub Config * Map of setting name => return value configuration for the stub Config
* object. * object.
* *
* Note: must be public for compatibility with PHP 5.3 runtimes where
* closures cannot access private members of the classes they are created
* in.
* @var array<string, callable|boolean> * @var array<string, callable|boolean>
*/ */
public $configValueMap; private $configValueMap;
protected function setUp(): void protected function setUp(): void
{ {

View File

@ -66,7 +66,8 @@ class InitCommandTest extends TestCase
public function testParseValidAlias1AuthorString(): void public function testParseValidAlias1AuthorString(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, $author = $this->callParseAuthorString(
$command,
'Johnathon "Johnny" Smith <john@example.com>' 'Johnathon "Johnny" Smith <john@example.com>'
); );
$this->assertEquals('Johnathon "Johnny" Smith', $author['name']); $this->assertEquals('Johnathon "Johnny" Smith', $author['name']);
@ -80,7 +81,8 @@ class InitCommandTest extends TestCase
public function testParseValidAlias2AuthorString(): void public function testParseValidAlias2AuthorString(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, $author = $this->callParseAuthorString(
$command,
'Johnathon (Johnny) Smith <john@example.com>' 'Johnathon (Johnny) Smith <john@example.com>'
); );
$this->assertEquals('Johnathon (Johnny) Smith', $author['name']); $this->assertEquals('Johnathon (Johnny) Smith', $author['name']);

View File

@ -1271,7 +1271,7 @@ Linked Version => 1.2.11',
class ResourceBundleStub class ResourceBundleStub
{ {
const STUB_VERSION = '32.0.1'; public const STUB_VERSION = '32.0.1';
/** /**
* @param string $locale * @param string $locale

View File

@ -57,9 +57,9 @@ class PerforceDriverTest extends TestCase
*/ */
protected $perforce; protected $perforce;
const TEST_URL = 'TEST_PERFORCE_URL'; private const TEST_URL = 'TEST_PERFORCE_URL';
const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; private const TEST_DEPOT = 'TEST_DEPOT_CONFIG';
const TEST_BRANCH = 'TEST_BRANCH_CONFIG'; private const TEST_BRANCH = 'TEST_BRANCH_CONFIG';
protected function setUp(): void protected function setUp(): void
{ {

View File

@ -32,12 +32,12 @@ class PerforceTest extends TestCase
/** @var \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\IOInterface */ /** @var \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\IOInterface */
protected $io; protected $io;
const TEST_DEPOT = 'depot'; private const TEST_DEPOT = 'depot';
const TEST_BRANCH = 'branch'; private const TEST_BRANCH = 'branch';
const TEST_P4USER = 'user'; private const TEST_P4USER = 'user';
const TEST_CLIENT_NAME = 'TEST'; private const TEST_CLIENT_NAME = 'TEST';
const TEST_PORT = 'port'; private const TEST_PORT = 'port';
const TEST_PATH = 'path'; private const TEST_PATH = 'path';
protected function setUp(): void protected function setUp(): void
{ {