This repository has been archived by the owner on Jul 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConfiguration.php
629 lines (580 loc) · 17.5 KB
/
Configuration.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<?php
namespace Eloquent\Composer\Configuration\Element;
use DateTime;
/**
* Represents an entire Composer configuration.
*/
class Configuration
{
/**
* The separator used to divide the package name into vendor name and
* project name.
*/
const NAME_SEPARATOR = '/';
/**
* Construct a new configuration.
*
* @param string|null $name The package name.
* @param string|null $description The package description.
* @param string|null $version The package version.
* @param string|null $type The package type.
* @param array<integer,string>|null $keywords The keywords the package is related to.
* @param string|null $homepage The URI of the package's home page.
* @param DateTime|null $time The release date of this version.
* @param array<integer,string>|null $license The licences the package is released under.
* @param array<integer,Author>|null $authors The authors of the package.
* @param SupportInformation|null $support Support information for the package.
* @param array<string,string>|null $dependencies The package's dependencies.
* @param array<string,string>|null $devDependencies The package's development dependencies.
* @param array<string,string>|null $conflict Packages that conflict with this version of the package.
* @param array<string,string>|null $replace Packages that are replaced by this package.
* @param array<string,string>|null $provide Packages that are provided by this package.
* @param array<string,string>|null $suggest Suggested packages for use with this package.
* @param array<string,array<integer,string>>|null $autoloadPsr4 PSR-4 autoloading configuration for the package.
* @param array<string,array<integer,string>>|null $autoloadPsr0 PSR-0 autoloading configuration for the package.
* @param array<integer,string>|null $autoloadClassmap Class map autoloading configuration for the package.
* @param array<integer,string>|null $autoloadFiles File autoloading configuration for the package.
* @param array<integer,string>|null $includePath Include path autoloading configuration for the package.
* @param string|null $targetDir The target directory for installation.
* @param Stability|null $minimumStability The minimum stability for packages.
* @param bool|null $preferStable True if stable packages should take precedence.
* @param array<integer,RepositoryInterface> $repositories The custom repositories used by this package.
* @param ProjectConfiguration|null $config The configuration options for the package that are specific to project-type repositories.
* @param ScriptConfiguration|null $scripts The hook scripts for the package.
* @param mixed $extra Arbitrary extra data contained in the project's configuration.
* @param array<integer,string>|null $bin Binary executable files provided by the package.
* @param ArchiveConfiguration|null $archive The archive configuration for the package.
* @param mixed $rawData The raw data describing the configuration.
*/
public function __construct(
$name = null,
$description = null,
$version = null,
$type = null,
array $keywords = null,
$homepage = null,
DateTime $time = null,
array $license = null,
array $authors = null,
SupportInformation $support = null,
array $dependencies = null,
array $devDependencies = null,
array $conflict = null,
array $replace = null,
array $provide = null,
array $suggest = null,
array $autoloadPsr4 = null,
array $autoloadPsr0 = null,
array $autoloadClassmap = null,
array $autoloadFiles = null,
array $includePath = null,
$targetDir = null,
Stability $minimumStability = null,
$preferStable = null,
array $repositories = null,
ProjectConfiguration $config = null,
ScriptConfiguration $scripts = null,
$extra = null,
array $bin = null,
ArchiveConfiguration $archive = null,
$rawData = null
) {
if (null === $type) {
$type = 'library';
}
if (null === $keywords) {
$keywords = [];
}
if (null === $license) {
$license = [];
}
if (null === $authors) {
$authors = [];
}
if (null === $support) {
$support = new SupportInformation();
}
if (null === $dependencies) {
$dependencies = [];
}
if (null === $devDependencies) {
$devDependencies = [];
}
if (null === $conflict) {
$conflict = [];
}
if (null === $replace) {
$replace = [];
}
if (null === $provide) {
$provide = [];
}
if (null === $suggest) {
$suggest = [];
}
if (null === $autoloadPsr4) {
$autoloadPsr4 = [];
}
if (null === $autoloadPsr0) {
$autoloadPsr0 = [];
}
if (null === $autoloadClassmap) {
$autoloadClassmap = [];
}
if (null === $autoloadFiles) {
$autoloadFiles = [];
}
if (null === $includePath) {
$includePath = [];
}
if (null === $minimumStability) {
$minimumStability = Stability::STABLE();
}
if (null === $preferStable) {
$preferStable = false;
}
if (null === $repositories) {
$repositories = [];
}
if (null === $config) {
$config = new ProjectConfiguration();
}
if (null === $scripts) {
$scripts = new ScriptConfiguration();
}
if (null === $archive) {
$archive = new ArchiveConfiguration();
}
if (null === $bin) {
$bin = [];
}
$this->name = $name;
$this->description = $description;
$this->version = $version;
$this->type = $type;
$this->keywords = $keywords;
$this->homepage = $homepage;
$this->time = $time;
$this->license = $license;
$this->authors = $authors;
$this->support = $support;
$this->dependencies = $dependencies;
$this->devDependencies = $devDependencies;
$this->conflict = $conflict;
$this->replace = $replace;
$this->provide = $provide;
$this->suggest = $suggest;
$this->autoloadPsr4 = $autoloadPsr4;
$this->autoloadPsr0 = $autoloadPsr0;
$this->autoloadClassmap = $autoloadClassmap;
$this->autoloadFiles = $autoloadFiles;
$this->includePath = $includePath;
$this->targetDir = $targetDir;
$this->minimumStability = $minimumStability;
$this->preferStable = $preferStable;
$this->repositories = $repositories;
$this->config = $config;
$this->scripts = $scripts;
$this->extra = $extra;
$this->bin = $bin;
$this->archive = $archive;
$this->rawData = $rawData;
}
/**
* Get the package name, including vendor and project names.
*
* @return string|null The name.
*/
public function name()
{
return $this->name;
}
/**
* Get the project name, without the vendor prefix.
*
* @return string|null The project name.
*/
public function projectName()
{
$name = $this->name();
if (null === $name) {
return null;
}
$atoms = explode(static::NAME_SEPARATOR, $name);
return array_pop($atoms);
}
/**
* Get the vendor name, without the project suffix.
*
* @return string|null The vendor name.
*/
public function vendorName()
{
$name = $this->name();
if (null === $name) {
return null;
}
$atoms = explode(static::NAME_SEPARATOR, $name);
array_pop($atoms);
if (count($atoms) < 1) {
return null;
}
return implode(static::NAME_SEPARATOR, $atoms);
}
/**
* Get the package description.
*
* @return string|null The description.
*/
public function description()
{
return $this->description;
}
/**
* Get the package version.
*
* @return string|null The version.
*/
public function version()
{
return $this->version;
}
/**
* Get the package type.
*
* @return string The type.
*/
public function type()
{
return $this->type;
}
/**
* Get the package keywords.
*
* @return array<integer,string> The keywords.
*/
public function keywords()
{
return $this->keywords;
}
/**
* Get the URI of the package's home page.
*
* @return string|null The home page.
*/
public function homepage()
{
return $this->homepage;
}
/**
* Get the release date of this version.
*
* @return DateTime|null The release date.
*/
public function time()
{
return $this->time;
}
/**
* Get the licences the package is released under.
*
* @return array<integer,string>|null The licences.
*/
public function license()
{
return $this->license;
}
/**
* Get the authors of the package.
*
* @return array<integer,Author> The authors.
*/
public function authors()
{
return $this->authors;
}
/**
* Get support information for the package.
*
* @return SupportInformation The support information.
*/
public function support()
{
return $this->support;
}
/**
* Get the package's dependencies, excluding development dependencies.
*
* @return array<string,string> The dependencies.
*/
public function dependencies()
{
return $this->dependencies;
}
/**
* Get the package's development dependencies.
*
* @return array<string,string> The development dependencies.
*/
public function devDependencies()
{
return $this->devDependencies;
}
/**
* Get all of the package's dependencies, including development, and
* non-development dependencies.
*
* @return array<string,string> All dependencies.
*/
public function allDependencies()
{
return array_merge(
$this->dependencies(),
$this->devDependencies()
);
}
/**
* Get the packages that conflict with this version of the package.
*
* @return array<string,string> The conflicting packages.
*/
public function conflict()
{
return $this->conflict;
}
/**
* Get the packages that are replaced by this package.
*
* @return array<string,string> The replaced packages.
*/
public function replace()
{
return $this->replace;
}
/**
* Get the packages that are provided by this package.
*
* @return array<string,string> The provided packages.
*/
public function provide()
{
return $this->provide;
}
/**
* Get suggested packages for use with this package.
*
* @return array<string,string> The suggested packages.
*/
public function suggest()
{
return $this->suggest;
}
/**
* Get the PSR-4 autoloading configuration for the package.
*
* @return array<string,array<integer,string>> The PSR-4 autoloading configuration.
*/
public function autoloadPsr4()
{
return $this->autoloadPsr4;
}
/**
* Get the PSR-0 autoloading configuration for the package.
*
* @return array<string,array<integer,string>> The PSR-0 autoloading configuration.
*/
public function autoloadPsr0()
{
return $this->autoloadPsr0;
}
/**
* Get the class map autoloading configuration for the package.
*
* @return array<integer,string> The class map autoloading configuration.
*/
public function autoloadClassmap()
{
return $this->autoloadClassmap;
}
/**
* Get the file autoloading configuration for the package.
*
* @return array<integer,string> The file autoloading configuration for the package.
*/
public function autoloadFiles()
{
return $this->autoloadFiles;
}
/**
* Get the include path autoloading configuration for the package.
*
* @return array<integer,string> The include path autoloading configuration for the package.
*/
public function includePath()
{
return $this->includePath;
}
/**
* Get an array of all source paths containing PSR-4 conformant code.
*
* @return array<integer,string> The PSR-4 source paths.
*/
public function allPsr4SourcePaths()
{
$autoloadPsr4Paths = [];
foreach ($this->autoloadPsr4() as $namespace => $paths) {
$autoloadPsr4Paths = array_merge($autoloadPsr4Paths, $paths);
}
return $autoloadPsr4Paths;
}
/**
* Get an array of all source paths containing PSR-0 conformant code.
*
* @return array<integer,string> The PSR-0 source paths.
*/
public function allPsr0SourcePaths()
{
$autoloadPsr0Paths = [];
foreach ($this->autoloadPsr0() as $namespace => $paths) {
$autoloadPsr0Paths = array_merge($autoloadPsr0Paths, $paths);
}
return $autoloadPsr0Paths;
}
/**
* Get an array of all source paths for this package.
*
* @return array<integer,string> All source paths.
*/
public function allSourcePaths()
{
return array_merge(
$this->allPsr4SourcePaths(),
$this->allPsr0SourcePaths(),
$this->autoloadClassmap(),
$this->autoloadFiles(),
$this->includePath()
);
}
/**
* Get the target directory for installation.
*
* @return string|null The target directory.
*/
public function targetDir()
{
return $this->targetDir;
}
/**
* Get the minimum stability for packages.
*
* @return Stability The minimum stability.
*/
public function minimumStability()
{
return $this->minimumStability;
}
/**
* Returns true if stable packages should take precedence.
*
* @return bool True if stable packages should take precedence.
*/
public function preferStable()
{
return $this->preferStable;
}
/**
* Get the custom repositories used by this package.
*
* @return array<integer,RepositoryInterface> The custom repositories.
*/
public function repositories()
{
return $this->repositories;
}
/**
* Get the configuration options for the package that are specific to
* project-type repositories.
*
* @return ProjectConfiguration The project configuration.
*/
public function config()
{
return $this->config;
}
/**
* Get the hook scripts for the package.
*
* @return ScriptConfiguration The hook scripts.
*/
public function scripts()
{
return $this->scripts;
}
/**
* Get the arbitrary extra data contained in the project's configuration.
*
* @return mixed The extra data.
*/
public function extra()
{
return $this->extra;
}
/**
* Get the binary executable files provided by the package.
*
* @return array<integer,string> The executable files.
*/
public function bin()
{
return $this->bin;
}
/**
* Get the archive configuration for the package.
*
* @return ArchiveConfiguration The archive configuration.
*/
public function archive()
{
return $this->archive;
}
/**
* Get the raw configuration data.
*
* @return mixed The raw configuration data.
*/
public function rawData()
{
return $this->rawData;
}
private $name;
private $description;
private $version;
private $type;
private $keywords;
private $homepage;
private $time;
private $license;
private $authors;
private $support;
private $dependencies;
private $devDependencies;
private $conflict;
private $replace;
private $provide;
private $suggest;
private $autoloadPsr4;
private $autoloadPsr0;
private $autoloadClassmap;
private $autoloadFiles;
private $includePath;
private $targetDir;
private $minimumStability;
private $preferStable;
private $repositories;
private $config;
private $scripts;
private $extra;
private $bin;
private $archive;
private $rawData;
}