From 0cf258203672e830f945eabbde4cf329412385bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 06:33:51 +0000 Subject: [PATCH 1/2] tools(deps-dev): Update friendsofphp/php-cs-fixer requirement Updates the requirements on [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) to permit the latest version. - [Release notes](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases) - [Changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/CHANGELOG.md) - [Commits](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.22.0...v3.23.0) --- updated-dependencies: - dependency-name: friendsofphp/php-cs-fixer dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- tools/php-cs-fixer/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/php-cs-fixer/composer.json b/tools/php-cs-fixer/composer.json index 8aa0b6f9..718c4702 100644 --- a/tools/php-cs-fixer/composer.json +++ b/tools/php-cs-fixer/composer.json @@ -3,7 +3,7 @@ "description": "php-cs-fixer", "type": "metapackage", "require-dev": { - "friendsofphp/php-cs-fixer": "3.22.0", + "friendsofphp/php-cs-fixer": "3.23.0", "roave/security-advisories": "dev-latest" }, "prefer-stable": true, From 9ae43a7d62e84872e620f1bad5dc462247663811 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 21 Aug 2023 09:19:15 +0200 Subject: [PATCH 2/2] style: apply latest coding standards Signed-off-by: Jan Kowalleck --- HISTORY.md | 5 +++++ src/Core/Factories/LicenseFactory.php | 9 +++++---- .../DOM/Normalizers/ComponentRepositoryNormalizer.php | 3 ++- .../DOM/Normalizers/HashDictionaryNormalizer.php | 3 ++- .../Serialization/DOM/Normalizers/MetadataNormalizer.php | 3 ++- .../DOM/Normalizers/PropertyRepositoryNormalizer.php | 3 ++- .../DOM/Normalizers/ToolRepositoryNormalizer.php | 3 ++- .../JSON/Normalizers/ComponentRepositoryNormalizer.php | 3 ++- .../JSON/Normalizers/HashDictionaryNormalizer.php | 3 ++- .../JSON/Normalizers/MetadataNormalizer.php | 3 ++- .../JSON/Normalizers/PropertyRepositoryNormalizer.php | 3 ++- .../JSON/Normalizers/ToolRepositoryNormalizer.php | 3 ++- 12 files changed, 30 insertions(+), 14 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 2926e820..0f614a5b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. ## unreleased +* Style + * Applied latest PHP Coding Standards (via [#341]) + +[#341]: https://github.com/CycloneDX/cyclonedx-php-library/pull/341 + ## 2.3.0 - 2023-06-27 Added support for [_CycloneDX_ Specification-1.5](https://github.com/CycloneDX/specification/releases/tag/1.5). diff --git a/src/Core/Factories/LicenseFactory.php b/src/Core/Factories/LicenseFactory.php index 9cb16234..73f2f1c6 100644 --- a/src/Core/Factories/LicenseFactory.php +++ b/src/Core/Factories/LicenseFactory.php @@ -29,6 +29,7 @@ use CycloneDX\Core\Models\License\SpdxLicense; use CycloneDX\Core\Spdx\LicenseIdentifiers; use DomainException; +use InvalidArgumentException; class LicenseFactory { @@ -52,12 +53,12 @@ public function makeFromString(string $license): SpdxLicense|LicenseExpression|N { try { return $this->makeSpdxLicense($license); - } catch (\DomainException) { + } catch (DomainException) { /* pass */ } try { return $this->makeExpression($license); - } catch (\DomainException) { + } catch (DomainException) { /* pass */ } @@ -68,7 +69,7 @@ public function makeDisjunctive(string $license): SpdxLicense|NamedLicense { try { return $this->makeSpdxLicense($license); - } catch (\DomainException) { + } catch (DomainException) { return $this->makeNamedLicense($license); } } @@ -80,7 +81,7 @@ public function makeExpression(string $license): LicenseExpression { try { $valid = $this->spdxLicenses->validate($license); - } catch (\InvalidArgumentException) { + } catch (InvalidArgumentException) { $valid = false; } if ($valid) { diff --git a/src/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizer.php b/src/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizer.php index 6f2b99ec..d21c51a0 100644 --- a/src/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizer.php +++ b/src/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\ComponentRepository; use CycloneDX\Core\Serialization\DOM\_BaseNormalizer; +use DomainException; use DOMElement; /** @@ -45,7 +46,7 @@ public function normalize(ComponentRepository $repo): array foreach ($repo->getItems() as $component) { try { $components[] = $normalizer->normalize($component); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizer.php b/src/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizer.php index 073ee301..c490d1fd 100644 --- a/src/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizer.php +++ b/src/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\HashDictionary; use CycloneDX\Core\Serialization\DOM\_BaseNormalizer; +use DomainException; use DOMElement; /** @@ -45,7 +46,7 @@ public function normalize(HashDictionary $repo): array foreach ($repo->getItems() as [$algorithm , $content]) { try { $hashes[] = $hashNormalizer->normalize($algorithm, $content); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/DOM/Normalizers/MetadataNormalizer.php b/src/Core/Serialization/DOM/Normalizers/MetadataNormalizer.php index 222482fe..29cff8ef 100644 --- a/src/Core/Serialization/DOM/Normalizers/MetadataNormalizer.php +++ b/src/Core/Serialization/DOM/Normalizers/MetadataNormalizer.php @@ -32,6 +32,7 @@ use DateTime; use DateTimeInterface; use DateTimeZone; +use DomainException; use DOMElement; /** @@ -90,7 +91,7 @@ private function normalizeComponent(?Component $component): ?DOMElement try { return $this->getNormalizerFactory()->makeForComponent()->normalize($component); - } catch (\DomainException) { + } catch (DomainException) { return null; } } diff --git a/src/Core/Serialization/DOM/Normalizers/PropertyRepositoryNormalizer.php b/src/Core/Serialization/DOM/Normalizers/PropertyRepositoryNormalizer.php index 3f7e6d09..dd4acc3c 100644 --- a/src/Core/Serialization/DOM/Normalizers/PropertyRepositoryNormalizer.php +++ b/src/Core/Serialization/DOM/Normalizers/PropertyRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\PropertyRepository; use CycloneDX\Core\Serialization\DOM\_BaseNormalizer; +use DomainException; use DOMElement; /** @@ -45,7 +46,7 @@ public function normalize(PropertyRepository $repo): array foreach ($repo->getItems() as $property) { try { $properties[] = $normalizer->normalize($property); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizer.php b/src/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizer.php index 778c7544..c6cb5908 100644 --- a/src/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizer.php +++ b/src/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\ToolRepository; use CycloneDX\Core\Serialization\DOM\_BaseNormalizer; +use DomainException; use DOMElement; /** @@ -45,7 +46,7 @@ public function normalize(ToolRepository $repo): array foreach ($repo->getItems() as $tool) { try { $tools[] = $normalizer->normalize($tool); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizer.php b/src/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizer.php index 8c585a45..9373edd7 100644 --- a/src/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizer.php +++ b/src/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\ComponentRepository; use CycloneDX\Core\Serialization\JSON\_BaseNormalizer; +use DomainException; /** * @author jkowalleck @@ -42,7 +43,7 @@ public function normalize(ComponentRepository $repo): array foreach ($repo->getItems() as $component) { try { $components[] = $normalizer->normalize($component); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/JSON/Normalizers/HashDictionaryNormalizer.php b/src/Core/Serialization/JSON/Normalizers/HashDictionaryNormalizer.php index 61d5d5ac..6719c3b2 100644 --- a/src/Core/Serialization/JSON/Normalizers/HashDictionaryNormalizer.php +++ b/src/Core/Serialization/JSON/Normalizers/HashDictionaryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\HashDictionary; use CycloneDX\Core\Serialization\JSON\_BaseNormalizer; +use DomainException; /** * @author jkowalleck @@ -39,7 +40,7 @@ public function normalize(HashDictionary $repo): array foreach ($repo->getItems() as [$algorithm , $content]) { try { $hashes[] = $normalizer->normalize($algorithm, $content); - } catch (\DomainException) { + } catch (DomainException) { /* pass */ } } diff --git a/src/Core/Serialization/JSON/Normalizers/MetadataNormalizer.php b/src/Core/Serialization/JSON/Normalizers/MetadataNormalizer.php index aa0e990d..b0b0f07c 100644 --- a/src/Core/Serialization/JSON/Normalizers/MetadataNormalizer.php +++ b/src/Core/Serialization/JSON/Normalizers/MetadataNormalizer.php @@ -32,6 +32,7 @@ use DateTime; use DateTimeInterface; use DateTimeZone; +use DomainException; /** * @author jkowalleck @@ -80,7 +81,7 @@ private function normalizeComponent(?Component $component): ?array try { return $this->getNormalizerFactory()->makeForComponent()->normalize($component); - } catch (\DomainException) { + } catch (DomainException) { return null; } } diff --git a/src/Core/Serialization/JSON/Normalizers/PropertyRepositoryNormalizer.php b/src/Core/Serialization/JSON/Normalizers/PropertyRepositoryNormalizer.php index 20575726..8bb71c10 100644 --- a/src/Core/Serialization/JSON/Normalizers/PropertyRepositoryNormalizer.php +++ b/src/Core/Serialization/JSON/Normalizers/PropertyRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\PropertyRepository; use CycloneDX\Core\Serialization\JSON\_BaseNormalizer; +use DomainException; /** * @author jkowalleck @@ -39,7 +40,7 @@ public function normalize(PropertyRepository $repo): array foreach ($repo->getItems() as $property) { try { $properties[] = $normalizer->normalize($property); - } catch (\DomainException) { + } catch (DomainException) { // pass } } diff --git a/src/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizer.php b/src/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizer.php index 9f413faf..783923ab 100644 --- a/src/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizer.php +++ b/src/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizer.php @@ -25,6 +25,7 @@ use CycloneDX\Core\Collections\ToolRepository; use CycloneDX\Core\Serialization\JSON\_BaseNormalizer; +use DomainException; /** * @author jkowalleck @@ -44,7 +45,7 @@ public function normalize(ToolRepository $repo): array foreach ($repo->getItems() as $tool) { try { $item = $normalizer->normalize($tool); - } catch (\DomainException) { + } catch (DomainException) { continue; } if (false === empty($item)) {