Browse Source

Fixed: php 8.0 bugs

zjh 4 tháng trước cách đây
mục cha
commit
b3a80a2040
27 tập tin đã thay đổi với 106 bổ sung56 xóa
  1. 1 1
      src/Application.php
  2. 49 0
      src/Driver/Entity/Base.php
  3. 1 0
      src/Library/Third/Curl/CaseInsensitiveArray.php
  4. 1 1
      src/Library/Third/Curl/Curl.php
  5. 1 1
      src/View/Smarty.php
  6. 3 3
      src/View/smarty/sysplugins/smarty_internal_compile_break.php
  7. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_capture.php
  8. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_config_load.php
  9. 3 3
      src/View/smarty/sysplugins/smarty_internal_compile_continue.php
  10. 4 4
      src/View/smarty/sysplugins/smarty_internal_compile_foreach.php
  11. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_function.php
  12. 2 2
      src/View/smarty/sysplugins/smarty_internal_compile_if.php
  13. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_include_php.php
  14. 3 3
      src/View/smarty/sysplugins/smarty_internal_compile_insert.php
  15. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_ldelim.php
  16. 2 2
      src/View/smarty/sysplugins/smarty_internal_compile_private_foreachsection.php
  17. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_private_modifier.php
  18. 4 4
      src/View/smarty/sysplugins/smarty_internal_compile_private_php.php
  19. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_private_special_variable.php
  20. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_rdelim.php
  21. 2 2
      src/View/smarty/sysplugins/smarty_internal_compile_section.php
  22. 1 1
      src/View/smarty/sysplugins/smarty_internal_compile_while.php
  23. 5 5
      src/View/smarty/sysplugins/smarty_internal_compilebase.php
  24. 5 5
      src/View/smarty/sysplugins/smarty_internal_templatecompilerbase.php
  25. 4 4
      src/View/smarty/sysplugins/smarty_security.php
  26. 2 6
      src/View/smarty/sysplugins/smartycompilerexception.php
  27. 5 1
      src/View/smarty/sysplugins/smartyexception.php

+ 1 - 1
src/Application.php

