Conversation
Benchmark ResultsComparison of Open to see the benchmark results
Generated by phpbench against commit 72fe86a |
|
Aidan's not the only one who loves the commits :D |
|
Todo: add Rectors |
| // Transform $kernel->discoveryLocations to $kernel->registry->locations | ||
| return new PropertyFetch( | ||
| new PropertyFetch($node->var, 'registry'), |
There was a problem hiding this comment.
| // Transform $kernel->discoveryLocations to $kernel->registry->locations | |
| return new PropertyFetch( | |
| new PropertyFetch($node->var, 'registry'), | |
| // Transform $kernel->discoveryLocations to $kernel->discoveryConfig->locations | |
| return new PropertyFetch( | |
| new PropertyFetch($node->var, 'discoveryConfig'), |
| { | ||
| $this->rector | ||
| ->runFixture(__DIR__ . '/Fixtures/KernelDiscoveryLocations.input.php') | ||
| ->assertContains('$this->kernel->registry->locations') |
There was a problem hiding this comment.
| ->assertContains('$this->kernel->registry->locations') | |
| ->assertContains('$this->kernel->discoveryConfig->locations') |
| { | ||
| $this->rector | ||
| ->runFixture(__DIR__ . '/Fixtures/KernelDiscoveryClasses.input.php') | ||
| ->assertContains('$this->kernel->registry->classes') |
There was a problem hiding this comment.
| ->assertContains('$this->kernel->registry->classes') | |
| ->assertContains('$this->kernel->discoveryConfig->classes') |
| private function resolveDiscovery(string $discoveryClass): Discovery | ||
| { | ||
| /** @var Discovery $discovery */ | ||
| $discovery = $this->container->get($discoveryClass); |
There was a problem hiding this comment.
Perhaps we could do a check with $this->container->has($discoveryClass) and instantiate a new $discoveryClass if the check returns with false. This would add support for containers with no autowiring.
| public bool $discoveryCache; | ||
|
|
There was a problem hiding this comment.
| public bool $discoveryCache; |
Dead code.
| 'Tempest\Core\DiscoveryConfig' => 'Tempest\Discovery\DiscoveryConfig', | ||
| 'Tempest\Core\CouldNotStoreDiscoveryCache' => 'Tempest\Discovery\CouldNotStoreDiscoveryCache', |
There was a problem hiding this comment.
| 'Tempest\Core\DiscoveryConfig' => 'Tempest\Discovery\DiscoveryConfig', | |
| 'Tempest\Core\CouldNotStoreDiscoveryCache' => 'Tempest\Discovery\CouldNotStoreDiscoveryCache', | |
| 'Tempest\Core\DiscoveryConfig' => 'Tempest\Discovery\DiscoveryConfig', | |
| 'Tempest\Core\CouldNotStoreDiscoveryCache' => 'Tempest\Discovery\CouldNotStoreDiscoveryCache', | |
| 'Tempest\Core\DiscoveryCacheInitializer' => 'Tempest\Discovery\DiscoveryCacheInitializer', | |
| 'Tempest\Core\DiscoveryDiscovery' => 'Tempest\Discovery\DiscoveryDiscovery', |
| @@ -78,10 +79,11 @@ public function resolveKernel(): Kernel | |||
| { | |||
| $container = new GenericContainer(); | |||
| $container->singleton(Container::class, $container); | |||
There was a problem hiding this comment.
| $container->singleton(Container::class, $container); |
new GenericContainer(); already registers Container::class (and a couple others) as singletons.
|
|
||
| ### Manually specify discovery locations | ||
|
|
||
| `DiscoveryConfig::autoload()` will scan a given root path and autmatically determine discovery locations by analyzing the composer.json file in that path. If you prefer another way of defining locations to scan, you can manually provide them via `DiscoveryConfig`: |
There was a problem hiding this comment.
| `DiscoveryConfig::autoload()` will scan a given root path and autmatically determine discovery locations by analyzing the composer.json file in that path. If you prefer another way of defining locations to scan, you can manually provide them via `DiscoveryConfig`: | |
| `DiscoveryConfig::autoload()` will scan a given root path and automatically determine discovery locations by analyzing the composer.json file in that path. If you prefer another way of defining locations to scan, you can manually provide them via `DiscoveryConfig`: |
| public array $discoveryLocations; | ||
|
|
||
| public array $discoveryClasses; | ||
|
|
There was a problem hiding this comment.
discoveryLocations and discoveryClasses got removed from Kernel, dead code.
| $this->discoveryLocations = $kernel->discoveryConfig->locations; | ||
| $this->discoveryClasses = $kernel->discoveryConfig->classes; |
There was a problem hiding this comment.
| $this->discoveryLocations = $kernel->discoveryConfig->locations; | |
| $this->discoveryClasses = $kernel->discoveryConfig->classes; |
See #2041 (comment)
| use Tempest\Container\Container; | ||
| use Tempest\Container\Initializer; | ||
| use Tempest\Container\Singleton; |
There was a problem hiding this comment.
We still depend on container here, is that okay? container is only pulled in by require-dev.
|
There are also a couple |
Upgrade Guide
Install Rector if you haven't yet:
Next, update Tempest; it's important to add the
--no-scriptsflag to prevent any errors from being thrown during the update.Then configure Rector to upgrade to Tempest 3.4:
Next, run Rector:
Finally: make sure all discovery caches are regenerated:
Breaking changes:
Tempest\Core\DiscoveryCachemoved toTempest\Discovery\DiscoveryCacheTempest\Core\DiscoveryCacheStrategymoved toTempest\Discovery\DiscoveryCacheStrategyTempest\Core\Composermoved toTempest\Discovery\ComposerTempest\Core\ComposerJsonCouldNotBeLocatedmoved toTempest\Discovery\ComposerJsonCouldNotBeLocatedTempest\Core\DiscoveryCachingStrategyWasChangedmoved toTempest\Discovery\DiscoveryCachingStrategyWasChangedTempest\Core\DiscoveryConfigmoved toTempest\Discovery\DiscoveryConfigKernel::$discoveryLocationsandKernel::$discoveryClassesproperty hooksFrameworkKernel::$discoveryLocationsandFrameworkKernel::$discoveryClassespropertiesNon-breaking changes:
Tempest\Core\LoadDiscoveryClassesmoved toTempest\Discovery\BootDiscoveryTempest\Core\LoadDiscoveryLocationsmoved toTempest\Discovery\AutoloadDiscoveryLocationsTempest\Core\DiscoveryCacheInitializermoved toTempest\Discovery\DiscoveryCacheInitializerTempest\Core\DiscoveryDiscoverymoved toTempest\Discovery\DiscoveryDiscoveryDiscovery as a standalone package
tempest/discoverycan be used as a standalone package in any application. All it needs is a PSR-11 compliant container.Start by requiring
tempest/discovery:composer require tempest/discoveryNext, you can boot discovery:
Whenever this action is run, discovery will find all discovery classes, and run them against all registered locations.
Manually specify discovery locations
DiscoveryConfig::autoload()will scan a given root path and autmatically determine discovery locations by analyzing the composer.json file in that path. If you prefer another way of defining locations to scan, you can manually provide them viaDiscoveryConfig:Config and caching
You can pass config and cache parameters into the
BootDiscoveryaction, with these you can exclude files and classes from discovery, as well as config caching behavior: