for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the Valkyrja Framework package.
*
* (c) Melech Mizrachi <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Valkyrja\Orm\Schema;
use Throwable;
/**
* Abstract Class TransactionalMigration.
* @author Melech Mizrachi
abstract class TransactionalMigration extends Migration
{
* @inheritDoc
* @throws Throwable
public function run(): void
$orm = $this->orm;
try {
$orm->ensureTransaction();
$this->runMigration();
$orm->commit();
} catch (Throwable $exception) {
$orm->rollback();
$this->runFailure($exception);
throw $exception;
}
public function rollback(): void
$this->rollbackMigration();
$this->rollbackFailure($exception);
* Do on run failure.
* @param Throwable $exception The exception
* @return void
protected function runFailure(Throwable $exception): void
$exception
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected function runFailure(/** @scrutinizer ignore-unused */ Throwable $exception): void
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
* Do on rollback failure.
protected function rollbackFailure(Throwable $exception): void
protected function rollbackFailure(/** @scrutinizer ignore-unused */ Throwable $exception): void
* Run the migration.
abstract protected function runMigration(): void;
* Rollback the migration.
abstract protected function rollbackMigration(): void;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.