diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 661950ae..7cb1f987 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -4,21 +4,10 @@ namespace Smarty; /** * Smarty error handler to fix new error levels in PHP8 for backwards compatibility - * - - * @author Simon Wisselink - * */ class ErrorHandler { - - /** - * Allows {$foo} where foo is unset. - * @var bool - */ - public $allowUndefinedVars = true; - /** * Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset. * @var bool @@ -74,14 +63,6 @@ class ErrorHandler */ public function handleError($errno, $errstr, $errfile, $errline, $errcontext = []) { - - if ($this->allowUndefinedVars && preg_match( - '/^(Attempt to read property "value" on null|Trying to get property (\'value\' )?of non-object)/', - $errstr - )) { - return; // suppresses this error - } - if ($this->allowUndefinedArrayKeys && preg_match( '/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/', $errstr diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php index a1611b46..e1afc1ea 100644 --- a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php @@ -65,6 +65,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty */ public function testError() { + $this->smarty->error_unassigned = true; $this->expectException(PHPUnit\Framework\Error\Error::class); $this->expectExceptionMessage('Undefined '); $e1 = error_reporting(); @@ -131,9 +132,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty $this->assertEquals("ab", $this->smarty->fetch($tpl)); } - /** - * @group 20221124 - */ + public function testDereferenceOnNull() { $this->smarty->setErrorReporting(E_ALL & ~E_WARNING & ~E_NOTICE); $this->smarty->muteUndefinedOrNullWarnings(); @@ -142,9 +141,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty $this->assertEquals("ab", $this->smarty->fetch($tpl)); } - /** - * @group 20221124 - */ + public function testDereferenceOnBool() { $this->smarty->setErrorReporting(E_ALL & ~E_NOTICE); $this->smarty->muteUndefinedOrNullWarnings(); @@ -153,9 +150,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty $this->assertEquals("ab", $this->smarty->fetch($tpl)); } - /** - * @group 20221124 - */ + public function testDereferenceOnString() { $this->smarty->setErrorReporting(E_ALL & ~E_NOTICE); $this->smarty->muteUndefinedOrNullWarnings();