From 55bee8ea80734186df6eb6bb769cc530bbee2b86 Mon Sep 17 00:00:00 2001 From: Scott Dutton Date: Wed, 9 Aug 2017 13:05:16 +0100 Subject: [PATCH 1/2] Use the longest string for the haystack in phpmnd --- src/FileMatchers/EndsWith.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FileMatchers/EndsWith.php b/src/FileMatchers/EndsWith.php index 0d85174..4f26882 100644 --- a/src/FileMatchers/EndsWith.php +++ b/src/FileMatchers/EndsWith.php @@ -34,6 +34,9 @@ public function match($needle, array $haystack) protected function fileEndsWith($haystack, $needle) { $length = strlen($needle); + if (strlen($haystack) < $length) { + return $this->fileEndsWith($needle, $haystack); + } return (substr($haystack, -$length) === $needle); } From a3762f9be1483e468713a2b4a740797218608e62 Mon Sep 17 00:00:00 2001 From: Scott Dutton Date: Wed, 9 Aug 2017 13:13:24 +0100 Subject: [PATCH 2/2] Commit new unit test too --- tests/PhpMndTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpMndTest.php b/tests/PhpMndTest.php index 202c81d..9c632f3 100644 --- a/tests/PhpMndTest.php +++ b/tests/PhpMndTest.php @@ -8,7 +8,7 @@ class PhpMndTest extends TestCase { public function setUp() { - $file = __DIR__ . "/fixtures/phpmnd.txt"; + $file = __DIR__ . "/fixtures/phpmnd.txt"; $this->mnd = new PhpMndLoader($file); $this->assertInstanceOf(PhpMndLoader::class, $this->mnd);