@@ -143,10 +143,10 @@ class Application
     public function setWorkspace($workspace = './')
     {
         //此处转换成真实路径,防止workspace中引入的文件出错
+        $workspace = Psr4::getInstance()->realpath($workspace);
         if (!is_dir($workspace)) {
             throw new FolderDoesNotExist(\Qii::i(1045, $workspace), __LINE__);
         }
-        $workspace = Psr4::getInstance()->realpath($workspace);
         //设置 app path , appPATH 为工作目录的上一级目录
         self::$appPATH =  dirname($workspace);
         Psr4::getInstance()->removeNamespace('workspace', self::$workspace);

+ 49 - 0
src/Driver/Entity/Base.php

@@ -72,6 +72,19 @@ class Base {
      */
     private $lastInsertID;
 
+    /**
+     * 动态创建属性
+     *
+     * @var array
+     */
+    private $setter = [];
+
+    /** 表名
+     *
+     * @var null
+     */
+    private $tableName = null;
+
     public function __construct(){
         $this->cleanVars();
     }
@@ -87,6 +100,27 @@ class Base {
         $this->privateKeys = null;
         $this->exclude = [];
     }
+
+    /**
+     * setter
+     * @param string $name key
+     * @param mixed $value value
+     * @return void
+     */
+    public function __set($name, $value) {
+        $this->setter[$name] = $value;
+    }
+    /**
+     * getter
+     * @param $name
+     * @return mixed|null
+     */
+    public function __get($name) {
+        if(isset($this->setter[$name])) {
+            return $this->setter[$name];
+        }
+        return null;
+    }
     /**
      * 默认值,仅在新增数据的时候支持,更新不支持
      *
@@ -94,6 +128,18 @@ class Base {
      */
     public function defaultFieldsValue(){}
 
+    /**
+     * 设置表名
+     *
+     * @param $tableName
+     * @return void
+     */
+    public function setTableName($tableName) {
+        if(is_callable($tableName)) {
+            $this->tableName = $tableName();
+        }
+        if($tableName) $this->tableName = $tableName;
+    }
     /**
      * 返回 table 的名字,以便分库分表的时候指定使用
      *
@@ -101,6 +147,9 @@ class Base {
      * @throws \Exception
      */
     public function getTable() {
+        if($this->tableName != null) {
+            return $this->tableName;
+        }
         throw new \Exception('请先设置需要保存的数据表');
     }
 

+ 1 - 0
src/Library/Third/Curl/CaseInsensitiveArray.php

@@ -2,6 +2,7 @@
 
 namespace Curl;
 
+#[AllowDynamicProperties]
 class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
 {
 

+ 1 - 1
src/Library/Third/Curl/Curl.php

@@ -1,10 +1,10 @@
 <?php
-
 namespace Curl;
 
 use Curl\ArrayUtil;
 use Curl\Decoder;
 
+#[AllowDynamicProperties]
 class Curl
 {
     const VERSION = '8.6.0';

+ 1 - 1
src/View/Smarty.php

@@ -17,7 +17,7 @@ Import::requires(QII_DIR . DS . 'View' . DS . 'smarty' . DS . 'Autoloader.php');
 \Smarty_Autoloader::register(true);
 Import::requires(QII_DIR . DS . DS . 'View' . DS . 'smarty' . DS . 'SmartyBC.class.php');
 Import::requires(QII_DIR . DS . DS . 'View' . DS . 'smarty' . DS . 'sysplugins' .DS. 'smartyexception.php');
-Import::requires(QII_DIR . DS . DS . 'View' . DS . 'smarty' . DS . 'sysplugins' .DS. 'smartycompilerexception.php');
+//Import::requires(QII_DIR . DS . DS . 'View' . DS . 'smarty' . DS . 'sysplugins' .DS. 'smartycompilerexception.php');
 
 class Smarty extends \SmartyBC implements Intf
 {

+ 3 - 3
src/View/smarty/sysplugins/smarty_internal_compile_break.php

@@ -49,12 +49,12 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
         $_attr = $this->getAttributes($compiler, $args);
 
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
 
         if (isset($_attr[ 'levels' ])) {
             if (!is_numeric($_attr[ 'levels' ])) {
-                $compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
+                $compiler->trigger_template_error('level attribute must be a numeric constant', __LINE__, true);
             }
             $_levels = $_attr[ 'levels' ];
         } else {
@@ -69,7 +69,7 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
             $stack_count --;
         }
         if ($level_count != 0) {
-            $compiler->trigger_template_error("cannot break {$_levels} level(s)", null, true);
+            $compiler->trigger_template_error("cannot break {$_levels} level(s)", __LINE__, true);
         }
 
         return "<?php break {$_levels};?>";

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_capture.php

@@ -47,7 +47,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
         $tag = trim($parameter[ 0 ], '"\'');
         $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
         if (!$name) {
-            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
+            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", __LINE__, true);
         }
         return "\$_smarty_tpl->smarty->ext->_capture->getBuffer(\$_smarty_tpl, '{$name}')";
     }

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_config_load.php

@@ -72,7 +72,7 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
         $_attr = $this->getAttributes($compiler, $args);
 
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
 
         // save possible attributes

+ 3 - 3
src/View/smarty/sysplugins/smarty_internal_compile_continue.php

@@ -49,12 +49,12 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
         $_attr = $this->getAttributes($compiler, $args);
 
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
 
         if (isset($_attr[ 'levels' ])) {
             if (!is_numeric($_attr[ 'levels' ])) {
-                $compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
+                $compiler->trigger_template_error('level attribute must be a numeric constant', __LINE__, true);
             }
             $_levels = $_attr[ 'levels' ];
         } else {
@@ -69,7 +69,7 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
             $stack_count --;
         }
         if ($level_count != 0) {
-            $compiler->trigger_template_error("cannot continue {$_levels} level(s)", null, true);
+            $compiler->trigger_template_error("cannot continue {$_levels} level(s)", __LINE__, true);
         }
 
         return "<?php continue {$_levels};?>";

+ 4 - 4
src/View/smarty/sysplugins/smarty_internal_compile_foreach.php

@@ -112,7 +112,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
         }
         foreach ($attributes as $a => $v) {
             if ($v === false) {
-                $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
+                $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", __LINE__, true);
             }
         }
         $fromName = $compiler->getVariableName($_attr[ 'from' ]);
@@ -120,7 +120,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
             foreach (array('item', 'key') as $a) {
                 if (isset($attributes[ $a ]) && $attributes[ $a ] == $fromName) {
                     $compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'",
-                                                      null, true);
+                        __LINE__, true);
                 }
             }
         }
