Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make aggregation properties non-nullable #131

Merged
merged 24 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ jobs:
- name: Run PHPUnit tests
run: >
php
-d zend.assertions=1
-d assert.exception=1
-d display_errors=On
-d error_reporting=-1
-d log_errors_max_len=0
-d zend.assertions=1 -d assert.exception=1
-d display_errors=On -d error_reporting=-1 -d log_errors_max_len=0
-d memory_limit=-1
-d xdebug.mode=coverage
-d pcov.enabled=1 -d pcov.directory=src
vendor/phpunit/phpunit/phpunit
--log-junit=${{ env.REPORTS_DIR }}/tests.${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml
--coverage-clover=${{ env.REPORTS_DIR }}/coverage.${{ matrix.os}}_php${{ matrix.php }}_${{ matrix.dependencies }}.clover.xml
Expand Down
30 changes: 9 additions & 21 deletions .phpmd/baseline.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

151 changes: 119 additions & 32 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,132 @@ All notable changes to this project will be documented in this file.

## 2.0.0 - unreleased

* BREAKING changes
* Dropped support for php v7.3 and v7.4. (via [#125])
* Interface `\CycloneDX\Core\Spec\SpecInterface` became internal, was public api. (via [#65])
This is done to prevent the need for future "breaking changed" when the schema requires additional spec implementations.
* API
* Some methods now enforce the use of concrete union types instead of protocols. (via [#125])
Affected the usages of `\CycloneDX\Core\Models\License\AbstractDisjunctiveLicense` and methods that used license-related classes.
This was possible due to php8's UnionType language feature.
* Changed
* Method `\CycloneDX\Core\Serialize\{DOM,JSON}\Normalizers\ExternalReferenceNormalizer::normalize` throw `DomainException` when `ExternalReference`'s type was not supported by the spec. (via [#65])
This is considered a non-breaking change, because the behaviour was already documented in the API, even though there was no need for an implementation before.
* Class `\CycloneDX\Core\Models\Component`'s property `version` is optional now, to reflect CycloneDX v1.4. (via [#118], [#131])
This affects constructor arguments, and affects methods `{get,set}Version()`.
* Some methods no longer throw `InvalidArgumentException`. (via [#125])
This was possible by enforcing correct typing on language level.
* Removed
* The public usage of the internal class `\CycloneDX\Core\Models\License\AbstractDisjunctiveLicense`. (via [#125])
This was possible due php8's UnionType language feature.
* BREAKING
* Removed support for PHP v7.3. ([#6] via [#125])
* Removed support for PHP v7.4. ([#114] via [#125])
* Changed models' aggregation properties to be no longer optional. ([#66] via [#131])
* Streamlined repository data structures to follow a common method naming scheme. (via [#131])
* Added
* New class constant `\CycloneDX\Core\Spec\Version::V_1_4` for CycloneDX v1.4. (via [#65])
* New class `\CycloneDX\Core\Spec\Spec14` to reflect CycloneDX v1.4. (via [#65])
* Support for CycloneDX v1.4 in `\CycloneDX\Core\Validation\Validators\{Json,Xml}StrictValidator`. (via [#65])
* New methods in class `\CycloneDX\Core\Spec\Spec1{1,2,3}`:
* `::getSupportedExternalReferenceTypes()` (via [#65], [#124])
* `::isSupportedExternalReferenceType()` (via [#65], [#124])
* `::supportsToolExternalReferences()` (via [#123])
* New class constant `CycloneDX\Core\Enums\ExternalReferenceType::RELEASE_NOTES` to reflect CycloneDX v1.4. (via [#65])
* Style
* All class properties now enforce the correct types. (via [#125])
* Support for CycloneDX v1.4. ([#57] via [#65], [#118], [#123])
* Misc
* All class properties now enforce the correct types. ([#6], [#114] via [#125])
This is considered a non-breaking change, because the types were already correctly annotated.
This was possible due to php74's features and php8's UnionType language feature.
* Migrated internals to php8 language features. (via [#125])

This was possible due to PHP74's features and php8's UnionType language feature.
* Migrated internals to PHP8 language features. ([#114] via [#125])

API changes

* Overall
* BREAKING: Enforced the use of concrete UnionTypes instead of protocols/interfaces/abstracts. ([#114] via [#125])
Affected the usages of no longer public `\CycloneDX\Core\Models\License\AbstractDisjunctiveLicense` and methods that used license-related classes.
This was possible due to PHP8's UnionType language feature.
* Changed some methods to no longer throw `\InvalidArgumentException`. (via [#125])
PhpDoc annotations were updated, so that code analysis tools should pick up.
This was possible by enforcing correct typing on PHP8 language level.
* `\CycloneDX\Core\Enum` namespace
* Added class constant `ExternalReferenceType::RELEASE_NOTES` to reflect CycloneDX v1.4 ([#57] via [#65])
* `\CycloneDX\Core\Factories` namespace
* No noteworthy changes
* `\CycloneDX\Core\Models` namespace
* `Bom` class
* BREAKING: renamed methods `{get,set}ComponentRepository()` -> `{get,set}Components()` ([#133] via [#131])
* BREAKING: renamed methods `{get,set}ExternalReferenceRepository()` -> `{get,set}ExternalReferences()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* BREAKING: renamed methods `{get,set}MetaData()` -> `{get,set}Metadata()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* `Component` class
* BREAKING: renamed methods `{get,set}DependenciesBomRefRepository()` -> `{get,set}Dependencies()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* BREAKING: renamed methods `{get,set}ExternalReferenceRepository()` -> `{get,set}ExternalReferences()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* BREAKING: renamed methods `{get,set}HashRepository()` -> `{get,set}Hashes()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* BREAKING: renamed methods `{get,set}License()` -> `{get,set}Licenses()` (via [#131])
and changed it work with class `LicenseRepository` only, was working with various `Models\License\*` types. ([#66] via [#131])
* BREAKING: Changed class property `version` to optional now, to reflect CycloneDX v1.4. ([#27] via [#118], [#131])
This affects constructor arguments, and affects methods `{get,set}Version()`.
* `ExternalReference` class
* BREAKING: renamed methods `{get,set}HashRepository()` -> `{get,set}Hashes()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* `Licenses` namespace
* `AbstractDisjunctiveLicense`
* BREAKING: Removed this class (via [#125], [#131])
* `DisjunctiveLicenseWithId` class
* No noteworthy changes.
* `DisjunctiveLicenseWithName` class
* No noteworthy changes.
* `LicenseExpression` class
* No noteworthy changes.
* `MetaData` class
* BREAKING: renamed class to `Metadata` ([#133] via [#131])
Even though PHP is case-insensitive with class names, autoloaders are not. Therefore, this is considered a breaking change.
* BREAKING: changed methods `{get,set}Tools()` so that their parameter & return type is non-nullable, was nullable ([#66] via [#131])
* `Tool` class
* BREAKING: renamed methods `{get,set}ExternalReferenceRepository()` -> `{get,set}ExternalReferences()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* BREAKING: renamed methods `{get,set}HashRepository()` -> `{get,set}Hashes()` ([#133] via [#131])
and changed parameter & return type to non-nullable, was nullable ([#66] via [#131])
* `\CycloneDX\Core\Repositories` namespace
* Overall:
* BREAKING: Renamed the namespace to `Collections` ([#133] via [#131])
* BREAKING: Streamlined all classes, renamed all getters to `getItems` and all setters to `setItems`. ([#133] via [#131])
In addition, the method arguments were renamed to generic `$items`.
* `DisjunctiveLicenseRepository` class
* BREAKING: renamed the class to `LicenseRepository` (via [#131])
* BREAKING: Added the capability to also aggregate instances of class `Models\LicenseExpression`. (via [#131])
Therefore, various getters and setters and the constructor changed their signatures,
was usage of `Models\License\AbstractDisjunctiveLicense` only.
* `HashRepository` class
* BREAKING: renamed to `HashDictionary` ([#133] via [#131])
* BREAKING: renamed all methods and changed all method signatures to match the overall streamlined scheme ([#133] via [#131])
* `\CycloneDX\Core\Serialize` namespace
* `{DOM,JSON}\NormalizerFactory` classes
* BREAKING: removed method `makeForLicenseExpression()` (via [#131])
* BREAKING: removed method `makeForDisjunctiveLicense()` (via [#131])
* BREAKING: removed method `makeForDisjunctiveLicenseRepository()` (via [#131])
* BREAKING: removed method `makeForHashRepositonary()` - use `makeForHashDictionary()` instead ([#133] via [#131])
* BREAKING: removed method `setSpec()` (via [#131])
* Added new method `makeForHashDictionary()` ([#133] via [#131])
* Added method `makeForLicense()` (via [#131])
* Added method `makeForLicenseRepository()` (via [#131])
* namespaces `{DOM,JSON}\Normalizers`
* BREAKING: removed classes `DisjunctiveLicenseNormalizer` - use `LicenseNormalizer` instead (via [#131])
* BREAKING: removed classes `LicenseExpressionNormalizer` - use `LicenseNormalizer` instead (via [#131])
* BREAKING: removed classes `DisjunctiveLicenseRepositoryNormalizer` (via [#131])
* BREAKING: renamed classes `HashRepositoryNormalizer` -> `HashDictionaryNormalizer` ([#133] via [#131])
and changed signatures to accept `Models\HashDictionary` instead of `Models\HashRepository`
* Added new classes `LicenseNormalizer` that can normalize every existing license model (via [#131])
* Added new classes `LicenseRepositoryNormalizer` that can normalize `LicenseRepository` (via [#131])
* `ExternalReferenceNormalizer` classes
* Changed the method `normalize()` to actually throw `\DomainException` when `\ExternalReference`'s type was not supported by the spec. (via [#65])
This is considered a non-breaking change, because the behaviour was already documented in the API, even though there was no need for an implementation before.
* `\CycloneDX\Core\Spdx` namespace
* No noteworthy changes.
* `\CycloneDX\Core\Spec` namespace
* BREAKING: removed the public usage of the interface `SpecInterface` (via [#65])
This is done to prevent the need for future "breaking changed" when the schema requires additional spec implementations.
The class was not removed, but marked `@internal`.
* Added class constant `Version::V_1_4` for CycloneDX v1.4 ([#57] via [#65])
* Added new class `Spec14` to reflect CycloneDX v1.4 ([#57] via [#65])
* Added new methods in class `Spec1{1,2,3}`:
* `getSupportedExternalReferenceTypes()` (via [#65], [#124])
* `isSupportedExternalReferenceType()` (via [#65], [#124])
* `supportsToolExternalReferences()` (via [#123])
* `\CycloneDX\Core\Validation` namespace
* Added support for CycloneDX v1.4 in classes`{Json,Xml}StrictValidator` ([#57] via [#65])

[#6]: https://github.com/CycloneDX/cyclonedx-php-library/issues/6
[#27]: https://github.com/CycloneDX/cyclonedx-php-library/issues/27
[#57]: https://github.com/CycloneDX/cyclonedx-php-library/issues/57
[#65]: https://github.com/CycloneDX/cyclonedx-php-library/pull/65
[#66]: https://github.com/CycloneDX/cyclonedx-php-library/issues/66
[#114]: https://github.com/CycloneDX/cyclonedx-php-library/issues/114
[#118]: https://github.com/CycloneDX/cyclonedx-php-library/pull/118
[#123]: https://github.com/CycloneDX/cyclonedx-php-library/pull/123
[#124]: https://github.com/CycloneDX/cyclonedx-php-library/pull/123
[#124]: https://github.com/CycloneDX/cyclonedx-php-library/pull/124
[#125]: https://github.com/CycloneDX/cyclonedx-php-library/pull/125
[#131]: https://github.com/CycloneDX/cyclonedx-php-library/pull/131
[#133]: https://github.com/CycloneDX/cyclonedx-php-library/pull/133

## 1.6.3 - 2022-09-15

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ See extended [examples].

```php
$bom = new \CycloneDX\Core\Models\Bom();
$bom->getComponentRepository()->addComponent(
$bom->getComponents()->addItems(
new \CycloneDX\Core\Models\Component(
\CycloneDX\Core\Enums\Classification::LIBRARY,
'myComponent'
Expand Down
Loading