Skip to content

Commit

Permalink
Remove nullable properties and assertions, use isset/unset and langua…
Browse files Browse the repository at this point in the history
…ge constraints (#171)
  • Loading branch information
ben-challis authored Sep 1, 2023
1 parent 3218c6a commit 39754aa
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Migration/LazyLoadingMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
final class LazyLoadingMigrations implements Migrations
{
/**
* @var \Closure(): void|null
* @var \Closure(): void
*/
private ?\Closure $loader;
private \Closure $loader;

private ?Migrations $migrations = null;
private Migrations $migrations;

/**
* @param \Closure(): Migrations $loader
Expand All @@ -26,40 +26,34 @@ public function __construct(\Closure $loader)
{
$this->loader = function () use ($loader): void {
$this->migrations = $loader->bindTo(null)();
$this->loader = null;
unset($this->loader);
};
}

public function getAll(): VectorInterface
{
if ($this->loader !== null) {
if (isset($this->loader)) {
($this->loader)();
}

\assert($this->migrations instanceof Migrations);

return $this->migrations->getAll();
}

public function get(Version $version): Migration
{
if ($this->loader !== null) {
if (isset($this->loader)) {
($this->loader)();
}

\assert($this->migrations instanceof Migrations);

return $this->migrations->get($version);
}

public function changeState(Version $version, State $state): Migration
{
if ($this->loader !== null) {
if (isset($this->loader)) {
($this->loader)();
}

\assert($this->migrations instanceof Migrations);

return $this->migrations->changeState($version, $state);
}
}

0 comments on commit 39754aa

Please sign in to comment.