14
14
final class TreeSource extends BaseSource implements FilterableSourceInterface
15
15
{
16
16
/**
17
- * @param string|array<string> $sourcePath Path(s) to generate tree from
17
+ * @param string|array<string> $sourcePaths Path(s) to generate tree from
18
18
* @param string $description Human-readable description
19
19
* @param string|array<string> $filePattern Pattern(s) to match files
20
20
* @param array<string> $notPath Patterns to exclude paths
@@ -26,7 +26,7 @@ final class TreeSource extends BaseSource implements FilterableSourceInterface
26
26
* @param array<non-empty-string> $tags
27
27
*/
28
28
public function __construct (
29
- public readonly string |array $ sourcePath ,
29
+ public readonly string |array $ sourcePaths ,
30
30
string $ description = '' ,
31
31
public readonly string |array $ filePattern = '* ' ,
32
32
public readonly array $ notPath = [],
@@ -46,12 +46,12 @@ public function __construct(
46
46
public static function fromArray (array $ data , string $ rootPath = '' ): self
47
47
{
48
48
if (!isset ($ data ['sourcePaths ' ])) {
49
- throw new \RuntimeException ('Tree source must have a "sourcePath " property ' );
49
+ throw new \RuntimeException ('Tree source must have a "sourcePaths " property ' );
50
50
}
51
51
52
52
$ sourcePath = $ data ['sourcePaths ' ];
53
53
if (!\is_string ($ sourcePath ) && !\is_array ($ sourcePath )) {
54
- throw new \RuntimeException ('"sourcePath " must be a string or array in source ' );
54
+ throw new \RuntimeException ('"sourcePaths " must be a string or array in source ' );
55
55
}
56
56
57
57
$ sourcePath = \is_string ($ sourcePath ) ? [$ sourcePath ] : $ sourcePath ;
@@ -106,7 +106,7 @@ public static function fromArray(array $data, string $rootPath = ''): self
106
106
}
107
107
108
108
return new self (
109
- sourcePath : $ sourcePath ,
109
+ sourcePaths : $ sourcePath ,
110
110
description: $ data ['description ' ] ?? '' ,
111
111
filePattern: $ filePattern ,
112
112
notPath: $ notPath ,
@@ -167,7 +167,7 @@ public function in(): array|null
167
167
{
168
168
$ directories = [];
169
169
170
- foreach ((array ) $ this ->sourcePath as $ path ) {
170
+ foreach ((array ) $ this ->sourcePaths as $ path ) {
171
171
if (\is_dir ($ path )) {
172
172
$ directories [] = $ path ;
173
173
}
@@ -180,7 +180,7 @@ public function files(): array|null
180
180
{
181
181
$ files = [];
182
182
183
- foreach ((array ) $ this ->sourcePath as $ path ) {
183
+ foreach ((array ) $ this ->sourcePaths as $ path ) {
184
184
if (\is_file ($ path )) {
185
185
$ files [] = $ path ;
186
186
}
@@ -199,7 +199,7 @@ public function jsonSerialize(): array
199
199
$ result = [
200
200
'type ' => 'tree ' ,
201
201
...parent ::jsonSerialize (),
202
- 'sourcePaths ' => $ this ->sourcePath ,
202
+ 'sourcePaths ' => $ this ->sourcePaths ,
203
203
'filePattern ' => $ this ->filePattern ,
204
204
'notPath ' => $ this ->notPath ,
205
205
'renderFormat ' => $ this ->renderFormat ,
0 commit comments