@@ -142,7 +142,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
                 if (in_array($prop, $this->itemProperties)) {
                     $itemAttr[ $prop ] = true;
                 } else {
-                    $compiler->trigger_template_error("Invalid property '{$prop}'", null, true);
+                    $compiler->trigger_template_error("Invalid property '{$prop}'", __LINE__, true);
                 }
             }
             if ($this->isNamed) {
@@ -150,7 +150,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
                     if (in_array($prop, $this->nameProperties)) {
                         $nameAttr[ $prop ] = true;
                     } else {
-                        $compiler->trigger_template_error("Invalid property '{$prop}'", null, true);
+                        $compiler->trigger_template_error("Invalid property '{$prop}'", __LINE__, true);
                     }
                 }
             }

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_function.php

@@ -57,7 +57,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
         $_attr = $this->getAttributes($compiler, $args);
 
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
         unset($_attr[ 'nocache' ]);
         $_name = trim($_attr[ 'name' ], "'\"");

+ 2 - 2
src/View/smarty/sysplugins/smarty_internal_compile_if.php

@@ -35,7 +35,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
         $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
 
         if (!array_key_exists("if condition", $parameter)) {
-            $compiler->trigger_template_error("missing if condition", null, true);
+            $compiler->trigger_template_error("missing if condition", __LINE__, true);
         }
 
         if (is_array($parameter[ 'if condition' ])) {
@@ -119,7 +119,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
         list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
 
         if (!array_key_exists("if condition", $parameter)) {
-            $compiler->trigger_template_error("missing elseif condition", null, true);
+            $compiler->trigger_template_error("missing elseif condition", __LINE__, true);
         }
 
         $assignCode = '';

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_include_php.php

@@ -84,7 +84,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
             }
         }
         if ($_filepath == false) {
-            $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
+            $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", __LINE__, true);
         }
 
         if (isset($compiler->smarty->security_policy)) {

+ 3 - 3
src/View/smarty/sysplugins/smarty_internal_compile_insert.php

@@ -106,14 +106,14 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
                 }
             }
             if ($_filepath == false) {
-                $compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true);
+                $compiler->trigger_template_error("{insert} missing script file '{$_script}'", __LINE__, true);
             }
             // code for script file loading
             $_output .= "require_once '{$_filepath}' ;";
             require_once $_filepath;
             if (!is_callable($_function)) {
                 $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'",
-                                                  null, true);
+                    __LINE__, true);
             }
         } else {
             $_filepath = 'null';
@@ -122,7 +122,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
             if (!is_callable($_function)) {
                 // try plugin
                 if (!$_function = $compiler->getPlugin($_name, 'insert')) {
-                    $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null,
+                    $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", __LINE__,
                                                       true);
                 }
             }

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_ldelim.php

@@ -30,7 +30,7 @@ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
     {
         $_attr = $this->getAttributes($compiler, $args);
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
         // this tag does not return compiled code
         $compiler->has_code = true;

+ 2 - 2
src/View/smarty/sysplugins/smarty_internal_compile_private_foreachsection.php

@@ -209,11 +209,11 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
         $tag = strtolower(trim($parameter[ 0 ], '"\''));
         $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
         if (!$name) {
-            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
+            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", __LINE__, true);
         }
         $property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
         if (!$property || !in_array($property, $this->nameProperties)) {
-            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
+            $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", __LINE__, true);
         }
         $tagVar = "'__smarty_{$tag}_{$name}'";
         return "(isset(\$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}']) ? \$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}'] : null)";

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_private_modifier.php

@@ -148,7 +148,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
                 }
             }
             if (!isset($compiler->known_modifier_type[ $modifier ])) {
-                $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", null, true);
+                $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", __LINE__, true);
             }
         }
 

