Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch "validate --no-check-lock" #10723

Merged
merged 1 commit into from Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions phpstan/baseline.neon
Expand Up @@ -2375,6 +2375,11 @@ parameters:
count: 2
path: ../src/Composer/Command/ValidateCommand.php

-
message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
count: 1
path: ../src/Composer/Command/ValidateCommand.php

-
message: "#^Only booleans are allowed in a negated boolean, array\\<Composer\\\\Package\\\\BasePackage\\> given\\.$#"
count: 1
Expand Down Expand Up @@ -2410,6 +2415,11 @@ parameters:
count: 1
path: ../src/Composer/Command/ValidateCommand.php

-
message: "#^Only booleans are allowed in \\|\\|, mixed given on the right side\\.$#"
count: 1
path: ../src/Composer/Command/ValidateCommand.php

-
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{Composer\\\\Package\\\\RootPackageInterface, 'getDevRequires'\\|'getRequires'\\} given\\.$#"
count: 1
Expand Down
3 changes: 3 additions & 0 deletions src/Composer/Command/ValidateCommand.php
Expand Up @@ -45,6 +45,7 @@ protected function configure()
->setDescription('Validates a composer.json and composer.lock.')
->setDefinition(array(
new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even config.lock is false, overrides --no-check-lock)'),
Copy link
Member

@Seldaek Seldaek Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this simpler, or leave the flag out altogether as I don't really see the point if you disabled the lock file..

Suggested change
new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even config.lock is false, overrides --no-check-lock)'),
new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even when config.lock is false)'),

new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
Expand Down Expand Up @@ -95,6 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

$lockErrors = array();
$composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
// config.lock = false ~= implicit --no-check-lock; --check-lock overrides
$checkLock = ($checkLock && $composer->getConfig()->get('lock')) || $input->getOption('check-lock');
$locker = $composer->getLocker();
if ($locker->isLocked() && !$locker->isFresh()) {
$lockErrors[] = '- The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.';
Expand Down