forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14274.php
More file actions
49 lines (40 loc) · 1.53 KB
/
Copy pathbug-14274.php
File metadata and controls
49 lines (40 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php // lint >= 8.0
declare(strict_types=1);
namespace Bug14274;
class PreApplyEvent {}
final class ComposerPatchesValidator {
/**
* Validates the status of the patcher plugin.
*/
public function validate(mixed $event): void {
$messages = [];
[$plugin_installed_in_active, $is_active_root_requirement, $active_configuration_ok] = $this->computePatcherStatus();
if ($event instanceof PreApplyEvent) {
[$plugin_installed_in_stage, $is_stage_root_requirement, $stage_configuration_ok] = $this->computePatcherStatus();
$has_staged_update = TRUE;
}
else {
// No staged update exists.
$has_staged_update = FALSE;
}
if ($has_staged_update && $plugin_installed_in_active !== $plugin_installed_in_stage) {
$messages[] = 'package-manager-faq-composer-patches-installed-or-removed';
}
// If the patcher is not listed in the runtime or dev dependencies, that's
// an error as well.
if (($plugin_installed_in_active && !$is_active_root_requirement) || ($has_staged_update && $plugin_installed_in_stage && !$is_stage_root_requirement)) {
$messages[] = 'It must be a root dependency.';
}
// If the plugin is misconfigured in either the active or stage directories,
// flag an error.
if (($plugin_installed_in_active && !$active_configuration_ok) || ($has_staged_update && $plugin_installed_in_stage && !$stage_configuration_ok)) {
$messages[] = 'The composer-exit-on-patch-failure key is not set to true.';
}
}
/**
* @return bool[]
*/
private function computePatcherStatus(): array {
return [];
}
}