@@ -65,6 +65,7 @@ class Update extends BaseCommand
6565 * @param boolean $ignorePlatformReqs Ignore platform reqs when running the update.
6666 * @param string $installPreference Set an install preference - must be one of "none", "dist", "source"
6767 * @param boolean $ignoreScripts Ignores scripts that run after Composer events.
68+ * @param ?string $package Specify a specific package to update.
6869 * @return void
6970 */
7071 final public function __construct (
@@ -74,18 +75,15 @@ final public function __construct(
7475 protected bool $ ignorePlatformReqs = false ,
7576 protected string $ installPreference = 'none ' ,
7677 protected bool $ ignoreScripts = false ,
77- protected bool $ dryRun = false
78+ protected bool $ dryRun = false ,
79+ protected ?string $ package = null
7880 ) {
7981 parent ::__construct ($ composer );
8082
81- $ this ->includeDev = $ includeDev ;
82- $ this ->lockFileOnly = $ lockFileOnly ;
83- $ this ->ignorePlatformReqs = $ ignorePlatformReqs ;
84- $ this ->ignoreScripts = $ ignoreScripts ;
85- $ this ->dryRun = $ dryRun ;
86-
87- if (in_array ($ installPreference , [self ::PREFER_NONE , self ::PREFER_DIST , self ::PREFER_SOURCE ])) {
88- $ this ->installPreference = $ installPreference ;
83+ if (!in_array ($ this ->installPreference , [self ::PREFER_NONE , self ::PREFER_DIST , self ::PREFER_SOURCE ])) {
84+ throw new \InvalidArgumentException (
85+ 'installPreference is not an allowed value ` ' . $ this ->installPreference . '`. See: "none", "dist", "source" '
86+ );
8987 }
9088 }
9189
@@ -337,6 +335,10 @@ protected function arguments(): array
337335 $ arguments ['--prefer- ' . $ this ->installPreference ] = true ;
338336 }
339337
338+ if ($ this ->package ) {
339+ $ arguments ['packages ' ] = [$ this ->package ];
340+ }
341+
340342 return $ arguments ;
341343 }
342344}
0 commit comments