diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 8e567fe0c369..62d1ac7f74fa 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -65,7 +65,7 @@ // TODO later once 2.2 is more stable // 'array_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, 'combine_nested_dirname' => true, 'random_api_migration' => true, diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 747e898cec53..badf948db226 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -5495,6 +5495,14 @@ parameters: count: 1 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\\.$#" count: 1 diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index 5dfbd9fa1c39..9f5b4a7e1688 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -36,10 +36,10 @@ */ class BaseDependencyCommand extends BaseCommand { - const ARGUMENT_PACKAGE = 'package'; - const ARGUMENT_CONSTRAINT = 'version'; - const OPTION_RECURSIVE = 'recursive'; - const OPTION_TREE = 'tree'; + protected const ARGUMENT_PACKAGE = 'package'; + protected const ARGUMENT_CONSTRAINT = 'version'; + protected const OPTION_RECURSIVE = 'recursive'; + protected const OPTION_TREE = 'tree'; /** @var ?string[] */ protected $colors; diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index af0b1007eb26..c0b688e585bd 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -36,8 +36,8 @@ */ class SelfUpdateCommand extends BaseCommand { - const HOMEPAGE = 'getcomposer.org'; - const OLD_INSTALL_EXT = '-old.phar'; + private const HOMEPAGE = 'getcomposer.org'; + private const OLD_INSTALL_EXT = '-old.phar'; /** * @return void diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php index 8aec0e70dcdb..58b6663a719a 100644 --- a/src/Composer/Command/StatusCommand.php +++ b/src/Composer/Command/StatusCommand.php @@ -32,9 +32,9 @@ */ class StatusCommand extends BaseCommand { - const EXIT_CODE_ERRORS = 1; - const EXIT_CODE_UNPUSHED_CHANGES = 2; - const EXIT_CODE_VERSION_CHANGES = 4; + private const EXIT_CODE_ERRORS = 1; + private const EXIT_CODE_UNPUSHED_CHANGES = 2; + private const EXIT_CODE_VERSION_CHANGES = 4; /** * @return void diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 8913397b6f43..a4b769ee2207 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -29,6 +29,8 @@ class Composer extends PartialComposer /* * 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): * const VERSION = '1.8.2'; * const BRANCH_ALIAS_VERSION = ''; @@ -46,11 +48,13 @@ class Composer extends PartialComposer * const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; * const RELEASE_DATE = '@release_date@'; * const SOURCE_VERSION = '1.8-dev+source'; + * + * @see getVersion() */ - const VERSION = '@package_version@'; - const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; - const RELEASE_DATE = '@release_date@'; - const SOURCE_VERSION = '2.3.999-dev+source'; + public const VERSION = '@package_version@'; + public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; + public const RELEASE_DATE = '@release_date@'; + public const SOURCE_VERSION = '2.3.999-dev+source'; /** * Version number of the internal composer-runtime-api package @@ -61,7 +65,7 @@ class Composer extends PartialComposer * * @var string */ - const RUNTIME_API_VERSION = '2.2.2'; + public const RUNTIME_API_VERSION = '2.2.2'; /** * @return string diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 57c54a09772e..b009af3820ec 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -24,11 +24,11 @@ */ class Config { - const SOURCE_DEFAULT = 'default'; - const SOURCE_COMMAND = 'command'; - const SOURCE_UNKNOWN = 'unknown'; + public const SOURCE_DEFAULT = 'default'; + public const SOURCE_COMMAND = 'command'; + public const SOURCE_UNKNOWN = 'unknown'; - const RELATIVE_PATHS = 1; + public const RELATIVE_PATHS = 1; /** @var array */ public static $defaultConfig = array( diff --git a/src/Composer/DependencyResolver/Decisions.php b/src/Composer/DependencyResolver/Decisions.php index f9e3490244c3..f06a25a8b74d 100644 --- a/src/Composer/DependencyResolver/Decisions.php +++ b/src/Composer/DependencyResolver/Decisions.php @@ -20,8 +20,8 @@ */ class Decisions implements \Iterator, \Countable { - const DECISION_LITERAL = 0; - const DECISION_REASON = 1; + public const DECISION_LITERAL = 0; + public const DECISION_REASON = 1; /** @var Pool */ protected $pool; diff --git a/src/Composer/DependencyResolver/Operation/InstallOperation.php b/src/Composer/DependencyResolver/Operation/InstallOperation.php index 7f66d17e9c4b..da31a52cccc1 100644 --- a/src/Composer/DependencyResolver/Operation/InstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/InstallOperation.php @@ -21,7 +21,7 @@ */ class InstallOperation extends SolverOperation implements OperationInterface { - const TYPE = 'install'; + protected const TYPE = 'install'; /** * @var PackageInterface diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index e1c21008b574..8626813e2571 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -21,7 +21,7 @@ */ class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface { - const TYPE = 'markAliasInstalled'; + protected const TYPE = 'markAliasInstalled'; /** * @var AliasPackage diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 6cdd02837f1c..1e858ef1e65f 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -21,7 +21,7 @@ */ class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface { - const TYPE = 'markAliasUninstalled'; + protected const TYPE = 'markAliasUninstalled'; /** * @var AliasPackage diff --git a/src/Composer/DependencyResolver/Operation/SolverOperation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php index 5aa0957a75d0..094029af0e46 100644 --- a/src/Composer/DependencyResolver/Operation/SolverOperation.php +++ b/src/Composer/DependencyResolver/Operation/SolverOperation.php @@ -19,7 +19,10 @@ */ abstract class SolverOperation implements OperationInterface { - const TYPE = null; + /** + * @abstract must be redefined by extending classes + */ + protected const TYPE = ''; /** * Returns operation type. diff --git a/src/Composer/DependencyResolver/Operation/UninstallOperation.php b/src/Composer/DependencyResolver/Operation/UninstallOperation.php index 7b4ff8ddb3f0..878691508b51 100644 --- a/src/Composer/DependencyResolver/Operation/UninstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/UninstallOperation.php @@ -21,7 +21,7 @@ */ class UninstallOperation extends SolverOperation implements OperationInterface { - const TYPE = 'uninstall'; + protected const TYPE = 'uninstall'; /** * @var PackageInterface diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index e674376f5fc3..728bb15116fc 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -22,7 +22,7 @@ */ class UpdateOperation extends SolverOperation implements OperationInterface { - const TYPE = 'update'; + protected const TYPE = 'update'; /** * @var PackageInterface diff --git a/src/Composer/DependencyResolver/Request.php b/src/Composer/DependencyResolver/Request.php index dde4972f5b85..d7cde079377a 100644 --- a/src/Composer/DependencyResolver/Request.php +++ b/src/Composer/DependencyResolver/Request.php @@ -26,19 +26,19 @@ class Request /** * 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 * 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 * 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 */ protected $lockedRepository; diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index bcf32fb03fd0..55e75e624768 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -29,19 +29,19 @@ abstract class Rule { // reason constants and // their reason data contents - const RULE_ROOT_REQUIRE = 2; // array{packageName: string, constraint: ConstraintInterface} - const RULE_FIXED = 3; // array{package: BasePackage} - const RULE_PACKAGE_CONFLICT = 6; // Link - const RULE_PACKAGE_REQUIRES = 7; // Link - const RULE_PACKAGE_SAME_NAME = 10; // string (package name) - const RULE_LEARNED = 12; // int (rule id) - const RULE_PACKAGE_ALIAS = 13; // BasePackage - const RULE_PACKAGE_INVERSE_ALIAS = 14; // BasePackage + public const RULE_ROOT_REQUIRE = 2; // array{packageName: string, constraint: ConstraintInterface} + public const RULE_FIXED = 3; // array{package: BasePackage} + public const RULE_PACKAGE_CONFLICT = 6; // Link + public const RULE_PACKAGE_REQUIRES = 7; // Link + public const RULE_PACKAGE_SAME_NAME = 10; // string (package name) + public const RULE_LEARNED = 12; // int (rule id) + public const RULE_PACKAGE_ALIAS = 13; // BasePackage + public const RULE_PACKAGE_INVERSE_ALIAS = 14; // BasePackage // bitfield defs - const BITFIELD_TYPE = 0; - const BITFIELD_REASON = 8; - const BITFIELD_DISABLED = 16; + private const BITFIELD_TYPE = 0; + private const BITFIELD_REASON = 8; + private const BITFIELD_DISABLED = 16; /** @var int */ protected $bitfield; diff --git a/src/Composer/DependencyResolver/RuleSet.php b/src/Composer/DependencyResolver/RuleSet.php index d430b46a9339..9d856c4b68f7 100644 --- a/src/Composer/DependencyResolver/RuleSet.php +++ b/src/Composer/DependencyResolver/RuleSet.php @@ -21,9 +21,9 @@ class RuleSet implements \IteratorAggregate, \Countable { // highest priority => lowest number - const TYPE_PACKAGE = 0; - const TYPE_REQUEST = 1; - const TYPE_LEARNED = 4; + public const TYPE_PACKAGE = 0; + public const TYPE_REQUEST = 1; + public const TYPE_LEARNED = 4; /** * READ-ONLY: Lookup table for rule id to rule object diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index e90c3b67e731..0a07203983af 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -23,8 +23,8 @@ */ class Solver { - const BRANCH_LITERALS = 0; - const BRANCH_LEVEL = 1; + private const BRANCH_LITERALS = 0; + private const BRANCH_LEVEL = 1; /** @var PolicyInterface */ protected $policy; diff --git a/src/Composer/DependencyResolver/SolverProblemsException.php b/src/Composer/DependencyResolver/SolverProblemsException.php index 936c73d744a1..caec38a34ae6 100644 --- a/src/Composer/DependencyResolver/SolverProblemsException.php +++ b/src/Composer/DependencyResolver/SolverProblemsException.php @@ -22,7 +22,7 @@ */ class SolverProblemsException extends \RuntimeException { - const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; + public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; /** @var Problem[] */ protected $problems; diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 48a01ef613be..8cb7865e8ed7 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -33,8 +33,8 @@ */ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface { - const STRATEGY_SYMLINK = 10; - const STRATEGY_MIRROR = 20; + private const STRATEGY_SYMLINK = 10; + private const STRATEGY_MIRROR = 20; /** * @inheritDoc diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 66fe735db3a5..ba987cc8a390 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -22,11 +22,11 @@ */ interface IOInterface extends LoggerInterface { - const QUIET = 1; - const NORMAL = 2; - const VERBOSE = 4; - const VERY_VERBOSE = 8; - const DEBUG = 16; + public const QUIET = 1; + public const NORMAL = 2; + public const VERBOSE = 4; + public const VERY_VERBOSE = 8; + public const DEBUG = 16; /** * Is this input means interactive? diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index c9b3be229ab0..ec0800947867 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -70,12 +70,12 @@ */ class Installer { - const ERROR_NONE = 0; // no error/success state - const ERROR_GENERIC_FAILURE = 1; - const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3; - const ERROR_LOCK_FILE_INVALID = 4; + public const ERROR_NONE = 0; // no error/success state + public const ERROR_GENERIC_FAILURE = 1; + public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3; + public const ERROR_LOCK_FILE_INVALID = 4; // used/declared in SolverProblemsException, carried over here for completeness - const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; + public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; /** * @var IOInterface diff --git a/src/Composer/Installer/InstallerEvents.php b/src/Composer/Installer/InstallerEvents.php index f75b8bdd4171..d536b459cf61 100644 --- a/src/Composer/Installer/InstallerEvents.php +++ b/src/Composer/Installer/InstallerEvents.php @@ -22,5 +22,5 @@ class InstallerEvents * * @var string */ - const PRE_OPERATIONS_EXEC = 'pre-operations-exec'; + public const PRE_OPERATIONS_EXEC = 'pre-operations-exec'; } diff --git a/src/Composer/Installer/PackageEvents.php b/src/Composer/Installer/PackageEvents.php index 1b48e4f696f9..852da58ff126 100644 --- a/src/Composer/Installer/PackageEvents.php +++ b/src/Composer/Installer/PackageEvents.php @@ -26,7 +26,7 @@ class PackageEvents * * @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. @@ -35,7 +35,7 @@ class PackageEvents * * @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. @@ -44,7 +44,7 @@ class PackageEvents * * @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. @@ -53,7 +53,7 @@ class PackageEvents * * @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. @@ -62,7 +62,7 @@ class PackageEvents * * @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. @@ -71,5 +71,5 @@ class PackageEvents * * @var string */ - const POST_PACKAGE_UNINSTALL = 'post-package-uninstall'; + public const POST_PACKAGE_UNINSTALL = 'post-package-uninstall'; } diff --git a/src/Composer/Installer/SuggestedPackagesReporter.php b/src/Composer/Installer/SuggestedPackagesReporter.php index 3b1c92651b32..f2cfafebda7d 100644 --- a/src/Composer/Installer/SuggestedPackagesReporter.php +++ b/src/Composer/Installer/SuggestedPackagesReporter.php @@ -25,9 +25,9 @@ */ class SuggestedPackagesReporter { - const MODE_LIST = 1; - const MODE_BY_PACKAGE = 2; - const MODE_BY_SUGGESTION = 4; + public const MODE_LIST = 1; + public const MODE_BY_PACKAGE = 2; + public const MODE_BY_SUGGESTION = 4; /** * @var array diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index a14ba7b60bc1..d464d9e77c35 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -28,8 +28,8 @@ */ class JsonFile { - const LAX_SCHEMA = 1; - const STRICT_SCHEMA = 2; + public const LAX_SCHEMA = 1; + public const STRICT_SCHEMA = 2; /** @deprecated Use \JSON_UNESCAPED_SLASHES */ public const JSON_UNESCAPED_SLASHES = 64; @@ -38,7 +38,7 @@ class JsonFile /** @deprecated Use \JSON_UNESCAPED_UNICODE */ 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 */ private $path; @@ -204,7 +204,7 @@ public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schem $isComposerSchemaFile = false; if (null === $schemaFile) { $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) diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 1adff603b12e..d673caf05911 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -34,11 +34,11 @@ abstract class BasePackage implements PackageInterface 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE), ); - const STABILITY_STABLE = 0; - const STABILITY_RC = 5; - const STABILITY_BETA = 10; - const STABILITY_ALPHA = 15; - const STABILITY_DEV = 20; + public const STABILITY_STABLE = 0; + public const STABILITY_RC = 5; + public const STABILITY_BETA = 10; + public const STABILITY_ALPHA = 15; + public const STABILITY_DEV = 20; /** @var array */ public static $stabilities = array( diff --git a/src/Composer/Package/Link.php b/src/Composer/Package/Link.php index 481988c154f1..1430cd800715 100644 --- a/src/Composer/Package/Link.php +++ b/src/Composer/Package/Link.php @@ -32,10 +32,7 @@ class Link * @internal */ 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'; /** diff --git a/src/Composer/Package/Loader/LoaderInterface.php b/src/Composer/Package/Loader/LoaderInterface.php index c81176ded91d..be2e4704237b 100644 --- a/src/Composer/Package/Loader/LoaderInterface.php +++ b/src/Composer/Package/Loader/LoaderInterface.php @@ -12,7 +12,6 @@ namespace Composer\Package\Loader; -use Composer\Package\CompletePackageInterface; use Composer\Package\CompletePackage; use Composer\Package\CompleteAliasPackage; use Composer\Package\RootAliasPackage; diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index 70a6affe3008..bf51849fd0ad 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -24,9 +24,9 @@ */ class ValidatingArrayLoader implements LoaderInterface { - const CHECK_ALL = 3; - const CHECK_UNBOUND_CONSTRAINTS = 1; - const CHECK_STRICT_CONSTRAINTS = 2; + public const CHECK_ALL = 3; + public const CHECK_UNBOUND_CONSTRAINTS = 1; + public const CHECK_STRICT_CONSTRAINTS = 2; /** @var LoaderInterface */ private $loader; diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index 31a0e78fb8f9..e666e7139d0a 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -26,9 +26,9 @@ */ interface PackageInterface { - const DISPLAY_SOURCE_REF_IF_DEV = 0; - const DISPLAY_SOURCE_REF = 1; - const DISPLAY_DIST_REF = 2; + public const DISPLAY_SOURCE_REF_IF_DEV = 0; + public const DISPLAY_SOURCE_REF = 1; + public const DISPLAY_DIST_REF = 2; /** * Returns the package's name without version info, thus not a unique identifier diff --git a/src/Composer/Package/RootPackage.php b/src/Composer/Package/RootPackage.php index 07bd31d6fe87..a0b7ec950516 100644 --- a/src/Composer/Package/RootPackage.php +++ b/src/Composer/Package/RootPackage.php @@ -19,7 +19,7 @@ */ 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 */ protected $minimumStability = 'stable'; diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index faa5002c785c..6c0345999069 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -20,7 +20,7 @@ class VersionParser extends SemverVersionParser { - const DEFAULT_BRANCH_ALIAS = '9999999-dev'; + public const DEFAULT_BRANCH_ALIAS = '9999999-dev'; /** @var array Constraint parsing cache */ private static $constraints = array(); diff --git a/src/Composer/Plugin/PluginEvents.php b/src/Composer/Plugin/PluginEvents.php index ff476ba40d17..c2e58d510f36 100644 --- a/src/Composer/Plugin/PluginEvents.php +++ b/src/Composer/Plugin/PluginEvents.php @@ -27,7 +27,7 @@ class PluginEvents * * @var string */ - const INIT = 'init'; + public const INIT = 'init'; /** * The COMMAND event occurs as a command begins @@ -37,7 +37,7 @@ class PluginEvents * * @var string */ - const COMMAND = 'command'; + public const COMMAND = 'command'; /** * The PRE_FILE_DOWNLOAD event occurs before downloading a file @@ -47,7 +47,7 @@ class PluginEvents * * @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 @@ -57,7 +57,7 @@ class PluginEvents * * @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 @@ -67,7 +67,7 @@ class PluginEvents * * @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 @@ -78,5 +78,5 @@ class PluginEvents * * @var string */ - const PRE_POOL_CREATE = 'pre-pool-create'; + public const PRE_POOL_CREATE = 'pre-pool-create'; } diff --git a/src/Composer/Plugin/PluginInterface.php b/src/Composer/Plugin/PluginInterface.php index c2a35e50adf8..ae5139a849d2 100644 --- a/src/Composer/Plugin/PluginInterface.php +++ b/src/Composer/Plugin/PluginInterface.php @@ -32,7 +32,7 @@ interface PluginInterface * * @var string */ - const PLUGIN_API_VERSION = '2.3.0'; + public const PLUGIN_API_VERSION = '2.3.0'; /** * Apply plugin modifications to Composer diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 461191e4a2ae..3c9c625fed86 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -32,7 +32,11 @@ */ 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 diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index 0de31edd3d64..129a0949879a 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -25,9 +25,9 @@ */ interface RepositoryInterface extends \Countable { - const SEARCH_FULLTEXT = 0; - const SEARCH_NAME = 1; - const SEARCH_VENDOR = 2; + public const SEARCH_FULLTEXT = 0; + public const SEARCH_NAME = 1; + public const SEARCH_VENDOR = 2; /** * Checks if specified package registered (installed). diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index d13a423e03ca..c0e39fd5f2dd 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -34,11 +34,11 @@ class RepositorySet /** * 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 */ - const ALLOW_SHADOWED_REPOSITORIES = 2; + public const ALLOW_SHADOWED_REPOSITORIES = 2; /** * @var array[] diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 047cefa240a5..13ecd755d636 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -82,7 +82,7 @@ class GitLabDriver extends VcsDriver */ private $hasNonstandardOrigin = false; - const URL_REGEX = '#^(?:(?Phttps?)://(?P.+?)(?::(?P[0-9]+))?/|git@(?P[^:]+):)(?P.+)/(?P[^/]+?)(?:\.git|/)?$#'; + private const URL_REGEX = '#^(?:(?Phttps?)://(?P.+?)(?::(?P[0-9]+))?/|git@(?P[^:]+):)(?P.+)/(?P[^/]+?)(?:\.git|/)?$#'; /** * Extracts information from the repository url. diff --git a/src/Composer/Script/ScriptEvents.php b/src/Composer/Script/ScriptEvents.php index d2dc6662554f..33cc4f57dd8b 100644 --- a/src/Composer/Script/ScriptEvents.php +++ b/src/Composer/Script/ScriptEvents.php @@ -27,7 +27,7 @@ class ScriptEvents * * @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. @@ -36,7 +36,7 @@ class ScriptEvents * * @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. @@ -45,7 +45,7 @@ class ScriptEvents * * @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. @@ -54,7 +54,7 @@ class ScriptEvents * * @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. @@ -63,7 +63,7 @@ class ScriptEvents * * @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. @@ -72,7 +72,7 @@ class ScriptEvents * * @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. @@ -81,7 +81,7 @@ class ScriptEvents * * @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. @@ -90,7 +90,7 @@ class ScriptEvents * * @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. @@ -99,7 +99,7 @@ class ScriptEvents * * @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. @@ -109,7 +109,7 @@ class ScriptEvents * * @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. @@ -118,7 +118,7 @@ class ScriptEvents * * @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. @@ -127,5 +127,5 @@ class ScriptEvents * * @var string */ - const POST_ARCHIVE_CMD = 'post-archive-cmd'; + public const POST_ARCHIVE_CMD = 'post-archive-cmd'; } diff --git a/src/Composer/Util/Bitbucket.php b/src/Composer/Util/Bitbucket.php index 4ce3b7599ddb..b80eb37bec79 100644 --- a/src/Composer/Util/Bitbucket.php +++ b/src/Composer/Util/Bitbucket.php @@ -35,7 +35,7 @@ class Bitbucket /** @var int|null */ 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. diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index 4d2f50d2dd09..ea84c10b299b 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -29,7 +29,7 @@ */ class ConfigValidator { - const CHECK_VERSION = 1; + public const CHECK_VERSION = 1; /** @var IOInterface */ private $io; diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index bc229960f3e4..b0377bf79d7a 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -32,11 +32,11 @@ */ class HttpDownloader { - const STATUS_QUEUED = 1; - const STATUS_STARTED = 2; - const STATUS_COMPLETED = 3; - const STATUS_FAILED = 4; - const STATUS_ABORTED = 5; + private const STATUS_QUEUED = 1; + private const STATUS_STARTED = 2; + private const STATUS_COMPLETED = 3; + private const STATUS_FAILED = 4; + private const STATUS_ABORTED = 5; /** @var IOInterface */ private $io; diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index f55515192688..f936fcad116f 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -25,11 +25,11 @@ */ class ProcessExecutor { - const STATUS_QUEUED = 1; - const STATUS_STARTED = 2; - const STATUS_COMPLETED = 3; - const STATUS_FAILED = 4; - const STATUS_ABORTED = 5; + private const STATUS_QUEUED = 1; + private const STATUS_STARTED = 2; + private const STATUS_COMPLETED = 3; + private const STATUS_FAILED = 4; + private const STATUS_ABORTED = 5; /** @var int */ protected static $timeout = 300; diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index 86416e56d508..00a090d5c2c9 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -22,7 +22,7 @@ */ class Svn { - const MAX_QTY_AUTH_TRIES = 5; + private const MAX_QTY_AUTH_TRIES = 5; /** * @var ?array{username: string, password: string} diff --git a/src/bootstrap.php b/src/bootstrap.php index f61063a4a0f8..3b2cb4d852f7 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -10,7 +10,9 @@ * 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; } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 87ff8c4aaa71..508f1c03a0f3 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -83,12 +83,9 @@ class AutoloadGeneratorTest extends TestCase * Map of setting name => return value configuration for the stub Config * 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 */ - public $configValueMap; + private $configValueMap; protected function setUp(): void { diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 25af49ed503c..f33f730b93a1 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -66,7 +66,8 @@ public function testParseNumericAuthorString(): void public function testParseValidAlias1AuthorString(): void { $command = new InitCommand; - $author = $this->callParseAuthorString($command, + $author = $this->callParseAuthorString( + $command, 'Johnathon "Johnny" Smith ' ); $this->assertEquals('Johnathon "Johnny" Smith', $author['name']); @@ -80,7 +81,8 @@ public function testParseValidAlias1AuthorString(): void public function testParseValidAlias2AuthorString(): void { $command = new InitCommand; - $author = $this->callParseAuthorString($command, + $author = $this->callParseAuthorString( + $command, 'Johnathon (Johnny) Smith ' ); $this->assertEquals('Johnathon (Johnny) Smith', $author['name']); diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index 22445b4df459..18c2a68d8795 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -1271,7 +1271,7 @@ public function testValidPlatformPackages(string $packageName, bool $expectation class ResourceBundleStub { - const STUB_VERSION = '32.0.1'; + public const STUB_VERSION = '32.0.1'; /** * @param string $locale diff --git a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php index f1787e71c271..fda883a43825 100644 --- a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php @@ -57,9 +57,9 @@ class PerforceDriverTest extends TestCase */ protected $perforce; - const TEST_URL = 'TEST_PERFORCE_URL'; - const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; - const TEST_BRANCH = 'TEST_BRANCH_CONFIG'; + private const TEST_URL = 'TEST_PERFORCE_URL'; + private const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; + private const TEST_BRANCH = 'TEST_BRANCH_CONFIG'; protected function setUp(): void { diff --git a/tests/Composer/Test/Util/PerforceTest.php b/tests/Composer/Test/Util/PerforceTest.php index b42f484b36f5..7b524337f187 100644 --- a/tests/Composer/Test/Util/PerforceTest.php +++ b/tests/Composer/Test/Util/PerforceTest.php @@ -32,12 +32,12 @@ class PerforceTest extends TestCase /** @var \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\IOInterface */ protected $io; - const TEST_DEPOT = 'depot'; - const TEST_BRANCH = 'branch'; - const TEST_P4USER = 'user'; - const TEST_CLIENT_NAME = 'TEST'; - const TEST_PORT = 'port'; - const TEST_PATH = 'path'; + private const TEST_DEPOT = 'depot'; + private const TEST_BRANCH = 'branch'; + private const TEST_P4USER = 'user'; + private const TEST_CLIENT_NAME = 'TEST'; + private const TEST_PORT = 'port'; + private const TEST_PATH = 'path'; protected function setUp(): void {