Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../lib/twig/src/Error
File: Error.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of Twig.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
namespace WPML\Core\Twig\Error;
[10] Fix | Delete
[11] Fix | Delete
use WPML\Core\Twig\Source;
[12] Fix | Delete
use WPML\Core\Twig\Template;
[13] Fix | Delete
/**
[14] Fix | Delete
* Twig base exception.
[15] Fix | Delete
*
[16] Fix | Delete
* This exception class and its children must only be used when
[17] Fix | Delete
* an error occurs during the loading of a template, when a syntax error
[18] Fix | Delete
* is detected in a template, or when rendering a template. Other
[19] Fix | Delete
* errors must use regular PHP exception classes (like when the template
[20] Fix | Delete
* cache directory is not writable for instance).
[21] Fix | Delete
*
[22] Fix | Delete
* To help debugging template issues, this class tracks the original template
[23] Fix | Delete
* name and line where the error occurred.
[24] Fix | Delete
*
[25] Fix | Delete
* Whenever possible, you must set these information (original template name
[26] Fix | Delete
* and line number) yourself by passing them to the constructor. If some or all
[27] Fix | Delete
* these information are not available from where you throw the exception, then
[28] Fix | Delete
* this class will guess them automatically (when the line number is set to -1
[29] Fix | Delete
* and/or the name is set to null). As this is a costly operation, this
[30] Fix | Delete
* can be disabled by passing false for both the name and the line number
[31] Fix | Delete
* when creating a new instance of this class.
[32] Fix | Delete
*
[33] Fix | Delete
* @author Fabien Potencier <fabien@symfony.com>
[34] Fix | Delete
*/
[35] Fix | Delete
class Error extends \Exception
[36] Fix | Delete
{
[37] Fix | Delete
protected $lineno;
[38] Fix | Delete
// to be renamed to name in 2.0
[39] Fix | Delete
protected $filename;
[40] Fix | Delete
protected $rawMessage;
[41] Fix | Delete
private $sourcePath;
[42] Fix | Delete
private $sourceCode;
[43] Fix | Delete
/**
[44] Fix | Delete
* Constructor.
[45] Fix | Delete
*
[46] Fix | Delete
* Set the line number to -1 to enable its automatic guessing.
[47] Fix | Delete
* Set the name to null to enable its automatic guessing.
[48] Fix | Delete
*
[49] Fix | Delete
* @param string $message The error message
[50] Fix | Delete
* @param int $lineno The template line where the error occurred
[51] Fix | Delete
* @param Source|string|null $source The source context where the error occurred
[52] Fix | Delete
* @param \Exception $previous The previous exception
[53] Fix | Delete
*/
[54] Fix | Delete
public function __construct($message, $lineno = -1, $source = null, \Exception $previous = null)
[55] Fix | Delete
{
[56] Fix | Delete
if (null === $source) {
[57] Fix | Delete
$name = null;
[58] Fix | Delete
} elseif (!$source instanceof \WPML\Core\Twig\Source) {
[59] Fix | Delete
// for compat with the Twig C ext., passing the template name as string is accepted
[60] Fix | Delete
$name = $source;
[61] Fix | Delete
} else {
[62] Fix | Delete
$name = $source->getName();
[63] Fix | Delete
$this->sourceCode = $source->getCode();
[64] Fix | Delete
$this->sourcePath = $source->getPath();
[65] Fix | Delete
}
[66] Fix | Delete
parent::__construct('', 0, $previous);
[67] Fix | Delete
$this->lineno = $lineno;
[68] Fix | Delete
$this->filename = $name;
[69] Fix | Delete
$this->rawMessage = $message;
[70] Fix | Delete
$this->updateRepr();
[71] Fix | Delete
}
[72] Fix | Delete
/**
[73] Fix | Delete
* Gets the raw message.
[74] Fix | Delete
*
[75] Fix | Delete
* @return string The raw message
[76] Fix | Delete
*/
[77] Fix | Delete
public function getRawMessage()
[78] Fix | Delete
{
[79] Fix | Delete
return $this->rawMessage;
[80] Fix | Delete
}
[81] Fix | Delete
/**
[82] Fix | Delete
* Gets the logical name where the error occurred.
[83] Fix | Delete
*
[84] Fix | Delete
* @return string The name
[85] Fix | Delete
*
[86] Fix | Delete
* @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead.
[87] Fix | Delete
*/
[88] Fix | Delete
public function getTemplateFile()
[89] Fix | Delete
{
[90] Fix | Delete
@\trigger_error(\sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[91] Fix | Delete
return $this->filename;
[92] Fix | Delete
}
[93] Fix | Delete
/**
[94] Fix | Delete
* Sets the logical name where the error occurred.
[95] Fix | Delete
*
[96] Fix | Delete
* @param string $name The name
[97] Fix | Delete
*
[98] Fix | Delete
* @deprecated since 1.27 (to be removed in 2.0). Use setSourceContext() instead.
[99] Fix | Delete
*/
[100] Fix | Delete
public function setTemplateFile($name)
[101] Fix | Delete
{
[102] Fix | Delete
@\trigger_error(\sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[103] Fix | Delete
$this->filename = $name;
[104] Fix | Delete
$this->updateRepr();
[105] Fix | Delete
}
[106] Fix | Delete
/**
[107] Fix | Delete
* Gets the logical name where the error occurred.
[108] Fix | Delete
*
[109] Fix | Delete
* @return string The name
[110] Fix | Delete
*
[111] Fix | Delete
* @deprecated since 1.29 (to be removed in 2.0). Use getSourceContext() instead.
[112] Fix | Delete
*/
[113] Fix | Delete
public function getTemplateName()
[114] Fix | Delete
{
[115] Fix | Delete
@\trigger_error(\sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[116] Fix | Delete
return $this->filename;
[117] Fix | Delete
}
[118] Fix | Delete
/**
[119] Fix | Delete
* Sets the logical name where the error occurred.
[120] Fix | Delete
*
[121] Fix | Delete
* @param string $name The name
[122] Fix | Delete
*
[123] Fix | Delete
* @deprecated since 1.29 (to be removed in 2.0). Use setSourceContext() instead.
[124] Fix | Delete
*/
[125] Fix | Delete
public function setTemplateName($name)
[126] Fix | Delete
{
[127] Fix | Delete
@\trigger_error(\sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[128] Fix | Delete
$this->filename = $name;
[129] Fix | Delete
$this->sourceCode = $this->sourcePath = null;
[130] Fix | Delete
$this->updateRepr();
[131] Fix | Delete
}
[132] Fix | Delete
/**
[133] Fix | Delete
* Gets the template line where the error occurred.
[134] Fix | Delete
*
[135] Fix | Delete
* @return int The template line
[136] Fix | Delete
*/
[137] Fix | Delete
public function getTemplateLine()
[138] Fix | Delete
{
[139] Fix | Delete
return $this->lineno;
[140] Fix | Delete
}
[141] Fix | Delete
/**
[142] Fix | Delete
* Sets the template line where the error occurred.
[143] Fix | Delete
*
[144] Fix | Delete
* @param int $lineno The template line
[145] Fix | Delete
*/
[146] Fix | Delete
public function setTemplateLine($lineno)
[147] Fix | Delete
{
[148] Fix | Delete
$this->lineno = $lineno;
[149] Fix | Delete
$this->updateRepr();
[150] Fix | Delete
}
[151] Fix | Delete
/**
[152] Fix | Delete
* Gets the source context of the Twig template where the error occurred.
[153] Fix | Delete
*
[154] Fix | Delete
* @return Source|null
[155] Fix | Delete
*/
[156] Fix | Delete
public function getSourceContext()
[157] Fix | Delete
{
[158] Fix | Delete
return $this->filename ? new \WPML\Core\Twig\Source($this->sourceCode, $this->filename, $this->sourcePath) : null;
[159] Fix | Delete
}
[160] Fix | Delete
/**
[161] Fix | Delete
* Sets the source context of the Twig template where the error occurred.
[162] Fix | Delete
*/
[163] Fix | Delete
public function setSourceContext(\WPML\Core\Twig\Source $source = null)
[164] Fix | Delete
{
[165] Fix | Delete
if (null === $source) {
[166] Fix | Delete
$this->sourceCode = $this->filename = $this->sourcePath = null;
[167] Fix | Delete
} else {
[168] Fix | Delete
$this->sourceCode = $source->getCode();
[169] Fix | Delete
$this->filename = $source->getName();
[170] Fix | Delete
$this->sourcePath = $source->getPath();
[171] Fix | Delete
}
[172] Fix | Delete
$this->updateRepr();
[173] Fix | Delete
}
[174] Fix | Delete
public function guess()
[175] Fix | Delete
{
[176] Fix | Delete
$this->guessTemplateInfo();
[177] Fix | Delete
$this->updateRepr();
[178] Fix | Delete
}
[179] Fix | Delete
public function appendMessage($rawMessage)
[180] Fix | Delete
{
[181] Fix | Delete
$this->rawMessage .= $rawMessage;
[182] Fix | Delete
$this->updateRepr();
[183] Fix | Delete
}
[184] Fix | Delete
/**
[185] Fix | Delete
* @internal
[186] Fix | Delete
*/
[187] Fix | Delete
protected function updateRepr()
[188] Fix | Delete
{
[189] Fix | Delete
$this->message = $this->rawMessage;
[190] Fix | Delete
if ($this->sourcePath && $this->lineno > 0) {
[191] Fix | Delete
$this->file = $this->sourcePath;
[192] Fix | Delete
$this->line = $this->lineno;
[193] Fix | Delete
return;
[194] Fix | Delete
}
[195] Fix | Delete
$dot = \false;
[196] Fix | Delete
if ('.' === \substr($this->message, -1)) {
[197] Fix | Delete
$this->message = \substr($this->message, 0, -1);
[198] Fix | Delete
$dot = \true;
[199] Fix | Delete
}
[200] Fix | Delete
$questionMark = \false;
[201] Fix | Delete
if ('?' === \substr($this->message, -1)) {
[202] Fix | Delete
$this->message = \substr($this->message, 0, -1);
[203] Fix | Delete
$questionMark = \true;
[204] Fix | Delete
}
[205] Fix | Delete
if ($this->filename) {
[206] Fix | Delete
if (\is_string($this->filename) || \is_object($this->filename) && \method_exists($this->filename, '__toString')) {
[207] Fix | Delete
$name = \sprintf('"%s"', $this->filename);
[208] Fix | Delete
} else {
[209] Fix | Delete
$name = \json_encode($this->filename);
[210] Fix | Delete
}
[211] Fix | Delete
$this->message .= \sprintf(' in %s', $name);
[212] Fix | Delete
}
[213] Fix | Delete
if ($this->lineno && $this->lineno >= 0) {
[214] Fix | Delete
$this->message .= \sprintf(' at line %d', $this->lineno);
[215] Fix | Delete
}
[216] Fix | Delete
if ($dot) {
[217] Fix | Delete
$this->message .= '.';
[218] Fix | Delete
}
[219] Fix | Delete
if ($questionMark) {
[220] Fix | Delete
$this->message .= '?';
[221] Fix | Delete
}
[222] Fix | Delete
}
[223] Fix | Delete
/**
[224] Fix | Delete
* @internal
[225] Fix | Delete
*/
[226] Fix | Delete
protected function guessTemplateInfo()
[227] Fix | Delete
{
[228] Fix | Delete
$template = null;
[229] Fix | Delete
$templateClass = null;
[230] Fix | Delete
$backtrace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT);
[231] Fix | Delete
foreach ($backtrace as $trace) {
[232] Fix | Delete
if (isset($trace['object']) && $trace['object'] instanceof \WPML\Core\Twig\Template && 'Twig_Template' !== \get_class($trace['object'])) {
[233] Fix | Delete
$currentClass = \get_class($trace['object']);
[234] Fix | Delete
$isEmbedContainer = 0 === \strpos($templateClass, $currentClass);
[235] Fix | Delete
if (null === $this->filename || $this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer) {
[236] Fix | Delete
$template = $trace['object'];
[237] Fix | Delete
$templateClass = \get_class($trace['object']);
[238] Fix | Delete
}
[239] Fix | Delete
}
[240] Fix | Delete
}
[241] Fix | Delete
// update template name
[242] Fix | Delete
if (null !== $template && null === $this->filename) {
[243] Fix | Delete
$this->filename = $template->getTemplateName();
[244] Fix | Delete
}
[245] Fix | Delete
// update template path if any
[246] Fix | Delete
if (null !== $template && null === $this->sourcePath) {
[247] Fix | Delete
$src = $template->getSourceContext();
[248] Fix | Delete
$this->sourceCode = $src->getCode();
[249] Fix | Delete
$this->sourcePath = $src->getPath();
[250] Fix | Delete
}
[251] Fix | Delete
if (null === $template || $this->lineno > -1) {
[252] Fix | Delete
return;
[253] Fix | Delete
}
[254] Fix | Delete
$r = new \ReflectionObject($template);
[255] Fix | Delete
$file = $r->getFileName();
[256] Fix | Delete
$exceptions = [$e = $this];
[257] Fix | Delete
while ($e instanceof self && ($e = $e->getPrevious())) {
[258] Fix | Delete
$exceptions[] = $e;
[259] Fix | Delete
}
[260] Fix | Delete
while ($e = \array_pop($exceptions)) {
[261] Fix | Delete
$traces = $e->getTrace();
[262] Fix | Delete
\array_unshift($traces, ['file' => $e->getFile(), 'line' => $e->getLine()]);
[263] Fix | Delete
while ($trace = \array_shift($traces)) {
[264] Fix | Delete
if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
[265] Fix | Delete
continue;
[266] Fix | Delete
}
[267] Fix | Delete
foreach ($template->getDebugInfo() as $codeLine => $templateLine) {
[268] Fix | Delete
if ($codeLine <= $trace['line']) {
[269] Fix | Delete
// update template line
[270] Fix | Delete
$this->lineno = $templateLine;
[271] Fix | Delete
return;
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
\class_alias('WPML\\Core\\Twig\\Error\\Error', 'WPML\\Core\\Twig_Error');
[279] Fix | Delete
[280] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function