From bdfdc9974958ba5168b99e9d339c7b081dc4d056 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Fri, 27 Oct 2023 16:11:55 +0200 Subject: [PATCH] refactor: move non-public API into a sub-namespace called `_internal`, so that its reliability is obvious. Signed-off-by: Jan Kowalleck --- HISTORY.md | 3 +++ src/Plugin.php | 6 ++---- src/{ => _internal}/MakeBom/Builder.php | 4 ++-- src/{ => _internal}/MakeBom/Command.php | 2 +- src/{ => _internal}/MakeBom/Errors/OptionError.php | 2 +- src/{ => _internal}/MakeBom/Errors/OutputError.php | 2 +- src/{ => _internal}/MakeBom/Errors/ValidationError.php | 2 +- src/{ => _internal}/MakeBom/Options.php | 2 +- src/{ => _internal}/Properties.php | 2 +- src/_internal/README.md | 5 +++++ tests/Functional/PluginTest.php | 4 ++-- tests/Integration/CommandMakeSbomAsExpectedTest.php | 6 +++--- tests/Integration/CommandMakeSbomFailsTest.php | 6 +++--- tests/Integration/CommandMakeSbomTest.php | 6 +++--- tests/Integration/CommandTestCase.php | 2 +- tests/Unit/MakeBom/BuilderTest.php | 2 +- tests/Unit/MakeBom/OptionsTest.php | 2 +- 17 files changed, 32 insertions(+), 26 deletions(-) rename src/{ => _internal}/MakeBom/Builder.php (99%) rename src/{ => _internal}/MakeBom/Command.php (99%) rename src/{ => _internal}/MakeBom/Errors/OptionError.php (94%) rename src/{ => _internal}/MakeBom/Errors/OutputError.php (93%) rename src/{ => _internal}/MakeBom/Errors/ValidationError.php (93%) rename src/{ => _internal}/MakeBom/Options.php (99%) rename src/{ => _internal}/Properties.php (97%) create mode 100644 src/_internal/README.md diff --git a/HISTORY.md b/HISTORY.md index 192cee2a..12cf5a42 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## unreleased +* Misc + * Moved non-public API into a sub-namespace called `_internal`, so that its reliability is obvious. + ## 4.2.0 - 2023-09-04 * Added diff --git a/src/Plugin.php b/src/Plugin.php index 891336c6..15632c5c 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -31,8 +31,6 @@ use Composer\Plugin\PluginInterface; /** - * @internal - * * @author jkowalleck * * @psalm-suppress UnusedClass @@ -67,9 +65,9 @@ public function getCapabilities(): array public function getCommands(): array { return [ - new MakeBom\Command( + new _internal\MakeBom\Command( 'CycloneDX:make-sbom', - new MakeBom\Options(), + new _internal\MakeBom\Options(), new Factory() ), ]; diff --git a/src/MakeBom/Builder.php b/src/_internal/MakeBom/Builder.php similarity index 99% rename from src/MakeBom/Builder.php rename to src/_internal/MakeBom/Builder.php index 8303755b..bd20fbae 100644 --- a/src/MakeBom/Builder.php +++ b/src/_internal/MakeBom/Builder.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom; +namespace CycloneDX\Composer\_internal\MakeBom; use Composer\Composer; use Composer\Package\CompletePackageInterface; @@ -31,7 +31,7 @@ use Composer\Repository\InstalledRepositoryInterface; use Composer\Repository\LockArrayRepository; use Composer\Semver\Constraint\MatchAllConstraint; -use CycloneDX\Composer\Properties; +use CycloneDX\Composer\_internal\Properties; use CycloneDX\Core\Enums; use CycloneDX\Core\Factories\LicenseFactory; use CycloneDX\Core\Models; diff --git a/src/MakeBom/Command.php b/src/_internal/MakeBom/Command.php similarity index 99% rename from src/MakeBom/Command.php rename to src/_internal/MakeBom/Command.php index 9e7061d0..8e181751 100644 --- a/src/MakeBom/Command.php +++ b/src/_internal/MakeBom/Command.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom; +namespace CycloneDX\Composer\_internal\MakeBom; use Composer\Command\BaseCommand; use Composer\Factory as ComposerFactory; diff --git a/src/MakeBom/Errors/OptionError.php b/src/_internal/MakeBom/Errors/OptionError.php similarity index 94% rename from src/MakeBom/Errors/OptionError.php rename to src/_internal/MakeBom/Errors/OptionError.php index 45b1080e..7acadbb5 100644 --- a/src/MakeBom/Errors/OptionError.php +++ b/src/_internal/MakeBom/Errors/OptionError.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom\Errors; +namespace CycloneDX\Composer\_internal\MakeBom\Errors; use DomainException; diff --git a/src/MakeBom/Errors/OutputError.php b/src/_internal/MakeBom/Errors/OutputError.php similarity index 93% rename from src/MakeBom/Errors/OutputError.php rename to src/_internal/MakeBom/Errors/OutputError.php index 2f4e81b0..13efe7a1 100644 --- a/src/MakeBom/Errors/OutputError.php +++ b/src/_internal/MakeBom/Errors/OutputError.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom\Errors; +namespace CycloneDX\Composer\_internal\MakeBom\Errors; use Exception; diff --git a/src/MakeBom/Errors/ValidationError.php b/src/_internal/MakeBom/Errors/ValidationError.php similarity index 93% rename from src/MakeBom/Errors/ValidationError.php rename to src/_internal/MakeBom/Errors/ValidationError.php index d1370b8e..d5255449 100644 --- a/src/MakeBom/Errors/ValidationError.php +++ b/src/_internal/MakeBom/Errors/ValidationError.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom\Errors; +namespace CycloneDX\Composer\_internal\MakeBom\Errors; use Exception; diff --git a/src/MakeBom/Options.php b/src/_internal/MakeBom/Options.php similarity index 99% rename from src/MakeBom/Options.php rename to src/_internal/MakeBom/Options.php index 71353619..784dd7c0 100644 --- a/src/MakeBom/Options.php +++ b/src/_internal/MakeBom/Options.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer\MakeBom; +namespace CycloneDX\Composer\_internal\MakeBom; use CycloneDX\Core\Spec\Format; use CycloneDX\Core\Spec\Version; diff --git a/src/Properties.php b/src/_internal/Properties.php similarity index 97% rename from src/Properties.php rename to src/_internal/Properties.php index b3ab49cd..5f1a138d 100644 --- a/src/Properties.php +++ b/src/_internal/Properties.php @@ -21,7 +21,7 @@ * Copyright (c) OWASP Foundation. All Rights Reserved. */ -namespace CycloneDX\Composer; +namespace CycloneDX\Composer\_internal; /** * CDX properties' names and well-known values - specific to this very tool. diff --git a/src/_internal/README.md b/src/_internal/README.md new file mode 100644 index 00000000..dbbb3ee9 --- /dev/null +++ b/src/_internal/README.md @@ -0,0 +1,5 @@ +# INTERNAL + +All in here is to be treated non-public API. +All code in here might change without any notice during version upgrades. +No backwards compatibility is guaranteed. diff --git a/tests/Functional/PluginTest.php b/tests/Functional/PluginTest.php index 897a4292..6f91631d 100644 --- a/tests/Functional/PluginTest.php +++ b/tests/Functional/PluginTest.php @@ -26,8 +26,8 @@ use Composer\Plugin\Capability\CommandProvider; use Composer\Plugin\Capable; use Composer\Plugin\PluginInterface; -use CycloneDX\Composer\MakeBom\Command; -use CycloneDX\Composer\MakeBom\Options; +use CycloneDX\Composer\_internal\MakeBom\Command; +use CycloneDX\Composer\_internal\MakeBom\Options; use CycloneDX\Composer\Plugin; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversNothing; diff --git a/tests/Integration/CommandMakeSbomAsExpectedTest.php b/tests/Integration/CommandMakeSbomAsExpectedTest.php index 7f671b4b..c0b55f90 100644 --- a/tests/Integration/CommandMakeSbomAsExpectedTest.php +++ b/tests/Integration/CommandMakeSbomAsExpectedTest.php @@ -23,9 +23,9 @@ namespace CycloneDX\Tests\Integration; -use CycloneDX\Composer\MakeBom\Builder; -use CycloneDX\Composer\MakeBom\Command; -use CycloneDX\Composer\MakeBom\Options; +use CycloneDX\Composer\_internal\MakeBom\Builder; +use CycloneDX\Composer\_internal\MakeBom\Command; +use CycloneDX\Composer\_internal\MakeBom\Options; use CycloneDX\Composer\Plugin; use Generator; use PHPUnit\Framework\Attributes\CoversClass; diff --git a/tests/Integration/CommandMakeSbomFailsTest.php b/tests/Integration/CommandMakeSbomFailsTest.php index fb31739a..91d37f32 100644 --- a/tests/Integration/CommandMakeSbomFailsTest.php +++ b/tests/Integration/CommandMakeSbomFailsTest.php @@ -23,9 +23,9 @@ namespace CycloneDX\Tests\Integration; -use CycloneDX\Composer\MakeBom\Builder; -use CycloneDX\Composer\MakeBom\Command; -use CycloneDX\Composer\MakeBom\Options; +use CycloneDX\Composer\_internal\MakeBom\Builder; +use CycloneDX\Composer\_internal\MakeBom\Command; +use CycloneDX\Composer\_internal\MakeBom\Options; use CycloneDX\Composer\Plugin; use Generator; use PHPUnit\Framework\Attributes\CoversClass; diff --git a/tests/Integration/CommandMakeSbomTest.php b/tests/Integration/CommandMakeSbomTest.php index 04268389..41445cc3 100644 --- a/tests/Integration/CommandMakeSbomTest.php +++ b/tests/Integration/CommandMakeSbomTest.php @@ -23,9 +23,9 @@ namespace CycloneDX\Tests\Integration; -use CycloneDX\Composer\MakeBom\Builder; -use CycloneDX\Composer\MakeBom\Command; -use CycloneDX\Composer\MakeBom\Options; +use CycloneDX\Composer\_internal\MakeBom\Builder; +use CycloneDX\Composer\_internal\MakeBom\Command; +use CycloneDX\Composer\_internal\MakeBom\Options; use CycloneDX\Composer\Plugin; use Generator; use PHPUnit\Framework\Attributes\CoversClass; diff --git a/tests/Integration/CommandTestCase.php b/tests/Integration/CommandTestCase.php index 5b909a61..287642c4 100644 --- a/tests/Integration/CommandTestCase.php +++ b/tests/Integration/CommandTestCase.php @@ -24,7 +24,7 @@ namespace CycloneDX\Tests\Integration; use Composer\Console\Application; -use CycloneDX\Composer\MakeBom\Command; +use CycloneDX\Composer\_internal\MakeBom\Command; use PHPUnit\Framework\TestCase; abstract class CommandTestCase extends TestCase diff --git a/tests/Unit/MakeBom/BuilderTest.php b/tests/Unit/MakeBom/BuilderTest.php index 84d52e01..9ec29d52 100644 --- a/tests/Unit/MakeBom/BuilderTest.php +++ b/tests/Unit/MakeBom/BuilderTest.php @@ -25,7 +25,7 @@ use Composer\Factory as ComposerFactory; use Composer\IO\NullIO; -use CycloneDX\Composer\MakeBom\Builder; +use CycloneDX\Composer\_internal\MakeBom\Builder; use CycloneDX\Composer\Plugin; use CycloneDX\Core\Enums; use CycloneDX\Core\Models; diff --git a/tests/Unit/MakeBom/OptionsTest.php b/tests/Unit/MakeBom/OptionsTest.php index 1f54ea43..625a8351 100644 --- a/tests/Unit/MakeBom/OptionsTest.php +++ b/tests/Unit/MakeBom/OptionsTest.php @@ -23,7 +23,7 @@ namespace CycloneDX\Tests\Unit\MakeBom; -use CycloneDX\Composer\MakeBom\Options; +use CycloneDX\Composer\_internal\MakeBom\Options; use CycloneDX\Core\Spec\Format; use CycloneDX\Core\Spec\Version; use DomainException;