diff --git a/src/ArrayFile.php b/src/ArrayFile.php index 02fd9b3..e8be566 100644 --- a/src/ArrayFile.php +++ b/src/ArrayFile.php @@ -305,6 +305,7 @@ protected function getAstReturnIndex(array $ast): ?int switch (get_class($item)) { case Stmt\Use_::class: case Stmt\Expression::class: + case Stmt\Declare_::class: break; case Stmt\Return_::class: return $index; diff --git a/tests/ArrayFileTest.php b/tests/ArrayFileTest.php index 382f42d..8727b5b 100644 --- a/tests/ArrayFileTest.php +++ b/tests/ArrayFileTest.php @@ -845,4 +845,14 @@ public function testSingleLineCommentSubItem() str_replace("\r", '', $arrayFile->render()) ); } + + public function testStrictFileTypes() + { + $file = __DIR__ . '/fixtures/array/strict-file-types.php'; + $arrayFile = ArrayFile::open($file); + + $code = $arrayFile->render(); + + $this->assertStringContainsString('declare', $code); + } } diff --git a/tests/fixtures/array/strict-file-types.php b/tests/fixtures/array/strict-file-types.php new file mode 100644 index 0000000..8bcef5d --- /dev/null +++ b/tests/fixtures/array/strict-file-types.php @@ -0,0 +1,7 @@ + Response::HTTP_OK +];