Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The discovery benchmarks measure memory as PHP allocates it, from a reset peak: they read 2 MB whatever the load
- `#[WpRestRoute\Method]` no longer registers its route: `WpRestRouteRegistrar`, in the WpRest module, does, with the same arguments, permissions and request injection. Default slugs, meta keys and command names come from `Pollora\Attributes\Support\Naming`, which gives the same results as `Str::kebab()` and `Str::snake()`; `Pollora\Support\Slug` uses it
- The WpRest module no longer reaches for Laravel's application, the first step towards `pollora/wp-rest`: custom `HandlesAttributes` attributes receive the PSR-11 container given to `WpRestDiscovery`, and `WpRestAttributableWrapper` takes the controller instance instead of building it. An architecture test keeps the module to the attributes, discovery, PSR contracts and WordPress
- The WpCli module no longer reaches for Laravel's application, the first step towards `pollora/wp-cli`: `WpCliDiscovery` builds commands through the discovery's instance pool instead of `resolve()`. Its service provider and `pollora:make:wp-cli` stay in the framework; an architecture test keeps the rest to the attributes, discovery, PSR logging and WP-CLI

### Deprecated
- `DiscoveryCacheInterface` and `LaravelDiscoveryCache`, removed in 15.0: nothing reads this cache, scans are cached by the Spatie driver given to `DiscoveryCacheManager`
Expand Down
9 changes: 2 additions & 7 deletions src/WpCli/Infrastructure/Services/WpCliDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,8 @@ private function processWpCliCommand(string $className, ?ReflectionCacheInterfac
*/
private function getCommandInstance(string $className): object
{
// Use instance pool if available, otherwise fallback to local cache
return $this->getInstanceFromPool($className, function () use ($className): object {
// On laisse le container gérer la construction
$this->commandInstances[$className] ??= resolve($className);

return $this->commandInstances[$className];
});
// The instance pool builds it with its dependencies; one instance per class
return $this->commandInstances[$className] ??= $this->getInstanceFromPool($className);
}

/**
Expand Down
23 changes: 23 additions & 0 deletions tests/Unit/WpCli/PackageBoundaryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use Pollora\WpCli\Infrastructure\Providers\WpCliServiceProvider;
use Pollora\WpCli\UI\Console\WpCliMakeCommand;

/**
* The WpCli module becomes pollora/wp-cli, which runs without Laravel's
* application. Its service provider and the pollora:make:wp-cli generator stay
* in the framework; the rest uses the attributes, discovery, PSR logging and
* WP-CLI.
*/
arch('the WpCli module stays free of the Laravel application')
->expect('Pollora\WpCli')
->toOnlyUse([
'Pollora\WpCli',
'Pollora\Attributes',
'Pollora\Discovery',
'Psr\Log',
'Spatie\StructureDiscoverer',
])
->ignoring([WpCliServiceProvider::class, WpCliMakeCommand::class, 'WP_CLI', 'WP_CLI_Command']);
Loading