+ 4 - 4
src/View/smarty/sysplugins/smarty_internal_compile_private_php.php

@@ -78,17 +78,17 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
             } elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
                 if (!($compiler->smarty instanceof SmartyBC)) {
                     $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
-                                                      null, true);
+                        __LINE__, true);
                 }
                 $compiler->has_code = true;
                 return $_attr[ 'code' ];
             } else {
-                $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
+                $compiler->trigger_template_error('Illegal $smarty->php_handling value', __LINE__, true);
             }
         } else {
             $compiler->has_code = true;
             if (!($compiler->smarty instanceof SmartyBC)) {
-                $compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null,
+                $compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', __LINE__,
                                                   true);
             }
             $ldel = preg_quote($compiler->smarty->left_delimiter, '#');
@@ -98,7 +98,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
                 if ('nocache' == trim($match[ 2 ])) {
                     $compiler->tag_nocache = true;
                 } else {
-                    $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true);
+                    $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", __LINE__, true);
                 }
             }
             return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_private_special_variable.php

@@ -31,7 +31,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
         $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
         $variable = strtolower($compiler->getId($_index[ 0 ]));
         if ($variable === false) {
-            $compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
+            $compiler->trigger_template_error("special \$Smarty variable name index can not be variable", __LINE__, true);
         }
         if (!isset($compiler->smarty->security_policy) ||
             $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_rdelim.php

@@ -30,7 +30,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase
     {
         $_attr = $this->getAttributes($compiler, $args);
         if ($_attr[ 'nocache' ] === true) {
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
+            $compiler->trigger_template_error('nocache option not allowed', __LINE__, true);
         }
         // this tag does not return compiled code
         $compiler->has_code = true;

+ 2 - 2
src/View/smarty/sysplugins/smarty_internal_compile_section.php

@@ -94,7 +94,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
         unset($_attr[ 'name' ]);
         foreach ($attributes as $a => $v) {
             if ($v === false) {
-                $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
+                $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", __LINE__, true);
             }
         }
         $local = "\$__section_{$attributes['name']}_" . $this->counter ++ . '_';
@@ -124,7 +124,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
                 if (in_array($prop, $this->nameProperties)) {
                     $namedAttr[ $prop ] = true;
                 } else {
-                    $compiler->trigger_template_error("Invalid property '{$prop}'", null, true);
+                    $compiler->trigger_template_error("Invalid property '{$prop}'", __LINE__, true);
                 }
             }
         }

+ 1 - 1
src/View/smarty/sysplugins/smarty_internal_compile_while.php

@@ -34,7 +34,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
         $this->openTag($compiler, 'while', $compiler->nocache);
 
         if (!array_key_exists("if condition", $parameter)) {
-            $compiler->trigger_template_error("missing while condition", null, true);
+            $compiler->trigger_template_error("missing while condition", __LINE__, true);
         }
 
         // maybe nocache because of nocache variables

+ 5 - 5
src/View/smarty/sysplugins/smarty_internal_compilebase.php

@@ -87,7 +87,7 @@ abstract class Smarty_Internal_CompileBase
                     $_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed;
                 } else {
                     // too many shorthands
-                    $compiler->trigger_template_error('too many shorthand attributes', null, true);
+                    $compiler->trigger_template_error('too many shorthand attributes', __LINE__, true);
                 }
                 // named attribute
             } else {
@@ -104,7 +104,7 @@ abstract class Smarty_Internal_CompileBase
                                 $_indexed_attr[ $k ] = $this->optionMap[ $v ];
                             } else {
                                 $compiler->trigger_template_error("illegal value '" . var_export($v, true) .
-                                                                  "' for option flag '{$k}'", null, true);
+                                                                  "' for option flag '{$k}'", __LINE__, true);
                             }
                         }
                         // must be named attribute
@@ -117,7 +117,7 @@ abstract class Smarty_Internal_CompileBase
         // check if all required attributes present
         foreach ($this->required_attributes as $attr) {
             if (!isset($_indexed_attr[ $attr ])) {
-                $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true);
+                $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", __LINE__, true);
             }
         }
         // check for not allowed attributes
