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

feat(analyze): add an option to allow generating empty baseline #776

Merged
merged 2 commits into from
Nov 20, 2021
Merged

feat(analyze): add an option to allow generating empty baseline #776

merged 2 commits into from
Nov 20, 2021

Conversation

Lctrs
Copy link
Contributor

@Lctrs Lctrs commented Nov 18, 2021

No description provided.

@staabm
Copy link
Contributor

staabm commented Nov 18, 2021

Whats the motivation of this PR?

In case you are interessted in a 0 exit code, you can use
phpstan ... --generate-baseline || true

@Lctrs
Copy link
Contributor Author

Lctrs commented Nov 18, 2021

This will not generate an empty baseline file. And by empty, I mean with this content :

parameters:
	ignoreErrors: []

@Lctrs
Copy link
Contributor Author

Lctrs commented Nov 18, 2021

See #751 (comment)

@@ -55,6 +55,7 @@ protected function configure(): void
new InputOption('autoload-file', 'a', InputOption::VALUE_REQUIRED, 'Project\'s additional autoload file path'),
new InputOption('error-format', null, InputOption::VALUE_REQUIRED, 'Format in which to print the result of the analysis', null),
new InputOption('generate-baseline', null, InputOption::VALUE_OPTIONAL, 'Path to a file where the baseline should be saved', false),
new InputOption('allow-empty-baseline', null, InputOption::VALUE_NONE, 'Do not error out when the generated baseline is empty'),
Copy link
Member

Choose a reason for hiding this comment

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

This is missing a default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can't set a default on an input option which has no value.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right, haven't realized that 👍

@@ -102,6 +103,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$generateBaselineFile = 'phpstan-baseline.neon';
}

$allowEmptyBaseline = (bool) $input->getOption('allow-empty-baseline');
Copy link
Member

Choose a reason for hiding this comment

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

This set to true should result in an error if $generateBaselineFile is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I'm not very satisfied with the error message, if you have a better idea...

@ondrejmirtes ondrejmirtes merged commit 5615d5b into phpstan:master Nov 20, 2021
@ondrejmirtes
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants