From ff5605a981fdb7fcde358109d541ccbef3891715 Mon Sep 17 00:00:00 2001 From: malc0mn Date: Sun, 8 Oct 2017 11:41:49 +0200 Subject: [PATCH 1/2] Prevent possible 'Uninitialized string offset: x' errors. --- src/Text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Text.php b/src/Text.php index 50c7e28..4cd05b7 100644 --- a/src/Text.php +++ b/src/Text.php @@ -54,7 +54,7 @@ public function getChar($position = self::CURRENT_POSITION) throw new Exception('Position is not int. ' . gettype($position)); } - if ($this->eof()) { + if ($this->eof($position)) { throw new Exception('Index out of range. Position: ' . $position . '.'); } From c660bec138635a0f23efacaf0277cecef51a297b Mon Sep 17 00:00:00 2001 From: malc0mn Date: Sun, 8 Oct 2017 11:45:21 +0200 Subject: [PATCH 2/2] Added test for the 'Uninitialized string offset: x' fix. --- tests/TextTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/TextTest.php b/tests/TextTest.php index 6873839..5bc502a 100644 --- a/tests/TextTest.php +++ b/tests/TextTest.php @@ -13,6 +13,15 @@ class TextTest extends \PHPUnit_Framework_TestCase { + /** + * @expectedException \RomanPitak\Nginx\Config\Exception + */ + public function testEolErr() + { + $text = new Text('This is a line for testing...'); + $text->eol(30); + } + /** * @expectedException \RomanPitak\Nginx\Config\Exception */