mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-02 05:26:43 +00:00
feature #2961 Remove obsolete Error features (fabpot)
This PR was merged into the 3.x branch.
Discussion
----------
Remove obsolete Error features
Commits
-------
c4178fd2 removed obsolete Error features
This commit is contained in:
+6
-9
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user