From 1b64fef7bab72d4ec39b63ea40b340aa81a4cda0 Mon Sep 17 00:00:00 2001 From: faissaloux Date: Wed, 21 Feb 2024 16:58:40 +0100 Subject: [PATCH] fix toUseStrictTypes --- src/Expectation.php | 2 +- src/Expectations/OppositeExpectation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index a410cf1d..fcc0b7e9 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -441,7 +441,7 @@ final class Expectation { return Targeted::make( $this, - fn (ObjectDescription $object): bool => str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'), + fn (ObjectDescription $object): bool => (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)), 'to use strict types', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'original, - fn (ObjectDescription $object): bool => ! str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'), + fn (ObjectDescription $object): bool => ! preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)), 'not to use strict types', FileLineFinder::where(fn (string $line): bool => str_contains($line, '