From 3d9c5a74432b8c214a69568eee4fd8425094cd7e Mon Sep 17 00:00:00 2001 From: Ernestas Kvedaras Date: Tue, 1 Mar 2022 16:30:41 +0100 Subject: [PATCH] Add support for anonymous migrations --- src/Handlers/Eloquent/Schema/SchemaAggregator.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Handlers/Eloquent/Schema/SchemaAggregator.php b/src/Handlers/Eloquent/Schema/SchemaAggregator.php index 5899656..6649dd8 100644 --- a/src/Handlers/Eloquent/Schema/SchemaAggregator.php +++ b/src/Handlers/Eloquent/Schema/SchemaAggregator.php @@ -23,6 +23,12 @@ class SchemaAggregator foreach ($stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\Class_) { $this->addClassStatements($stmt->stmts); + } elseif ( + $stmt instanceof PhpParser\Node\Stmt\Return_ && + $stmt->expr instanceof PhpParser\Node\Expr\New_ && + $stmt->expr->class instanceof PhpParser\Node\Stmt\Class_ + ) { + $this->addClassStatements($stmt->expr->class->stmts); } } }