diff --git a/src/Error/Error.php b/src/Error/Error.php index 0487d7502..2b3642292 100644 --- a/src/Error/Error.php +++ b/src/Error/Error.php @@ -56,20 +56,17 @@ class Error extends \Exception * * By default, automatic guessing is enabled. * - * @param string $message The error message - * @param int $lineno The template line where the error occurred - * @param Source|string|null $source The source context where the error occurred - * @param \Exception $previous The previous exception + * @param string $message The error message + * @param int $lineno The template line where the error occurred + * @param Source|null $source The source context where the error occurred + * @param \Exception $previous The previous exception */ - public function __construct(string $message, int $lineno = -1, $source = null, \Exception $previous = null) + public function __construct(string $message, int $lineno = -1, Source $source = null, \Exception $previous = null) { parent::__construct('', 0, $previous); if (null === $source) { $name = null; - } elseif (!$source instanceof Source && !$source instanceof \Twig_Source) { - @trigger_error(sprintf('Passing a string as a source to %s is deprecated since Twig 2.6.1; pass a Twig\Source instance instead.', __CLASS__), E_USER_DEPRECATED); - $name = $source; } else { $name = $source->getName(); $this->sourceCode = $source->getCode(); @@ -204,7 +201,7 @@ class Error extends \Exception $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); foreach ($backtrace as $trace) { - if (isset($trace['object']) && $trace['object'] instanceof Template && 'Twig_Template' !== \get_class($trace['object'])) { + if (isset($trace['object']) && $trace['object'] instanceof Template) { $currentClass = \get_class($trace['object']); $isEmbedContainer = 0 === strpos($templateClass, $currentClass); if (null === $this->name || ($this->name == $trace['object']->getTemplateName() && !$isEmbedContainer)) { diff --git a/src/Sandbox/SecurityNotAllowedFilterError.php b/src/Sandbox/SecurityNotAllowedFilterError.php index 04561c2a7..538a657aa 100644 --- a/src/Sandbox/SecurityNotAllowedFilterError.php +++ b/src/Sandbox/SecurityNotAllowedFilterError.php @@ -22,18 +22,9 @@ class SecurityNotAllowedFilterError extends SecurityError { private $filterName; - public function __construct(string $message, string $functionName, int $lineno = -1, string $filename = null, \Exception $previous = null) + public function __construct(string $message, string $functionName) { - if (-1 !== $lineno) { - @trigger_error(sprintf('Passing $lineno as a 3th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $filename) { - @trigger_error(sprintf('Passing $filename as a 4th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $previous) { - @trigger_error(sprintf('Passing $previous as a 5th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - parent::__construct($message, $lineno, $filename, $previous); + parent::__construct($message); $this->filterName = $functionName; } diff --git a/src/Sandbox/SecurityNotAllowedFunctionError.php b/src/Sandbox/SecurityNotAllowedFunctionError.php index b9428f531..2f3e3d23e 100644 --- a/src/Sandbox/SecurityNotAllowedFunctionError.php +++ b/src/Sandbox/SecurityNotAllowedFunctionError.php @@ -22,18 +22,9 @@ class SecurityNotAllowedFunctionError extends SecurityError { private $functionName; - public function __construct(string $message, string $functionName, int $lineno = -1, string $filename = null, \Exception $previous = null) + public function __construct(string $message, string $functionName) { - if (-1 !== $lineno) { - @trigger_error(sprintf('Passing $lineno as a 3th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $filename) { - @trigger_error(sprintf('Passing $filename as a 4th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $previous) { - @trigger_error(sprintf('Passing $previous as a 5th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - parent::__construct($message, $lineno, $filename, $previous); + parent::__construct($message); $this->functionName = $functionName; } diff --git a/src/Sandbox/SecurityNotAllowedMethodError.php b/src/Sandbox/SecurityNotAllowedMethodError.php index ebbc40451..52c13b88d 100644 --- a/src/Sandbox/SecurityNotAllowedMethodError.php +++ b/src/Sandbox/SecurityNotAllowedMethodError.php @@ -23,18 +23,9 @@ class SecurityNotAllowedMethodError extends SecurityError private $className; private $methodName; - public function __construct(string $message, string $className, string $methodName, int $lineno = -1, string $filename = null, \Exception $previous = null) + public function __construct(string $message, string $className, string $methodName) { - if (-1 !== $lineno) { - @trigger_error(sprintf('Passing $lineno as a 3th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $filename) { - @trigger_error(sprintf('Passing $filename as a 4th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $previous) { - @trigger_error(sprintf('Passing $previous as a 5th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - parent::__construct($message, $lineno, $filename, $previous); + parent::__construct($message); $this->className = $className; $this->methodName = $methodName; } diff --git a/src/Sandbox/SecurityNotAllowedPropertyError.php b/src/Sandbox/SecurityNotAllowedPropertyError.php index 4c1c67e76..a523810ab 100644 --- a/src/Sandbox/SecurityNotAllowedPropertyError.php +++ b/src/Sandbox/SecurityNotAllowedPropertyError.php @@ -23,18 +23,9 @@ class SecurityNotAllowedPropertyError extends SecurityError private $className; private $propertyName; - public function __construct(string $message, string $className, string $propertyName, int $lineno = -1, string $filename = null, \Exception $previous = null) + public function __construct(string $message, string $className, string $propertyName) { - if (-1 !== $lineno) { - @trigger_error(sprintf('Passing $lineno as a 3th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $filename) { - @trigger_error(sprintf('Passing $filename as a 4th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $previous) { - @trigger_error(sprintf('Passing $previous as a 5th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - parent::__construct($message, $lineno, $filename, $previous); + parent::__construct($message); $this->className = $className; $this->propertyName = $propertyName; } diff --git a/src/Sandbox/SecurityNotAllowedTagError.php b/src/Sandbox/SecurityNotAllowedTagError.php index c19378acf..1e7c2e72a 100644 --- a/src/Sandbox/SecurityNotAllowedTagError.php +++ b/src/Sandbox/SecurityNotAllowedTagError.php @@ -22,18 +22,9 @@ class SecurityNotAllowedTagError extends SecurityError { private $tagName; - public function __construct(string $message, string $tagName, int $lineno = -1, string $filename = null, \Exception $previous = null) + public function __construct(string $message, string $tagName) { - if (-1 !== $lineno) { - @trigger_error(sprintf('Passing $lineno as a 3th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $filename) { - @trigger_error(sprintf('Passing $filename as a 4th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - if (null !== $previous) { - @trigger_error(sprintf('Passing $previous as a 5th argument of the %s constructor is deprecated since Twig 2.8.1.', __CLASS__), E_USER_DEPRECATED); - } - parent::__construct($message, $lineno, $filename, $previous); + parent::__construct($message); $this->tagName = $tagName; }