Skip to content

Commit aa16f71

Browse files
authored
BC: make CycloneDX\Core\Spec\Spec internal (#345)
* BC: make `CycloneDX\Core\Spec\Spec` internal Signed-off-by: Jan Kowalleck <[email protected]> * docs Signed-off-by: Jan Kowalleck <[email protected]> * docs Signed-off-by: Jan Kowalleck <[email protected]> * history Signed-off-by: Jan Kowalleck <[email protected]> * history Signed-off-by: Jan Kowalleck <[email protected]> --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 3deade3 commit aa16f71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+227
-214
lines changed

HISTORY.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,32 @@ All notable changes to this project will be documented in this file.
44

55
## unreleased
66

7+
* BREAKING
8+
* Interface `\CycloneDX\Core\Spec\Spec` was removed from public API ([#344] via [#345])
9+
This is only a breaking change if you custom-implemented this interface downstream; internal usage is non-breaking.
10+
This change was necessary, so that implementing more spec-features cause no breaking changes.
711
* Style
812
* Applied latest PHP Coding Standards (via [#341])
913

1014
[#341]: https://github.com/CycloneDX/cyclonedx-php-library/pull/341
15+
[#344]: https://github.com/CycloneDX/cyclonedx-php-library/issues/344
16+
[#345]: https://github.com/CycloneDX/cyclonedx-php-library/pull/345
1117

1218
## 2.3.0 - 2023-06-27
1319

1420
Added support for [_CycloneDX_ Specification-1.5](https://github.com/CycloneDX/specification/releases/tag/1.5).
1521

1622
* Changed
17-
* Method `Core\Spec\SpecFactory::makeForVersion()` supports _CycloneDX_ Specification-1.5 now ([#193] via [#255])
18-
* Classes `Core\Serialization\{DOM,JSON}\Normalizers\*` support _CycloneDX_ Specification-1.5 now ([#193] via [#255])
19-
* Classes `Core\Validation\Validators\*` support _CycloneDX_ Specification-1.5 now ([#193] via [#255])
23+
* Method `\CycloneDX\Core\Spec\SpecFactory::makeForVersion()` supports _CycloneDX_ Specification-1.5 now ([#193] via [#255])
24+
* Classes `\CycloneDX\Core\Serialization\{DOM,JSON}\Normalizers\*` support _CycloneDX_ Specification-1.5 now ([#193] via [#255])
25+
* Classes `\CycloneDX\Core\Validation\Validators\*` support _CycloneDX_ Specification-1.5 now ([#193] via [#255])
2026
* Added
21-
* Namespace `Core\Enums`
27+
* Namespace `\CycloneDX\Core\Enums`
2228
* Enum `ComponentType` got new cases ([#193] via [#255])
2329
New: `Data`, `DeviceDriver`, `MachineLearningModel`, `Platform`
2430
* Enum `ExternalReferenceType` got new cases ([#193] via [#255])
2531
New: `AdversaryModel`, `Attestation`, `CertificationReport`, `CodifiedInfrastructure`, `ComponentAnalysisReport`, `Configuration`, `DistributionIntake`, `DynamicAnalysisReport`, `Evidence`, `ExploitabilityStatement`, `Formulation`, `Log`, `MaturityReport`, `ModelCard`, `POAM`, `PentestReport`, `QualityMetrics`, `RiskAssessment`, `RuntimeAnalysisReport`, `SecurityContact`, `StaticAnalysisReport`, `ThreatModel`, `VulnerabilityAssertion`
26-
* Namespace `Core\Spec`
32+
* Namespace `\CycloneDX\Core\Spec`
2733
* New method `SpecFactory::make1dot5()` to reflect _CycloneDX_ Specification-1.5 ([#193] via [#255])
2834
* Enum `Version` got new case `v1dot5` to reflect _CycloneDX_ Specification-1.5 ([#193] via [#255])
2935
* Misc

src/Core/Serialization/DOM/NormalizerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace CycloneDX\Core\Serialization\DOM;
2525

26+
use CycloneDX\Core\Spec\_SpecProtocol as Spec;
2627
use CycloneDX\Core\Spec\Format;
27-
use CycloneDX\Core\Spec\Spec;
2828
use DomainException;
2929
use DOMDocument;
3030

src/Core/Serialization/JSON/NormalizerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace CycloneDX\Core\Serialization\JSON;
2525

26+
use CycloneDX\Core\Spec\_SpecProtocol as Spec;
2627
use CycloneDX\Core\Spec\Format;
27-
use CycloneDX\Core\Spec\Spec;
2828
use DomainException;
2929

3030
/**

src/Core/Spec/SpecFactory.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use DomainException;
3030

3131
/**
32-
* Factory for {@see \CycloneDX\Core\Spec\Spec Specification} objects.
32+
* Factory for {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} objects.
3333
*/
3434
abstract class SpecFactory
3535
{
@@ -47,11 +47,11 @@ abstract class SpecFactory
4747
*/
4848

4949
/**
50-
* Create the appropriate {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version}.
50+
* Create the appropriate {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version}.
5151
*
5252
* @throws DomainException when $version was unsupported
5353
*/
54-
public static function makeForVersion(Version $version): Spec
54+
public static function makeForVersion(Version $version): _SpecProtocol
5555
{
5656
return match ($version) {
5757
Version::v1dot1 => self::make1dot1(),
@@ -65,9 +65,9 @@ public static function makeForVersion(Version $version): Spec
6565
}
6666

6767
/**
68-
* Create the {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot1}.
68+
* Create the {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot1}.
6969
*/
70-
public static function make1dot1(): Spec
70+
public static function make1dot1(): _SpecProtocol
7171
{
7272
return new _Spec(
7373
Version::v1dot1,
@@ -125,9 +125,9 @@ public static function make1dot1(): Spec
125125
}
126126

127127
/**
128-
* Create the {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot2}.
128+
* Create the {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot2}.
129129
*/
130-
public static function make1dot2(): Spec
130+
public static function make1dot2(): _SpecProtocol
131131
{
132132
return new _Spec(
133133
Version::v1dot2,
@@ -193,9 +193,9 @@ public static function make1dot2(): Spec
193193
}
194194

195195
/**
196-
* Create the {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot3}.
196+
* Create the {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot3}.
197197
*/
198-
public static function make1dot3(): Spec
198+
public static function make1dot3(): _SpecProtocol
199199
{
200200
return new _Spec(
201201
Version::v1dot3,
@@ -264,9 +264,9 @@ public static function make1dot3(): Spec
264264
}
265265

266266
/**
267-
* Create the {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot4}.
267+
* Create the {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot4}.
268268
*/
269-
public static function make1dot4(): Spec
269+
public static function make1dot4(): _SpecProtocol
270270
{
271271
return new _Spec(
272272
Version::v1dot4,
@@ -336,9 +336,9 @@ public static function make1dot4(): Spec
336336
}
337337

338338
/**
339-
* Create the {@see \CycloneDX\Core\Spec\Spec Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot5}.
339+
* Create the {@see \CycloneDX\Core\Spec\_SpecProtocol Specification} based on {@see \CycloneDX\Core\Spec\Version::v1dot5}.
340340
*/
341-
public static function make1dot5(): Spec
341+
public static function make1dot5(): _SpecProtocol
342342
{
343343
return new _Spec(
344344
Version::v1dot5,

src/Core/Spec/_Spec.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
use CycloneDX\Core\Spdx\LicenseIdentifiers;
3030

3131
/**
32-
* This class is not for public use.
33-
* See {@see \CycloneDX\Core\Spec\SpecFactory Specification Factory} to get prepared instances.
32+
* This class is not intended to be public API.
33+
*
34+
* This is a helper to get the exact spec-versions implemented according to {@see \CycloneDX\Core\Spec\_SpecProtocol Specification}.
3435
*
3536
* @internal as this class may be affected by breaking changes without notice
3637
*
@@ -40,7 +41,7 @@
4041
*
4142
* @author jkowalleck
4243
*/
43-
class _Spec implements Spec
44+
class _Spec implements _SpecProtocol
4445
{
4546
/** @psalm-var list<string> */
4647
private array $lLicenseIdentifiers;

src/Core/Spec/Spec.php renamed to src/Core/Spec/_SpecProtocol.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@
2828
use CycloneDX\Core\Enums\HashAlgorithm;
2929

3030
/**
31+
* This interface is not intended to be public API.
32+
*
3133
* See {@see \CycloneDX\Core\Spec\SpecFactory Specification Factory} to get prepared instances.
3234
*
35+
* @internal as this interface may be affected by breaking changes without notice
36+
*
37+
* @SuppressWarnings(PHPMD.CamelCaseClassName)
38+
*
3339
* @author jkowalleck
3440
*/
35-
interface Spec
41+
interface _SpecProtocol
3642
{
3743
public function getVersion(): Version;
3844

src/Core/Validation/BaseValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace CycloneDX\Core\Validation;
2525

26-
use CycloneDX\Core\Spec\Spec;
26+
use CycloneDX\Core\Spec\_SpecProtocol as Spec;
2727

2828
/**
2929
* @author jkowalleck

tests/Core/Serialization/DOM/NormalizerFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use CycloneDX\Core\Serialization\DOM\_BaseNormalizer;
2727
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
2828
use CycloneDX\Core\Serialization\DOM\Normalizers;
29-
use CycloneDX\Core\Spec\Spec;
29+
use CycloneDX\Core\Spec\_SpecProtocol;
3030
use CycloneDX\Core\Spec\Version;
3131
use DomainException;
3232
use DOMDocument;
@@ -57,7 +57,7 @@ class NormalizerFactoryTest extends TestCase
5757
public function testConstructor(): NormalizerFactory
5858
{
5959
$spec = $this->createConfiguredMock(
60-
Spec::class,
60+
_SpecProtocol::class,
6161
[
6262
'isSupportedFormat' => true,
6363
]
@@ -73,7 +73,7 @@ public function testConstructor(): NormalizerFactory
7373
public function testConstructThrowsWhenUnsupported(): void
7474
{
7575
$spec = $this->createConfiguredMock(
76-
Spec::class,
76+
_SpecProtocol::class,
7777
[
7878
'getVersion' => Version::v1dot4,
7979
'isSupportedFormat' => false,

tests/Core/Serialization/DOM/Normalizers/BomNormalizerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
use CycloneDX\Core\Serialization\DOM\_BaseNormalizer;
3535
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
3636
use CycloneDX\Core\Serialization\DOM\Normalizers;
37-
use CycloneDX\Core\Spec\Spec;
37+
use CycloneDX\Core\Spec\_SpecProtocol;
3838
use CycloneDX\Core\Spec\Version;
3939
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
4040
use DOMDocument;
@@ -53,7 +53,7 @@ class BomNormalizerTest extends TestCase
5353

5454
public function testNormalize(): void
5555
{
56-
$spec = $this->createConfiguredMock(Spec::class, ['getVersion' => Version::v1dot2]);
56+
$spec = $this->createConfiguredMock(_SpecProtocol::class, ['getVersion' => Version::v1dot2]);
5757
$factory = $this->createConfiguredMock(
5858
NormalizerFactory::class,
5959
[
@@ -82,7 +82,7 @@ public function testNormalize(): void
8282

8383
public function testNormalizeComponents(): void
8484
{
85-
$spec = $this->createConfiguredMock(Spec::class, ['getVersion' => Version::v1dot2]);
85+
$spec = $this->createConfiguredMock(_SpecProtocol::class, ['getVersion' => Version::v1dot2]);
8686
$componentsNormalizer = $this->createMock(Normalizers\ComponentRepositoryNormalizer::class);
8787
$factory = $this->createConfiguredMock(
8888
NormalizerFactory::class,
@@ -121,7 +121,7 @@ public function testNormalizeComponents(): void
121121
public function testNormalizeMetadata(): void
122122
{
123123
$spec = $this->createConfiguredMock(
124-
Spec::class,
124+
_SpecProtocol::class,
125125
[
126126
'getVersion' => Version::v1dot2,
127127
'supportsMetadata' => true,
@@ -164,7 +164,7 @@ public function testNormalizeMetadata(): void
164164
public function testNormalizeMetadataNotSupported(): void
165165
{
166166
$spec = $this->createConfiguredMock(
167-
Spec::class,
167+
_SpecProtocol::class,
168168
[
169169
'getVersion' => Version::v1dot2,
170170
'supportsMetadata' => false,
@@ -209,7 +209,7 @@ public function testNormalizeMetadataNotSupported(): void
209209
public function testNormalizeDependencies(): void
210210
{
211211
$spec = $this->createConfiguredMock(
212-
Spec::class,
212+
_SpecProtocol::class,
213213
[
214214
'getVersion' => Version::v1dot2,
215215
'supportsDependencies' => true,
@@ -252,7 +252,7 @@ public function testNormalizeDependencies(): void
252252
public function testNormalizeDependenciesOmitWhenEmpty(): void
253253
{
254254
$spec = $this->createConfiguredMock(
255-
Spec::class,
255+
_SpecProtocol::class,
256256
[
257257
'getVersion' => Version::v1dot2,
258258
'supportsDependencies' => true,
@@ -298,7 +298,7 @@ public function testNormalizeDependenciesOmitWhenEmpty(): void
298298

299299
public function testNormalizeExternalReferencesMergedIfUnsupportedMetadata(): void
300300
{
301-
$spec = $this->createConfiguredMock(Spec::class, [
301+
$spec = $this->createConfiguredMock(_SpecProtocol::class, [
302302
'getVersion' => Version::v1dot2,
303303
'supportsMetadata' => false,
304304
]);
@@ -351,7 +351,7 @@ public function testNormalizeExternalReferencesMergedIfUnsupportedMetadata(): vo
351351

352352
public function testNormalizeExternalReferencesOmittedWHenEmpty(): void
353353
{
354-
$spec = $this->createConfiguredMock(Spec::class, [
354+
$spec = $this->createConfiguredMock(_SpecProtocol::class, [
355355
'getVersion' => Version::v1dot2,
356356
'supportsMetadata' => false,
357357
]);
@@ -400,7 +400,7 @@ public function testNormalizeProperties(): void
400400
'getProperties' => $this->createConfiguredMock(PropertyRepository::class, ['count' => 2]),
401401
]
402402
);
403-
$spec = $this->createConfiguredMock(Spec::class, [
403+
$spec = $this->createConfiguredMock(_SpecProtocol::class, [
404404
'getVersion' => Version::v1dot4,
405405
'supportsBomProperties' => true,
406406
]);
@@ -439,7 +439,7 @@ public function testNormalizePropertiesOmitEmpty(): void
439439
'getProperties' => $this->createConfiguredMock(PropertyRepository::class, ['count' => 0]),
440440
]
441441
);
442-
$spec = $this->createConfiguredMock(Spec::class, [
442+
$spec = $this->createConfiguredMock(_SpecProtocol::class, [
443443
'getVersion' => Version::v1dot4,
444444
'supportsBomProperties' => true,
445445
]);

tests/Core/Serialization/DOM/Normalizers/ComponentEvidenceNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use CycloneDX\Core\Serialization\DOM\_BaseNormalizer;
3232
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
3333
use CycloneDX\Core\Serialization\DOM\Normalizers;
34-
use CycloneDX\Core\Spec\Spec;
34+
use CycloneDX\Core\Spec\_SpecProtocol;
3535
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
3636
use DOMDocument;
3737
use PHPUnit\Framework\Attributes\CoversClass;
@@ -54,7 +54,7 @@ public function testNormalizeMinimal(): void
5454
'getCopyright' => $this->createMock(CopyrightRepository::class),
5555
]
5656
);
57-
$spec = $this->createMock(Spec::class);
57+
$spec = $this->createMock(_SpecProtocol::class);
5858
$factory = $this->createConfiguredMock(
5959
NormalizerFactory::class,
6060
['getSpec' => $spec, 'getDocument' => new DOMDocument()]
@@ -75,7 +75,7 @@ public function testNormalizeFull(): void
7575
'getCopyright' => $this->createConfiguredMock(CopyrightRepository::class, ['count' => 1, 'getItems' => ['some copyright']]),
7676
]
7777
);
78-
$spec = $this->createMock(Spec::class);
78+
$spec = $this->createMock(_SpecProtocol::class);
7979
$licenseRepoNormalizer = $this->createMock(Normalizers\LicenseRepositoryNormalizer::class);
8080
$factory = $this->createConfiguredMock(
8181
NormalizerFactory::class,

0 commit comments

Comments
 (0)