Author: dr
Date: Tue Dec 11 13:20:25 2007
New Revision: 6963

Log:
- Made named parameters work with PHP 5.1.6.

Modified:
    trunk/Template/ChangeLog
    trunk/Template/src/functions/functions.php
    trunk/Template/src/parsers/source_to_tst/implementations/function_call.php

Modified: trunk/Template/ChangeLog
==============================================================================
--- trunk/Template/ChangeLog [iso-8859-1] (original)
+++ trunk/Template/ChangeLog [iso-8859-1] Tue Dec 11 13:20:25 2007
@@ -1,7 +1,12 @@
+1.3alpha1 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 - Made the TemplateObject available in CustomBlocks. Thanks to Felix Weis for 
   the patch.
 - Fixed issue #11228: Cannot supply an absolute Win32-Path to $t->process().
 - Better error message when an external (use) variable is not given.
+- Made named parameters work with PHP 5.1.6.
+
 
 1.2 - Monday 02 July 2007
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Modified: trunk/Template/src/functions/functions.php
==============================================================================
--- trunk/Template/src/functions/functions.php [iso-8859-1] (original)
+++ trunk/Template/src/functions/functions.php [iso-8859-1] Tue Dec 11 13:20:25 
2007
@@ -385,13 +385,6 @@
      */
     protected function checkDefinition( $definition, $reflectionParameters )
     {
-        // A bug in the Reflection classes again.
-        // Need to check the current PHP version and create a different 
behavior. 
-        if ( version_compare( PHP_VERSION, "5.2", "<") )
-        {
-            return;
-        }
-
         if ( !isset( $definition->parameters ) || $definition->parameters === 
false) return;
 
         $i = 0;
@@ -435,29 +428,12 @@
     {
         $requiredParameters = 0;
 
-        if ( version_compare( PHP_VERSION, "5.2", "<") )
-        {
-            if ( !isset( $definition->parameters ) || $definition->parameters 
=== false)
-            {
-                throw new ezcTemplateException("PHP 5.2 is needed when the 
parameter definition is omitted in the CustomFunction definition.");
-            }
-
-            foreach ($definition->parameters as $p)
-            {
-                if ( $p[0] !== '[' ) $requiredParameters++;
-            }
-
-            return $requiredParameters;
-        }
-        else
-        {
-            foreach ($reflectionParameters as $p)
-            {
-                if ( !$p->isOptional()) $requiredParameters++;
-            }
-
-            return $requiredParameters;
-        }
+        foreach ($reflectionParameters as $p)
+        {
+            if ( !$p->isOptional()) $requiredParameters++;
+        }
+
+        return $requiredParameters;
     }
 
     /**
@@ -469,19 +445,7 @@
      */
     protected function countTotalParameters($definition, $reflectionParameters)
     {
-        if ( version_compare( PHP_VERSION, "5.2", "<") )
-        {
-            if ( !isset( $definition->parameters ) || $definition->parameters 
=== false)
-            {
-                throw new ezcTemplateException("PHP 5.2 is needed when the 
parameter definition is omitted in the CustomFunction definition.");
-            }
-
-            return sizeof( $definition->parameters);
-        }
-        else
-        {
-            return sizeof( $reflectionParameters );
-        }
+        return sizeof( $reflectionParameters );
     }
 
     /**

Modified: 
trunk/Template/src/parsers/source_to_tst/implementations/function_call.php
==============================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/function_call.php 
[iso-8859-1] (original)
+++ trunk/Template/src/parsers/source_to_tst/implementations/function_call.php 
[iso-8859-1] Tue Dec 11 13:20:25 2007
@@ -210,12 +210,6 @@
 
         if ( $namedParameter !== false )
         {
-
-            if ( version_compare( PHP_VERSION, "5.2", "<") )
-            {
-                throw new ezcTemplateParserException( $this->parser->source, 
$this->startCursor, $this->currentCursor, "Named parameters are not supported 
in PHP versions lower than 5.2" );
-            }
-
             if ( isset( $this->functionCall->parameters[$namedParameter] ) )
             {
                 throw new ezcTemplateParserException( $this->parser->source, 
$this->startCursor, $this->currentCursor, 
sprintf(ezcTemplateSourceToTstErrorMessages::MSG_NAMED_PARAMETER_ALREADY_ASSIGNED,
 $namedParameter ) );


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to