diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 04971c27..698eb4ee 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -38,9 +38,10 @@
'@Symfony' => true,
'@Symfony:risky' => true,
'declare_strict_types' => true,
- 'phpdoc_order' => true,
'header_comment' => ['header' => $header],
+ 'global_namespace_import' => true,
'fopen_flags' => ['b_mode' => true],
+ 'phpdoc_order' => true,
'phpdoc_to_comment' => [
'ignored_tags' => [
// 'psalm-var', // needed when PSALM introduced some issues that only manual hints can solve
diff --git a/src/Core/Collections/BomRefRepository.php b/src/Core/Collections/BomRefRepository.php
index 05c41e13..cb9ff8ea 100644
--- a/src/Core/Collections/BomRefRepository.php
+++ b/src/Core/Collections/BomRefRepository.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Models\BomRef;
/**
@@ -30,7 +31,7 @@
*
* @author jkowalleck
*/
-class BomRefRepository implements \Countable
+class BomRefRepository implements Countable
{
/**
* @var BomRef[]
diff --git a/src/Core/Collections/ComponentRepository.php b/src/Core/Collections/ComponentRepository.php
index 8607d0e2..5232e2e5 100644
--- a/src/Core/Collections/ComponentRepository.php
+++ b/src/Core/Collections/ComponentRepository.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Models\Component;
/**
@@ -30,7 +31,7 @@
*
* @author jkowalleck
*/
-class ComponentRepository implements \Countable
+class ComponentRepository implements Countable
{
/**
* @var Component[]
diff --git a/src/Core/Collections/ExternalReferenceRepository.php b/src/Core/Collections/ExternalReferenceRepository.php
index 407fecb7..dd4c9d87 100644
--- a/src/Core/Collections/ExternalReferenceRepository.php
+++ b/src/Core/Collections/ExternalReferenceRepository.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Models\ExternalReference;
/**
@@ -30,7 +31,7 @@
*
* @author jkowalleck
*/
-class ExternalReferenceRepository implements \Countable
+class ExternalReferenceRepository implements Countable
{
/**
* @var ExternalReference[]
diff --git a/src/Core/Collections/HashDictionary.php b/src/Core/Collections/HashDictionary.php
index 8f0639b9..1892f2fc 100644
--- a/src/Core/Collections/HashDictionary.php
+++ b/src/Core/Collections/HashDictionary.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Enums\HashAlgorithm;
use DomainException;
@@ -31,7 +32,7 @@
*
* @author jkowalleck
*/
-class HashDictionary implements \Countable
+class HashDictionary implements Countable
{
/**
* @var string[] dictionary of hashes
diff --git a/src/Core/Collections/LicenseRepository.php b/src/Core/Collections/LicenseRepository.php
index fe5a5bd9..0ce6bf07 100644
--- a/src/Core/Collections/LicenseRepository.php
+++ b/src/Core/Collections/LicenseRepository.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Models\License\DisjunctiveLicenseWithId;
use CycloneDX\Core\Models\License\DisjunctiveLicenseWithName;
use CycloneDX\Core\Models\License\LicenseExpression;
@@ -34,7 +35,7 @@
*
* @author jkowalleck
*/
-class LicenseRepository implements \Countable
+class LicenseRepository implements Countable
{
/**
* @var DisjunctiveLicenseWithId[]|DisjunctiveLicenseWithName[]|LicenseExpression[]
diff --git a/src/Core/Collections/ToolRepository.php b/src/Core/Collections/ToolRepository.php
index 1cd4e982..a1140ef2 100644
--- a/src/Core/Collections/ToolRepository.php
+++ b/src/Core/Collections/ToolRepository.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Core\Collections;
+use Countable;
use CycloneDX\Core\Models\Tool;
/**
@@ -30,7 +31,7 @@
*
* @author jkowalleck
*/
-class ToolRepository implements \Countable
+class ToolRepository implements Countable
{
/**
* @var Tool[]
diff --git a/src/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizer.php b/src/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizer.php
index 7783422f..ee1f0ed7 100644
--- a/src/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizer.php
+++ b/src/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizer.php
@@ -25,7 +25,9 @@
use CycloneDX\Core\Collections\ExternalReferenceRepository;
use CycloneDX\Core\Serialization\DOM\_BaseNormalizer;
+use DomainException;
use DOMElement;
+use UnexpectedValueException;
/**
* @author jkowalleck
@@ -45,7 +47,7 @@ public function normalize(ExternalReferenceRepository $repo): array
foreach ($repo->getItems() as $externalReference) {
try {
$externalReferences[] = $normalizer->normalize($externalReference);
- } catch (\DomainException|\UnexpectedValueException) {
+ } catch (DomainException|UnexpectedValueException) {
// pass
}
}
diff --git a/src/Core/Validation/Exceptions/FailedLoadingSchemaException.php b/src/Core/Validation/Exceptions/FailedLoadingSchemaException.php
index 8ac8cdb6..d1497ae2 100644
--- a/src/Core/Validation/Exceptions/FailedLoadingSchemaException.php
+++ b/src/Core/Validation/Exceptions/FailedLoadingSchemaException.php
@@ -23,6 +23,8 @@
namespace CycloneDX\Core\Validation\Exceptions;
-class FailedLoadingSchemaException extends \RuntimeException
+use RuntimeException;
+
+class FailedLoadingSchemaException extends RuntimeException
{
}
diff --git a/src/Core/Validation/ValidationError.php b/src/Core/Validation/ValidationError.php
index d469413d..9dab8610 100644
--- a/src/Core/Validation/ValidationError.php
+++ b/src/Core/Validation/ValidationError.php
@@ -23,6 +23,8 @@
namespace CycloneDX\Core\Validation;
+use Throwable;
+
/**
* @author jkowalleck
*/
@@ -56,7 +58,7 @@ public function getError(): ?object
/**
* @internal as this function may be affected by breaking changes without notice
*/
- public static function fromThrowable(\Throwable $error): static
+ public static function fromThrowable(Throwable $error): static
{
$instance = new static($error->getMessage());
$instance->error = $error;
diff --git a/src/Core/Validation/Validators/JsonValidator.php b/src/Core/Validation/Validators/JsonValidator.php
index 26845bf1..7ecbf480 100644
--- a/src/Core/Validation/Validators/JsonValidator.php
+++ b/src/Core/Validation/Validators/JsonValidator.php
@@ -31,6 +31,7 @@
use CycloneDX\Core\Validation\Exceptions\FailedLoadingSchemaException;
use Exception;
use JsonException;
+use stdClass;
use Swaggest\JsonSchema;
/**
@@ -71,7 +72,7 @@ public function validateString(string $string): ?JsonValidationError
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
- public function validateData(\stdClass $data): ?JsonValidationError
+ public function validateData(stdClass $data): ?JsonValidationError
{
$contract = $this->getSchemaContract();
try {
@@ -106,14 +107,14 @@ private function getSchemaContract(): JsonSchema\SchemaContract
/**
* @throws JsonException if loading the JSON failed
*/
- private function loadDataFromJson(string $json): \stdClass
+ private function loadDataFromJson(string $json): stdClass
{
try {
$data = json_decode($json, false, 512, \JSON_THROW_ON_ERROR);
} catch (Exception $exception) {
throw new JsonException('loading failed', 0, $exception);
}
- \assert($data instanceof \stdClass);
+ \assert($data instanceof stdClass);
return $data;
}
diff --git a/src/Core/Validation/Validators/XmlValidator.php b/src/Core/Validation/Validators/XmlValidator.php
index bda2f11b..39426ffd 100644
--- a/src/Core/Validation/Validators/XmlValidator.php
+++ b/src/Core/Validation/Validators/XmlValidator.php
@@ -30,6 +30,7 @@
use CycloneDX\Core\Validation\Exceptions\FailedLoadingSchemaException;
use DOMDocument;
use DOMException;
+use LibXMLError;
/**
* @author jkowalleck
@@ -81,7 +82,7 @@ public function validateDom(DOMDocument $doc): ?XmlValidationError
/**
* @throws FailedLoadingSchemaException
*/
- private function validateDomWithSchema(DOMDocument $doc): ?\LibXMLError
+ private function validateDomWithSchema(DOMDocument $doc): ?LibXMLError
{
$schema = $this->getSchemaFile();
diff --git a/src/Core/Validation/_helpers/JsonSchemaRemoteRefProviderForSnapshotResources.php b/src/Core/Validation/_helpers/JsonSchemaRemoteRefProviderForSnapshotResources.php
index 7ea8b2bf..95a5ce48 100644
--- a/src/Core/Validation/_helpers/JsonSchemaRemoteRefProviderForSnapshotResources.php
+++ b/src/Core/Validation/_helpers/JsonSchemaRemoteRefProviderForSnapshotResources.php
@@ -24,6 +24,8 @@
namespace CycloneDX\Core\Validation\_helpers;
use CycloneDX\Core\Resources;
+use JsonException;
+use stdClass;
use Swaggest\JsonSchema;
/**
@@ -38,7 +40,7 @@ class JsonSchemaRemoteRefProviderForSnapshotResources implements JsonSchema\Remo
/**
* {@inheritdoc}
*
- * @throws \JsonException
+ * @throws JsonException
*/
public function getSchemaData($url)
{
@@ -58,7 +60,7 @@ public function getSchemaData($url)
$content = file_get_contents($filePath);
\assert(\is_string($content));
$data = json_decode($content, false, 512, \JSON_THROW_ON_ERROR);
- \assert($data instanceof \stdClass);
+ \assert($data instanceof stdClass);
return $data;
}
diff --git a/tests/Core/Collections/HashDictionaryTest.php b/tests/Core/Collections/HashDictionaryTest.php
index a839298d..b9b033ce 100644
--- a/tests/Core/Collections/HashDictionaryTest.php
+++ b/tests/Core/Collections/HashDictionaryTest.php
@@ -25,6 +25,7 @@
use CycloneDX\Core\Collections\HashDictionary;
use CycloneDX\Core\Enums\HashAlgorithm;
+use DomainException;
use PHPUnit\Framework\TestCase;
/**
@@ -88,7 +89,7 @@ public function testSetUnknownHashAlgorithmThrows(): void
{
$hashes = new HashDictionary();
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessageMatches('/unknown hash algorithm/i');
$hashes->set('unknownAlgorithm', 'foobar');
diff --git a/tests/Core/Enums/ClassificationTest.php b/tests/Core/Enums/ClassificationTest.php
index c5e39709..dd95e6c0 100644
--- a/tests/Core/Enums/ClassificationTest.php
+++ b/tests/Core/Enums/ClassificationTest.php
@@ -25,7 +25,9 @@
use CycloneDX\Core\Enums\Classification;
use CycloneDX\Tests\_data\BomSpecData;
+use Generator;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
/**
* @covers \CycloneDX\Core\Enums\Classification
@@ -41,15 +43,15 @@ public function testIsValidValue(string $value, bool $expected): void
self::assertSame($expected, Classification::isValidValue($value));
}
- public function dpKnownValues(): \Generator
+ public function dpKnownValues(): Generator
{
- $allValues = (new \ReflectionClass(Classification::class))->getConstants();
+ $allValues = (new ReflectionClass(Classification::class))->getConstants();
foreach ($allValues as $value) {
yield $value => [$value, true];
}
}
- public function dpUnknownValue(): \Generator
+ public function dpUnknownValue(): Generator
{
yield 'invalid' => ['UnknownClassification', false];
}
@@ -62,7 +64,7 @@ public function testIsValidKnowsAllSchemaValues(string $value): void
self::assertTrue(Classification::isValidValue($value));
}
- public function dpSchemaValues(): \Generator
+ public function dpSchemaValues(): Generator
{
$allValues = array_unique(array_merge(
BomSpecData::getClassificationEnumForVersion('1.0'),
diff --git a/tests/Core/Enums/ExternalReferenceTypeTest.php b/tests/Core/Enums/ExternalReferenceTypeTest.php
index 59b7d7ce..b5fc9868 100644
--- a/tests/Core/Enums/ExternalReferenceTypeTest.php
+++ b/tests/Core/Enums/ExternalReferenceTypeTest.php
@@ -25,7 +25,9 @@
use CycloneDX\Core\Enums\ExternalReferenceType;
use CycloneDX\Tests\_data\BomSpecData;
+use Generator;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
/**
* @covers \CycloneDX\Core\Enums\ExternalReferenceType
@@ -41,15 +43,15 @@ public function testIsValidValue(string $value, bool $expected): void
self::assertSame($expected, ExternalReferenceType::isValidValue($value));
}
- public function dpKnownValues(): \Generator
+ public function dpKnownValues(): Generator
{
- $allValues = (new \ReflectionClass(ExternalReferenceType::class))->getConstants();
+ $allValues = (new ReflectionClass(ExternalReferenceType::class))->getConstants();
foreach ($allValues as $value) {
yield $value => [$value, true];
}
}
- public function dpUnknownValue(): \Generator
+ public function dpUnknownValue(): Generator
{
yield 'invalid' => ['UnknownExternalReferenceType', false];
}
@@ -62,7 +64,7 @@ public function testIsValidKnowsAllSchemaValues(string $value): void
self::assertTrue(ExternalReferenceType::isValidValue($value));
}
- public function dpSchemaValues(): \Generator
+ public function dpSchemaValues(): Generator
{
$allValues = array_unique(array_merge(
BomSpecData::getExternalReferenceTypeForVersion('1.1'),
diff --git a/tests/Core/Enums/HashAlgorithmTest.php b/tests/Core/Enums/HashAlgorithmTest.php
index 17bdfbf7..dba1c1ca 100644
--- a/tests/Core/Enums/HashAlgorithmTest.php
+++ b/tests/Core/Enums/HashAlgorithmTest.php
@@ -25,7 +25,9 @@
use CycloneDX\Core\Enums\HashAlgorithm;
use CycloneDX\Tests\_data\BomSpecData;
+use Generator;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
/**
* @covers \CycloneDX\Core\Enums\HashAlgorithm
@@ -41,15 +43,15 @@ public function testIsValidValue(string $value, bool $expected): void
self::assertSame($expected, HashAlgorithm::isValidValue($value));
}
- public function dpKnownValues(): \Generator
+ public function dpKnownValues(): Generator
{
- $allValues = (new \ReflectionClass(HashAlgorithm::class))->getConstants();
+ $allValues = (new ReflectionClass(HashAlgorithm::class))->getConstants();
foreach ($allValues as $value) {
yield $value => [$value, true];
}
}
- public function dpUnknownValue(): \Generator
+ public function dpUnknownValue(): Generator
{
yield 'invalid' => ['UnknownAlg', false];
}
@@ -62,7 +64,7 @@ public function testIsValidKnowsAllSchemaValues(string $value): void
self::assertTrue(HashAlgorithm::isValidValue($value));
}
- public function dpSchemaValues(): \Generator
+ public function dpSchemaValues(): Generator
{
$allValues = array_unique(array_merge(
BomSpecData::getHashAlgEnumForVersion('1.0'),
diff --git a/tests/Core/Factories/LicenseFactoryTest.php b/tests/Core/Factories/LicenseFactoryTest.php
index 6b6c74aa..aa5d797b 100644
--- a/tests/Core/Factories/LicenseFactoryTest.php
+++ b/tests/Core/Factories/LicenseFactoryTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Models\License\LicenseExpression;
use CycloneDX\Core\Spdx\LicenseValidator as SpdxLicenseValidator;
use DomainException;
+use Exception;
use PHPUnit\Framework\TestCase;
use UnexpectedValueException;
@@ -54,7 +55,7 @@ public function testConstructor(): LicenseFactory
$exception = null;
try {
$factory->getSpdxLicenseValidator();
- } catch (\Exception $exception) {
+ } catch (Exception $exception) {
// continue to assertions
}
diff --git a/tests/Core/Models/BomTest.php b/tests/Core/Models/BomTest.php
index 349f7892..a95d2ef1 100644
--- a/tests/Core/Models/BomTest.php
+++ b/tests/Core/Models/BomTest.php
@@ -27,6 +27,7 @@
use CycloneDX\Core\Collections\ExternalReferenceRepository;
use CycloneDX\Core\Models\Bom;
use CycloneDX\Core\Models\Metadata;
+use DomainException;
use PHPUnit\Framework\TestCase;
/**
@@ -89,7 +90,7 @@ public function testVersionSetterGetter(Bom $bom): void
public function testVersionSetterInvalidValue(Bom $bom): void
{
$version = 0 - random_int(1, 255);
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$bom->setVersion($version);
}
diff --git a/tests/Core/Models/ComponentTest.php b/tests/Core/Models/ComponentTest.php
index 22abdf3f..5fb6f5d9 100644
--- a/tests/Core/Models/ComponentTest.php
+++ b/tests/Core/Models/ComponentTest.php
@@ -30,6 +30,8 @@
use CycloneDX\Core\Enums\Classification;
use CycloneDX\Core\Models\BomRef;
use CycloneDX\Core\Models\Component;
+use DomainException;
+use Generator;
use PackageUrl\PackageUrl;
use PHPUnit\Framework\TestCase;
@@ -110,7 +112,7 @@ public function testTypeSetterGetter(Component $component): void
*/
public function testSetTypeWithUnknownValue(Component $component): void
{
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$component->setType('something unknown');
}
@@ -185,7 +187,7 @@ public function testDescriptionSetterGetter(Component $component, ?string $descr
self::assertSame($expected, $component->getDescription());
}
- public function dpDescriptionSetterGetter(): \Generator
+ public function dpDescriptionSetterGetter(): Generator
{
$component = $this->testConstructor();
yield 'null' => [$component, null, null];
@@ -209,7 +211,7 @@ public function testGroupSetterGetter(Component $component, ?string $group, ?str
self::assertSame($expected, $component->getGroup());
}
- public function dpGroupSetterGetter(): \Generator
+ public function dpGroupSetterGetter(): Generator
{
$component = $this->testConstructor();
yield 'null' => [$component, null, null];
diff --git a/tests/Core/Models/License/LicenseExpressionTest.php b/tests/Core/Models/License/LicenseExpressionTest.php
index 0ceefa9c..54924b3d 100644
--- a/tests/Core/Models/License/LicenseExpressionTest.php
+++ b/tests/Core/Models/License/LicenseExpressionTest.php
@@ -24,6 +24,8 @@
namespace CycloneDX\Tests\Core\Models\License;
use CycloneDX\Core\Models\License\LicenseExpression;
+use DomainException;
+use Generator;
use PHPUnit\Framework\TestCase;
/**
@@ -45,7 +47,7 @@ public function testConstructThrowsOnUnknownExpression(): void
{
$expression = $this->dpInvalidLicenseExpressions()[0];
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessageMatches('/invalid expression/i');
new LicenseExpression("$expression");
@@ -67,7 +69,7 @@ public function testSetThrowsOnUnknownExpression(): void
$expression = $this->dpInvalidLicenseExpressions()[0];
$license = $this->createPartialMock(LicenseExpression::class, []);
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessageMatches('/invalid expression/i');
$license->setExpression("$expression");
@@ -82,7 +84,7 @@ public function testIsValid(string $expression, $expected): void
self::assertSame($expected, $isValid);
}
- public function dpIsValid(): \Generator
+ public function dpIsValid(): Generator
{
foreach ($this->dpValidLicenseExpressions() as $license) {
yield $license => [$license, true];
diff --git a/tests/Core/ResourcesTest.php b/tests/Core/ResourcesTest.php
index ad3ab792..16de39e3 100644
--- a/tests/Core/ResourcesTest.php
+++ b/tests/Core/ResourcesTest.php
@@ -24,7 +24,9 @@
namespace CycloneDX\Tests\Core;
use CycloneDX\Core\Resources;
+use Generator;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
/**
* @coversNothing
@@ -47,9 +49,9 @@ public function testFileIsReadable(string $filePath): void
self::assertFileIsReadable($filePath);
}
- public function dpFiles(): \Generator
+ public function dpFiles(): Generator
{
- $constants = (new \ReflectionClass(Resources::class))->getConstants();
+ $constants = (new ReflectionClass(Resources::class))->getConstants();
foreach ($constants as $name => $value) {
if (str_starts_with($name, 'FILE')) {
yield $name => [$value];
diff --git a/tests/Core/Serialization/BaseSerializerTest.php b/tests/Core/Serialization/BaseSerializerTest.php
index bcf2964e..98e31956 100644
--- a/tests/Core/Serialization/BaseSerializerTest.php
+++ b/tests/Core/Serialization/BaseSerializerTest.php
@@ -31,6 +31,8 @@
use CycloneDX\Core\Models\Metadata;
use CycloneDX\Core\Serialization\BaseSerializer;
use CycloneDX\Core\Spec\Spec;
+use Exception;
+use Generator;
use PHPUnit\Framework\TestCase;
/**
@@ -87,7 +89,7 @@ public function testSerializeCallsNormalize(): void
public function testSerializeForwardsExceptionsFromNormalize(): void
{
$bom = $this->createStub(Bom::class);
- $exception = $this->createMock(\Exception::class);
+ $exception = $this->createMock(Exception::class);
$this->serializer->expects(self::once())
->method('normalize')
@@ -150,7 +152,7 @@ function () use ($allBomRefsValuesOriginal, &$allBomRefsValuesOnNormalize) {
self::assertSame('foobar', $actual);
}
- public function dpBomWithRefs(): \Generator
+ public function dpBomWithRefs(): Generator
{
$dependencies = $this->createStub(BomRefRepository::class);
diff --git a/tests/Core/Serialization/DOM/NormalizerFactoryTest.php b/tests/Core/Serialization/DOM/NormalizerFactoryTest.php
index fc0fa320..bba9ffcf 100644
--- a/tests/Core/Serialization/DOM/NormalizerFactoryTest.php
+++ b/tests/Core/Serialization/DOM/NormalizerFactoryTest.php
@@ -27,6 +27,7 @@
use CycloneDX\Core\Serialization\DOM\Normalizers;
use CycloneDX\Core\Spec\Spec;
use DomainException;
+use DOMDocument;
use PHPUnit\Framework\TestCase;
/**
@@ -47,7 +48,7 @@ public function testConstructor(): NormalizerFactory
$factory = new NormalizerFactory($spec);
self::assertSame($spec, $factory->getSpec());
- self::assertInstanceOf(\DOMDocument::class, $factory->getDocument());
+ self::assertInstanceOf(DOMDocument::class, $factory->getDocument());
return $factory;
}
diff --git a/tests/Core/Serialization/DOM/Normalizers/ComponentNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ComponentNormalizerTest.php
index db642905..f9bf4800 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ComponentNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ComponentNormalizerTest.php
@@ -35,6 +35,7 @@
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
use DomainException;
use DOMDocument;
+use Generator;
use PackageUrl\PackageUrl;
use PHPUnit\Framework\TestCase;
@@ -109,7 +110,7 @@ public function testNormalizeMinimal(string $expected, bool $requiresComponentVe
self::assertStringEqualsDomNode($expected, $actual);
}
- public function dbNormalizeMinimal(): \Generator
+ public function dbNormalizeMinimal(): Generator
{
yield 'mandatory ComponentVersion' => [
'myName',
diff --git a/tests/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizerTest.php
index 00540495..736e392f 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ComponentRepositoryNormalizerTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Serialization\DOM\Normalizers\ComponentNormalizer;
use CycloneDX\Core\Serialization\DOM\Normalizers\ComponentRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use DOMElement;
use PHPUnit\Framework\TestCase;
@@ -94,7 +95,7 @@ public function testNormalizeSkipsOnThrow(): void
$componentNormalizer->expects(self::exactly(2))->method('normalize')
->withConsecutive([$component1], [$component2])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$got = $normalizer->normalize($components);
diff --git a/tests/Core/Serialization/DOM/Normalizers/DependenciesNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/DependenciesNormalizerTest.php
index d09526ba..51caf088 100644
--- a/tests/Core/Serialization/DOM/Normalizers/DependenciesNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/DependenciesNormalizerTest.php
@@ -32,6 +32,9 @@
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
use CycloneDX\Core\Serialization\DOM\Normalizers\DependenciesNormalizer;
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
+use DOMDocument;
+use Exception;
+use Generator;
use PHPUnit\Framework\TestCase;
/**
@@ -57,7 +60,7 @@ protected function setUp(): void
$this->factory = $this->createConfiguredMock(
NormalizerFactory::class,
[
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
]
);
$this->normalizer = new DependenciesNormalizer($this->factory);
@@ -82,7 +85,7 @@ public function testNormalize(Bom $bom, array $expecteds): void
try {
self::assertStringEqualsDomNode($expected, $actual);
continue 2; // expected was found
- } catch (\Exception $exception) {
+ } catch (Exception $exception) {
// pass
}
}
@@ -99,7 +102,7 @@ public function testNormalize(Bom $bom, array $expecteds): void
);
}
- public function dpNormalize(): \Generator
+ public function dpNormalize(): Generator
{
$dependencies = $this->createStub(BomRefRepository::class);
diff --git a/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceNormalizerTest.php
index 225d517c..c1dff891 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceNormalizerTest.php
@@ -29,6 +29,9 @@
use CycloneDX\Core\Serialization\DOM\Normalizers;
use CycloneDX\Core\Spec\Spec;
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
+use DomainException;
+use DOMDocument;
+use Exception;
/**
* @covers \CycloneDX\Core\Serialization\DOM\Normalizers\ExternalReferenceNormalizer
@@ -42,7 +45,7 @@ public function testNormalizeTypeAndUrl(): void
{
$spec = $this->createMock(Spec::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'getSPec' => $spec,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -69,7 +72,7 @@ public function testThrowOnUnsupportedRefType(): void
{
$spec = $this->createMock(Spec::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'getSpec' => $spec,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -85,7 +88,7 @@ public function testThrowOnUnsupportedRefType(): void
->withConsecutive(['someType'], ['other'])
->willReturn(false);
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('ExternalReference has unsupported type: someType');
$normalizer->normalize($extRef);
@@ -95,7 +98,7 @@ public function testNormalizeTypeConvertIfNotSupported(): void
{
$spec = $this->createMock(Spec::class);
$normalizerFactory = $this->createConfiguredMock(\CycloneDX\Core\Serialization\DOM\NormalizerFactory::class, [
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'getSPec' => $spec,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -124,7 +127,7 @@ public function testNormalizeComment(): void
{
$spec = $this->createMock(Spec::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'getSPec' => $spec,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -157,7 +160,7 @@ public function testNormalizeHashes(): void
$HashDictionaryNormalizer = $this->createMock(Normalizers\HashDictionaryNormalizer::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
'getSpec' => $spec,
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'makeForHashDictionary' => $HashDictionaryNormalizer,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -188,7 +191,7 @@ public function testNormalizeHashes(): void
}
/**
- * @throws \Exception on assertion error
+ * @throws Exception on assertion error
*/
public function testNormalizeHashesOmitIfEmpty(): void
{
@@ -198,7 +201,7 @@ public function testNormalizeHashesOmitIfEmpty(): void
$HashDictionaryNormalizer = $this->createMock(Normalizers\HashDictionaryNormalizer::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
'getSpec' => $spec,
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'makeForHashDictionary' => $HashDictionaryNormalizer,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -225,7 +228,7 @@ public function testNormalizeHashesOmitIfEmpty(): void
}
/**
- * @throws \Exception on assertion error
+ * @throws Exception on assertion error
*/
public function testNormalizeHashesOmitIfNotSupported(): void
{
@@ -235,7 +238,7 @@ public function testNormalizeHashesOmitIfNotSupported(): void
$HashDictionaryNormalizer = $this->createMock(Normalizers\HashDictionaryNormalizer::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
'getSpec' => $spec,
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'makeForHashDictionary' => $HashDictionaryNormalizer,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
@@ -270,7 +273,7 @@ public function testNormalizeUrlEncodeAnyUri(string $rawUrl, string $encodedUrl)
{
$spec = $this->createMock(Spec::class);
$normalizerFactory = $this->createConfiguredMock(NormalizerFactory::class, [
- 'getDocument' => new \DOMDocument(),
+ 'getDocument' => new DOMDocument(),
'getSpec' => $spec,
]);
$normalizer = new Normalizers\ExternalReferenceNormalizer($normalizerFactory);
diff --git a/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
index 1129fdd4..eb04f4b5 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
@@ -28,7 +28,10 @@
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
use CycloneDX\Core\Serialization\DOM\Normalizers;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use DOMElement;
+use Generator;
+use UnexpectedValueException;
/**
* @covers \CycloneDX\Core\Serialization\DOM\Normalizers\ExternalReferenceRepositoryNormalizer
@@ -114,9 +117,9 @@ public function testNormalizeSkipsOnThrow(string $exceptionClass): void
self::assertSame([], $actual);
}
- public function dpNormalizeSkipsOnThrow(): \Generator
+ public function dpNormalizeSkipsOnThrow(): Generator
{
- yield 'DomainException' => [\DomainException::class];
- yield 'UnexpectedValueException' => [\UnexpectedValueException::class];
+ yield 'DomainException' => [DomainException::class];
+ yield 'UnexpectedValueException' => [UnexpectedValueException::class];
}
}
diff --git a/tests/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizerTest.php
index 235cc63f..cc52b649 100644
--- a/tests/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/HashDictionaryNormalizerTest.php
@@ -27,6 +27,7 @@
use CycloneDX\Core\Serialization\DOM\NormalizerFactory;
use CycloneDX\Core\Serialization\DOM\Normalizers\HashDictionaryNormalizer;
use CycloneDX\Core\Serialization\DOM\Normalizers\HashNormalizer;
+use DomainException;
use DOMDocument;
use DOMElement;
use PHPUnit\Framework\TestCase;
@@ -91,7 +92,7 @@ public function testNormalizeSkipOnThrow(): void
$hashNormalizer->expects(self::exactly(3))
->method('normalize')
->withConsecutive(['alg1', 'cont1'], ['alg2', 'cont2'], ['alg3', 'cont3'])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$got = $normalizer->normalize($repo);
diff --git a/tests/Core/Serialization/DOM/Normalizers/LicenseNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/LicenseNormalizerTest.php
index 3b32d54a..963b7df7 100644
--- a/tests/Core/Serialization/DOM/Normalizers/LicenseNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/LicenseNormalizerTest.php
@@ -31,6 +31,7 @@
use CycloneDX\Core\Spec\Spec;
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
use DOMDocument;
+use Generator;
/**
* @covers \CycloneDX\Core\Serialization\DOM\Normalizers\LicenseNormalizer
@@ -60,7 +61,7 @@ public function testNormalize(LicenseExpression|DisjunctiveLicenseWithId|Disjunc
self::assertStringEqualsDomNode($expectedXML, $actual);
}
- public function dpNormalize(): \Generator
+ public function dpNormalize(): Generator
{
yield 'license expression' => [
$this->createConfiguredMock(LicenseExpression::class, [
diff --git a/tests/Core/Serialization/DOM/Normalizers/MetadataNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/MetadataNormalizerTest.php
index fc0cab3f..5eb269da 100644
--- a/tests/Core/Serialization/DOM/Normalizers/MetadataNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/MetadataNormalizerTest.php
@@ -32,6 +32,7 @@
use CycloneDX\Core\Serialization\DOM\Normalizers\ToolRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
use CycloneDX\Tests\_traits\DomNodeAssertionTrait;
+use DomainException;
use DOMDocument;
use PHPUnit\Framework\TestCase;
@@ -150,7 +151,7 @@ public function testNormalizeComponentUnsupported(): void
$componentFactory->expects(self::once())
->method('normalize')
->with($metaData->getComponent())
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$actual = $normalizer->normalize($metaData);
diff --git a/tests/Core/Serialization/DOM/Normalizers/ToolNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ToolNormalizerTest.php
index 597d891f..aabec208 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ToolNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ToolNormalizerTest.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Tests\Core\Serialization\DOM\Normalizers;
+use BadMethodCallException;
use CycloneDX\Core\Collections\ExternalReferenceRepository;
use CycloneDX\Core\Collections\HashDictionary;
use CycloneDX\Core\Models\Tool;
@@ -149,10 +150,10 @@ public function testNormalizeMinimal(): void
$HashDictNormalizer->expects(self::never())
->method('normalize')
- ->willThrowException(new \BadMethodCallException());
+ ->willThrowException(new BadMethodCallException());
$extRefRepoNormalizer->expects(self::never())
->method('normalize')
- ->willThrowException(new \BadMethodCallException());
+ ->willThrowException(new BadMethodCallException());
$actual = $normalizer->normalize($tool);
diff --git a/tests/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizerTest.php b/tests/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizerTest.php
index a6ddaf4f..7c678104 100644
--- a/tests/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/DOM/Normalizers/ToolRepositoryNormalizerTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Serialization\DOM\Normalizers\ToolNormalizer;
use CycloneDX\Core\Serialization\DOM\Normalizers\ToolRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use DOMElement;
use PHPUnit\Framework\TestCase;
@@ -100,7 +101,7 @@ public function testNormalizeSkipsOnThrow(): void
$toolNormalizer->expects(self::exactly(2))
->method('normalize')
->withConsecutive([$tool1], [$tool2])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$actual = $normalizer->normalize($tools);
diff --git a/tests/Core/Serialization/JSON/Normalizers/ComponentNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ComponentNormalizerTest.php
index 186b77c3..22b7b88f 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ComponentNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ComponentNormalizerTest.php
@@ -32,6 +32,7 @@
use CycloneDX\Core\Serialization\JSON\Normalizers;
use CycloneDX\Core\Spec\Spec;
use DomainException;
+use Generator;
use PackageUrl\PackageUrl;
use PHPUnit\Framework\TestCase;
@@ -99,7 +100,7 @@ public function testNormalizeMinimal(array $expected, bool $requiresComponentVer
self::assertSame($expected, $actual);
}
- public function dptNormalizeMinimal(): \Generator
+ public function dptNormalizeMinimal(): Generator
{
yield 'mandatory Component Version' => [
[
diff --git a/tests/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizerTest.php
index b8942460..2166f181 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ComponentRepositoryNormalizerTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Serialization\JSON\Normalizers\ComponentNormalizer;
use CycloneDX\Core\Serialization\JSON\Normalizers\ComponentRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use PHPUnit\Framework\TestCase;
/**
@@ -91,7 +92,7 @@ public function testNormalizeSkipsOnThrow(): void
$componentNormalizer->expects(self::exactly(2))->method('normalize')
->withConsecutive([$component1], [$component2])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$got = $normalizer->normalize($components);
diff --git a/tests/Core/Serialization/JSON/Normalizers/DependenciesNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/DependenciesNormalizerTest.php
index 2c668663..d309650c 100644
--- a/tests/Core/Serialization/JSON/Normalizers/DependenciesNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/DependenciesNormalizerTest.php
@@ -31,6 +31,8 @@
use CycloneDX\Core\Models\Metadata;
use CycloneDX\Core\Serialization\JSON\NormalizerFactory;
use CycloneDX\Core\Serialization\JSON\Normalizers\DependenciesNormalizer;
+use Exception;
+use Generator;
use PHPUnit\Framework\TestCase;
/**
@@ -74,7 +76,7 @@ public function testNormalize(Bom $bom, array $expecteds): void
try {
self::assertEquals($expected, $actual);
continue 2; // expected was found
- } catch (\Exception $exception) {
+ } catch (Exception $exception) {
// pass
}
}
@@ -91,7 +93,7 @@ public function testNormalize(Bom $bom, array $expecteds): void
);
}
- public function dpNormalize(): \Generator
+ public function dpNormalize(): Generator
{
$dependencies = $this->createStub(BomRefRepository::class);
diff --git a/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceNormalizerTest.php
index 9451f6d3..b794a38e 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceNormalizerTest.php
@@ -28,6 +28,7 @@
use CycloneDX\Core\Serialization\JSON\NormalizerFactory;
use CycloneDX\Core\Serialization\JSON\Normalizers;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
/**
* @covers \CycloneDX\Core\Serialization\JSON\Normalizers\ExternalReferenceNormalizer
@@ -113,7 +114,7 @@ public function testThrowOnUnsupportedRefType(): void
->withConsecutive(['someType'], ['other'])
->willReturn(false);
- $this->expectException(\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('ExternalReference has unsupported type: someType');
$normalizer->normalize($extRef);
diff --git a/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceRepositoryNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
index 630959bb..12ea5226 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ExternalReferenceRepositoryNormalizerTest.php
@@ -28,6 +28,7 @@
use CycloneDX\Core\Serialization\JSON\NormalizerFactory;
use CycloneDX\Core\Serialization\JSON\Normalizers;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
/**
* @covers \CycloneDX\Core\Serialization\JSON\Normalizers\ExternalReferenceRepositoryNormalizer
@@ -100,7 +101,7 @@ public function testNormalizeSkipsOnThrow(): void
$externalReferenceNormalizer->expects(self::exactly(2))->method('normalize')
->withConsecutive([$extRef1], [$extRef2])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$actual = $normalizer->normalize($tools);
diff --git a/tests/Core/Serialization/JSON/Normalizers/LicenseNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/LicenseNormalizerTest.php
index fb162e2e..c7392380 100644
--- a/tests/Core/Serialization/JSON/Normalizers/LicenseNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/LicenseNormalizerTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Serialization\JSON\NormalizerFactory;
use CycloneDX\Core\Serialization\JSON\Normalizers\LicenseNormalizer;
use CycloneDX\Core\Spec\Spec;
+use Generator;
/**
* @covers \CycloneDX\Core\Serialization\JSON\Normalizers\LicenseNormalizer
@@ -50,7 +51,7 @@ public function testNormalize(LicenseExpression|DisjunctiveLicenseWithId|Disjunc
self::assertSame($expected, $actual);
}
- public function dpNormalize(): \Generator
+ public function dpNormalize(): Generator
{
yield 'license expression' => [
$this->createConfiguredMock(LicenseExpression::class, [
diff --git a/tests/Core/Serialization/JSON/Normalizers/MetadataNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/MetadataNormalizerTest.php
index c7921202..f48d63f1 100644
--- a/tests/Core/Serialization/JSON/Normalizers/MetadataNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/MetadataNormalizerTest.php
@@ -31,6 +31,7 @@
use CycloneDX\Core\Serialization\JSON\Normalizers\MetaDataNormalizer;
use CycloneDX\Core\Serialization\JSON\Normalizers\ToolRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use PHPUnit\Framework\TestCase;
/**
@@ -140,7 +141,7 @@ public function testNormalizeComponentUnsupported(): void
$componentFactory->expects(self::once())
->method('normalize')
->with($metaData->getComponent())
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$actual = $normalizer->normalize($metaData);
diff --git a/tests/Core/Serialization/JSON/Normalizers/ToolNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ToolNormalizerTest.php
index 6cbd1d51..358afeeb 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ToolNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ToolNormalizerTest.php
@@ -23,6 +23,7 @@
namespace CycloneDX\Tests\Core\Serialization\JSON\Normalizers;
+use BadMethodCallException;
use CycloneDX\Core\Collections\ExternalReferenceRepository;
use CycloneDX\Core\Collections\HashDictionary;
use CycloneDX\Core\Models\Tool;
@@ -131,10 +132,10 @@ public function testNormalizeMinimal(): void
$hashDictNormalizer->expects(self::never())
->method('normalize')
- ->willThrowException(new \BadMethodCallException());
+ ->willThrowException(new BadMethodCallException());
$extRefRepoNormalizer->expects(self::never())
->method('normalize')
- ->willThrowException(new \BadMethodCallException());
+ ->willThrowException(new BadMethodCallException());
$actual = $normalizer->normalize($tool);
diff --git a/tests/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizerTest.php b/tests/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizerTest.php
index dd4f99e7..b2ea27e6 100644
--- a/tests/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizerTest.php
+++ b/tests/Core/Serialization/JSON/Normalizers/ToolRepositoryNormalizerTest.php
@@ -29,6 +29,7 @@
use CycloneDX\Core\Serialization\JSON\Normalizers\ToolNormalizer;
use CycloneDX\Core\Serialization\JSON\Normalizers\ToolRepositoryNormalizer;
use CycloneDX\Core\Spec\Spec;
+use DomainException;
use PHPUnit\Framework\TestCase;
/**
@@ -99,7 +100,7 @@ public function testNormalizeSkipsOnThrow(): void
$toolNormalizer->expects(self::exactly(2))->method('normalize')
->withConsecutive([$tool1], [$tool2])
- ->willThrowException(new \DomainException());
+ ->willThrowException(new DomainException());
$actual = $normalizer->normalize($tools);
diff --git a/tests/Core/SerializeToJsonTest.php b/tests/Core/SerializeToJsonTest.php
index 664719c1..88119833 100644
--- a/tests/Core/SerializeToJsonTest.php
+++ b/tests/Core/SerializeToJsonTest.php
@@ -28,6 +28,7 @@
use CycloneDX\Core\Spec\SpecFactory;
use CycloneDX\Core\Validation\Validators\JsonStrictValidator;
use DomainException;
+use Exception;
use PHPUnit\Framework\TestCase;
/**
@@ -65,7 +66,7 @@ public function testSerialization11(): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema12(Bom $bom): void
{
@@ -90,7 +91,7 @@ public function testSchema12(Bom $bom): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema13(Bom $bom): void
{
@@ -115,7 +116,7 @@ public function testSchema13(Bom $bom): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema14(Bom $bom): void
{
diff --git a/tests/Core/SerializeToXmlTest.php b/tests/Core/SerializeToXmlTest.php
index 010d3639..f2b44f0b 100644
--- a/tests/Core/SerializeToXmlTest.php
+++ b/tests/Core/SerializeToXmlTest.php
@@ -27,6 +27,7 @@
use CycloneDX\Core\Serialization\XmlSerializer;
use CycloneDX\Core\Spec\SpecFactory;
use CycloneDX\Core\Validation\Validators\XmlValidator;
+use Exception;
use PHPUnit\Framework\TestCase;
/**
@@ -46,7 +47,7 @@ class SerializeToXmlTest extends TestCase
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema11(Bom $bom): void
{
@@ -70,7 +71,7 @@ public function testSchema11(Bom $bom): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema12(Bom $bom): void
{
@@ -94,7 +95,7 @@ public function testSchema12(Bom $bom): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema13(Bom $bom): void
{
@@ -118,7 +119,7 @@ public function testSchema13(Bom $bom): void
*
* @dataProvider \CycloneDX\Tests\_data\BomModelProvider::allBomTestData
*
- * @throws \Exception on validation failure
+ * @throws Exception on validation failure
*/
public function testSchema14(Bom $bom): void
{
diff --git a/tests/Core/Spdx/LicenseValidatorTest.php b/tests/Core/Spdx/LicenseValidatorTest.php
index c0510e27..9128d67e 100644
--- a/tests/Core/Spdx/LicenseValidatorTest.php
+++ b/tests/Core/Spdx/LicenseValidatorTest.php
@@ -26,6 +26,7 @@
use CycloneDX\Core\Spdx\LicenseValidator;
use Generator;
use PHPUnit\Framework\TestCase;
+use RuntimeException;
/**
* @covers \CycloneDX\Core\Spdx\LicenseValidator
@@ -130,7 +131,7 @@ public function testWithMalformedLicenseFile(): void
$license = $this->createPartialMock(LicenseValidator::class, ['getResourcesFile']);
$license->method('getResourcesFile')->willReturn($tempFilePath);
- $this->expectException(\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$this->expectExceptionMessageMatches('/malformed licenses file/i');
$license->loadLicenses();
@@ -144,7 +145,7 @@ public function testWithMissingLicenseFile(): void
$license = $this->createPartialMock(LicenseValidator::class, ['getResourcesFile']);
$license->method('getResourcesFile')->willReturn($tempFilePath);
- $this->expectException(\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$this->expectExceptionMessageMatches('/missing licenses file/i');
$license->loadLicenses();
diff --git a/tests/Core/Spec/SpecInstanceTestCase.php b/tests/Core/Spec/SpecInstanceTestCase.php
index ee9b8826..9bc49161 100644
--- a/tests/Core/Spec/SpecInstanceTestCase.php
+++ b/tests/Core/Spec/SpecInstanceTestCase.php
@@ -30,6 +30,7 @@
use CycloneDX\Tests\_data\BomSpecData;
use Generator;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
abstract class SpecInstanceTestCase extends TestCase
{
@@ -88,7 +89,7 @@ final public function dpIsSupportedComponentType(): Generator
{
yield 'unknown' => [uniqid('Classification', false), false];
$known = BomSpecData::getClassificationEnumForVersion($this->getSpecVersion());
- $values = (new \ReflectionClass(Classification::class))->getConstants();
+ $values = (new ReflectionClass(Classification::class))->getConstants();
foreach ($values as $value) {
yield $value => [$value, \in_array($value, $known, true)];
}
@@ -107,7 +108,7 @@ final public function dpIsSupportedHashAlgorithm(): Generator
{
yield 'unknown' => [uniqid('HashAlg', false), false];
$known = BomSpecData::getHashAlgEnumForVersion($this->getSpecVersion());
- $values = (new \ReflectionClass(HashAlgorithm::class))->getConstants();
+ $values = (new ReflectionClass(HashAlgorithm::class))->getConstants();
foreach ($values as $value) {
yield $value => [$value, \in_array($value, $known, true)];
}
@@ -141,7 +142,7 @@ final public function dpIsSupportedExternalReferenceType(): Generator
{
yield 'unknown' => [uniqid('ExternalReferenceType', false), false];
$known = BomSpecData::getExternalReferenceTypeForVersion($this->getSpecVersion());
- $values = (new \ReflectionClass(ExternalReferenceType::class))->getConstants();
+ $values = (new ReflectionClass(ExternalReferenceType::class))->getConstants();
foreach ($values as $value) {
yield $value => [$value, \in_array($value, $known, true)];
}
diff --git a/tests/Core/Validation/Errors/XmlValidationErrorTest.php b/tests/Core/Validation/Errors/XmlValidationErrorTest.php
index a6ed9983..c6799cc8 100644
--- a/tests/Core/Validation/Errors/XmlValidationErrorTest.php
+++ b/tests/Core/Validation/Errors/XmlValidationErrorTest.php
@@ -24,6 +24,7 @@
namespace CycloneDX\Tests\Core\Validation\Errors;
use CycloneDX\Core\Validation\Errors\XmlValidationError;
+use LibXMLError;
use PHPUnit\Framework\TestCase;
/**
@@ -34,7 +35,7 @@ class XmlValidationErrorTest extends TestCase
{
public function testFromLibXMLError(): void
{
- $libXmlError = new \LibXMLError();
+ $libXmlError = new LibXMLError();
$libXmlError->message = 'foo bar';
$libXmlError->level = \LIBXML_ERR_ERROR;
$libXmlError->code = 1337;
diff --git a/tests/Core/Validation/ValidationErrorTest.php b/tests/Core/Validation/ValidationErrorTest.php
index b2066a61..e5bf22cc 100644
--- a/tests/Core/Validation/ValidationErrorTest.php
+++ b/tests/Core/Validation/ValidationErrorTest.php
@@ -24,6 +24,7 @@
namespace CycloneDX\Tests\Core\Validation;
use CycloneDX\Core\Validation\ValidationError;
+use Exception;
use PHPUnit\Framework\TestCase;
/**
@@ -33,7 +34,7 @@ class ValidationErrorTest extends TestCase
{
public function testFromThrowable(): void
{
- $throwable = new \Exception('foo bar');
+ $throwable = new Exception('foo bar');
$error = ValidationError::fromThrowable($throwable);
diff --git a/tests/_data/BomModelProvider.php b/tests/_data/BomModelProvider.php
index 8c994363..57fbf534 100644
--- a/tests/_data/BomModelProvider.php
+++ b/tests/_data/BomModelProvider.php
@@ -40,6 +40,7 @@
use CycloneDX\Core\Models\Metadata;
use CycloneDX\Core\Models\Tool;
use Generator;
+use ReflectionClass;
/**
* common DataProvider.
@@ -209,7 +210,7 @@ public static function bomWithComponentPlain(): Generator
public static function bomWithComponentTypeAllKnown(): Generator
{
/** @psalm-var list $known */
- $known = array_values((new \ReflectionClass(Classification::class))->getConstants());
+ $known = array_values((new ReflectionClass(Classification::class))->getConstants());
yield from self::bomWithComponentTypes(
...$known,
...BomSpecData::getClassificationEnumForVersion('1.0'),
@@ -464,7 +465,7 @@ public static function bomWithComponentVersion(): Generator
private static function allHashAlgorithms(): array
{
/** @psalm-var list $known */
- $known = array_values((new \ReflectionClass(HashAlgorithm::class))->getConstants());
+ $known = array_values((new ReflectionClass(HashAlgorithm::class))->getConstants());
return array_values(
array_unique(
@@ -720,7 +721,7 @@ private static function bomWithMetaDataComponent(): Generator
public static function externalReferencesForAllTypes(): Generator
{
/** @psalm-var list $known */
- $known = array_values((new \ReflectionClass(ExternalReferenceType::class))->getConstants());
+ $known = array_values((new ReflectionClass(ExternalReferenceType::class))->getConstants());
$all = array_unique(
array_merge(
$known,
diff --git a/tests/_data/SpdxLicenseValidatorSingleton.php b/tests/_data/SpdxLicenseValidatorSingleton.php
index e0fd1679..fcfbc44b 100644
--- a/tests/_data/SpdxLicenseValidatorSingleton.php
+++ b/tests/_data/SpdxLicenseValidatorSingleton.php
@@ -24,13 +24,14 @@
namespace CycloneDX\Tests\_data;
use CycloneDX\Core\Spdx\LicenseValidator as SpdxLicenseValidator;
+use RuntimeException;
abstract class SpdxLicenseValidatorSingleton
{
private static ?SpdxLicenseValidator $instance = null;
/**
- * @throws \RuntimeException if loading licenses failed
+ * @throws RuntimeException if loading licenses failed
*/
public static function getInstance(): SpdxLicenseValidator
{
diff --git a/tests/_traits/DomNodeAssertionTrait.php b/tests/_traits/DomNodeAssertionTrait.php
index e0e572fa..ef07a515 100644
--- a/tests/_traits/DomNodeAssertionTrait.php
+++ b/tests/_traits/DomNodeAssertionTrait.php
@@ -25,12 +25,13 @@
use DOMDocument;
use DOMNode;
+use Exception;
use PHPUnit\Framework\Assert;
trait DomNodeAssertionTrait
{
/**
- * @throws \Exception
+ * @throws Exception
*/
final protected static function assertDomNodeEqualsDomNode(DOMNode $expected, DomNode $actual): void
{
@@ -43,7 +44,7 @@ final protected static function assertDomNodeEqualsDomNode(DOMNode $expected, Do
}
/**
- * @throws \Exception
+ * @throws Exception
*/
final protected static function assertDomNodeEqualsString(DomNode $expected, string $actual): void
{
@@ -55,7 +56,7 @@ final protected static function assertDomNodeEqualsString(DomNode $expected, str
}
/**
- * @throws \Exception
+ * @throws Exception
*/
final protected static function assertStringEqualsDomNode(string $expected, DOMNode $actual): void
{