Skip to content

Commit

Permalink
Add support for using strict types in configs (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel authored Sep 18, 2024
1 parent aec0791 commit 6866e60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ArrayFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions tests/ArrayFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/array/strict-file-types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

return [
'foo' => Response::HTTP_OK
];

0 comments on commit 6866e60

Please sign in to comment.