@@ -129,7 +129,7 @@ abstract class Smarty_Internal_CompileBase
             }
             foreach ($_indexed_attr as $key => $dummy) {
                 if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) {
-                    $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true);
+                    $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", __LINE__, true);
                 }
             }
         }
@@ -189,7 +189,7 @@ abstract class Smarty_Internal_CompileBase
             return;
         }
         // wrong nesting of tags
-        $compiler->trigger_template_error("unexpected closing tag", null, true);
+        $compiler->trigger_template_error("unexpected closing tag", __LINE__, true);
 
         return;
     }

+ 5 - 5
src/View/smarty/sysplugins/smarty_internal_templatecompilerbase.php

@@ -571,7 +571,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
                     } else {
                         // throw exception
                         $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' .
-                                                      $tag . '"', null, true);
+                                                      $tag . '"', __LINE__, true);
                     }
                 }
                 // check if tag is registered
@@ -685,7 +685,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
                     } else {
                         // throw exception
                         $this->trigger_template_error('not allowed closing tag method "' . $method .
-                                                      '" in registered object "' . $base_tag . '"', null, true);
+                                                      '" in registered object "' . $base_tag . '"', __LINE__, true);
                     }
                 }
                 // registered block tag ?
@@ -734,7 +734,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
                     throw new SmartyException("Plugin \"{$tag}\" not callable");
                 }
             }
-            $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true);
+            $this->trigger_template_error("unknown tag \"" . $tag . "\"", __LINE__, true);
         }
     }
 
@@ -1117,7 +1117,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
             }
             if ($_scope === false) {
                 $err = var_export($_scopeName, true);
-                $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true);
+                $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", __LINE__, true);
             }
         }
         return $_scope;
@@ -1149,7 +1149,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
      *
      * @throws \SmartyCompilerException when an unexpected token is found
      */
-    public function trigger_template_error($args = null, $line = null, $tagline = null)
+    public function trigger_template_error($args = null, $line = __LINE__, $tagline = null)
     {
         if(!is_numeric($line)) {
             $line = 400;

+ 4 - 4
src/View/smarty/sysplugins/smarty_security.php

@@ -391,12 +391,12 @@ class Smarty_Security
             if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
                 return true;
             } else {
-                $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true);
+                $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", __LINE__, true);
             }
         } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
             return true;
         } else {
-            $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true);
+            $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", __LINE__, true);
         }
 
         return false; // should not, but who knows what happens to the compiler in the future?
@@ -443,7 +443,7 @@ class Smarty_Security
             if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
                 return true;
             } else {
-                $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null,
+                $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", __LINE__,
                                                   true);
             }
         } elseif (in_array($modifier_name, $this->allowed_modifiers) &&
@@ -451,7 +451,7 @@ class Smarty_Security
         ) {
             return true;
         } else {
-            $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null,
+            $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", __LINE__,
                                               true);
         }
 

+ 2 - 6
src/View/smarty/sysplugins/smartycompilerexception.php

@@ -17,7 +17,7 @@ class SmartyCompilerException extends SmartyException
      *
      * @type int|null
      */
-    public $line = 0;
+    public $line = 400;
 
     /**
      * The template source snippet relating to the error
@@ -40,11 +40,7 @@ class SmartyCompilerException extends SmartyException
      */
     public $template = null;
     public function __construct($message, $code = 400, Exception $previous = null){
-        if(!is_numeric($code)){
-            $code = 400;
-        }else{
-            $code = intval($code);
-        }
+        $code = intval($code);
         parent::__construct($message, $code, $previous);
     }
 }

+ 5 - 1
src/View/smarty/sysplugins/smartyexception.php

@@ -10,7 +10,11 @@ class SmartyException extends Exception
     public static $escape = false;
 
     public function __construct($message, $code = 400, Exception $previous = null){
-        parent::__construct($message, 400, $previous);
+        if($code === null) $code = 400;
+        if(!is_numeric($code)){
+            $code = intval($code);
+        }
+        parent::__construct($message, $code, $previous);
     }
     public function __toString()
     {