-
-
Notifications
You must be signed in to change notification settings - Fork 449
Expand file tree
/
Copy pathSetProviderCollector.php
More file actions
65 lines (56 loc) · 1.63 KB
/
Copy pathSetProviderCollector.php
File metadata and controls
65 lines (56 loc) · 1.63 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
namespace Rector\Bridge;
use Rector\Set\Contract\SetInterface;
use Rector\Set\Contract\SetProviderInterface;
use Rector\Set\ValueObject\ComposerTriggeredSet;
/**
* @api
*
* Utils class to ease building bridges by 3rd-party tools
*
* @deprecated Bond the rules themselves instead, by implementing the ComposerPackageConstraintInterface. A set
* described as an object only existed to be matched against the installed packages; a bonded rule states the exact
* package version its target API is available from and applies from there upwards, so a plain set file is enough.
*
* @see \Rector\VersionBonding\Contract\ComposerPackageConstraintInterface
* @see https://github.com/rectorphp/rector-src/pull/8296
*/
final readonly class SetProviderCollector
{
/**
* @param SetProviderInterface[] $setProviders
*/
public function __construct(
private array $setProviders = []
) {
}
/**
* @return array<SetProviderInterface>
*/
public function provide(): array
{
return $this->setProviders;
}
/**
* @return array<SetInterface>
*/
public function provideSets(): array
{
$sets = [];
foreach ($this->setProviders as $setProvider) {
$sets = array_merge($sets, $setProvider->provide());
}
return $sets;
}
/**
* @return array<ComposerTriggeredSet>
*/
public function provideComposerTriggeredSets(): array
{
return array_filter(
$this->provideSets(),
fn (SetInterface $set): bool => $set instanceof ComposerTriggeredSet
);
}
}