deprecated passing a 4th and 5th arguments to the Sandbox exception classes

This commit is contained in:
Fabien Potencier
2019-04-16 18:11:16 +02:00
parent d15d794edf
commit 5312086b2d
6 changed files with 41 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
* 2.8.1 (2019-XX-XX)
* deprecated passing a 4th and 5th arguments to the Sandbox exception classes
* deprecated Node::setTemplateName() in favor of Node::setSourceContext()
* 2.8.0 (2019-04-16)
@@ -15,6 +15,8 @@ namespace Twig\Sandbox;
* Exception thrown when a not allowed filter is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*
* @final
*/
class SecurityNotAllowedFilterError extends SecurityError
{
@@ -22,6 +24,12 @@ class SecurityNotAllowedFilterError extends SecurityError
public function __construct(string $message, string $functionName, int $lineno = -1, string $filename = null, \Exception $previous = null)
{
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);
$this->filterName = $functionName;
}
@@ -15,6 +15,8 @@ namespace Twig\Sandbox;
* Exception thrown when a not allowed function is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*
* @final
*/
class SecurityNotAllowedFunctionError extends SecurityError
{
@@ -22,6 +24,12 @@ class SecurityNotAllowedFunctionError extends SecurityError
public function __construct(string $message, string $functionName, int $lineno = -1, string $filename = null, \Exception $previous = null)
{
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);
$this->functionName = $functionName;
}
@@ -15,6 +15,8 @@ namespace Twig\Sandbox;
* Exception thrown when a not allowed class method is used in a template.
*
* @author Kit Burton-Senior <mail@kitbs.com>
*
* @final
*/
class SecurityNotAllowedMethodError extends SecurityError
{
@@ -23,6 +25,12 @@ class SecurityNotAllowedMethodError extends SecurityError
public function __construct(string $message, string $className, string $methodName, int $lineno = -1, string $filename = null, \Exception $previous = null)
{
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);
$this->className = $className;
$this->methodName = $methodName;
@@ -15,6 +15,8 @@ namespace Twig\Sandbox;
* Exception thrown when a not allowed class property is used in a template.
*
* @author Kit Burton-Senior <mail@kitbs.com>
*
* @final
*/
class SecurityNotAllowedPropertyError extends SecurityError
{
@@ -23,6 +25,12 @@ class SecurityNotAllowedPropertyError extends SecurityError
public function __construct(string $message, string $className, string $propertyName, int $lineno = -1, string $filename = null, \Exception $previous = null)
{
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);
$this->className = $className;
$this->propertyName = $propertyName;
@@ -15,6 +15,8 @@ namespace Twig\Sandbox;
* Exception thrown when a not allowed tag is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*
* @final
*/
class SecurityNotAllowedTagError extends SecurityError
{
@@ -22,6 +24,12 @@ class SecurityNotAllowedTagError extends SecurityError
public function __construct(string $message, string $tagName, int $lineno = -1, string $filename = null, \Exception $previous = null)
{
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);
$this->tagName = $tagName;
}