Author: Jan Borsodi
Date: 2006-12-21 13:17:28 +0100 (Thu, 21 Dec 2006)
New Revision: 4430

Log:
- Added default values to parameters.

Modified:
   scripts/clone-empty.php

Modified: scripts/clone-empty.php
===================================================================
--- scripts/clone-empty.php     2006-12-21 12:01:20 UTC (rev 4429)
+++ scripts/clone-empty.php     2006-12-21 12:17:28 UTC (rev 4430)
@@ -298,10 +298,19 @@
     // Set the access type of the class.
     echo ( isset( $classTags[ "@access" ] ) ? $classTags["@access"][0] : 
"public" ) ." ";
 
-       echo
-               $rc->isAbstract() ? 'abstract ' : '',
-               $rc->isFinal() ? 'final ' : '',
-               $rc->isInterface() ? 'interface ' : 'class ';
+    if ( $rc->isInterface() )
+    {
+        echo
+            $rc->isFinal() ? 'final ' : '',
+            'interface ';
+    }
+    else
+    {
+        echo
+            $rc->isAbstract() ? 'abstract ' : '',
+            $rc->isFinal() ? 'final ' : '',
+            'class ';
+    }
        echo "$class";
 
     $c = $rc->getParentClass();
@@ -333,7 +342,7 @@
         {
             $constantType = "string";
         }
-        echo "public static final $constantType $constantName = $constant;\n";
+        echo "    public static final $constantType $constantName = ", 
var_export( $constant, true ), ";\n";
        }
        echo "\n";
 
@@ -385,7 +394,7 @@
     while ( true )
     {
         $text = substr( $classBlock, $o );
-        if ( preg_match( "[EMAIL PROTECTED](-read|-write|)[ 
\t\r\n*]+([a-zA-Z][a-zA-Z0-9_]*)[ \t\r\n*]+(?:[$]?([a-zA-Z][a-zA-Z0-9_]*))[ 
\t\r\n*]+([EMAIL PROTECTED])#s",
+        if ( preg_match( "[EMAIL PROTECTED](-read|-write|)[ \t\r\n*]+([^ 
\t\r\n]*)[ \t\r\n*]+(?:[$]?([^ \t\r\n]*))[ \t\r\n*]+([EMAIL PROTECTED])#s",
                          $text, $matches, PREG_OFFSET_CAPTURE ) )
         {
             $propType = $matches[1][0];
@@ -424,13 +433,24 @@
             echo ("\n\t");
 
             $methodTags = getTags( $method );
-            echo
-                $method->isAbstract() ? 'abstract ' : '',
-                $method->isFinal() ? 'final ' : '',
-                $method->isPublic() ? 'public ' : '',
-                $method->isPrivate() ? 'private ' : '',
-                $method->isProtected() ? 'protected ' : '',
-                $method->isStatic() ? 'static ' : '';
+            if ( $rc->isInterface() )
+            {
+                echo
+                    $method->isFinal() ? 'final ' : '',
+                    $method->isPublic() ? 'public ' : '',
+                    $method->isPrivate() ? 'private ' : '',
+                    $method->isProtected() ? 'protected ' : '';
+            }
+            else
+            {
+                echo
+                    $method->isAbstract() ? 'abstract ' : '',
+                    $method->isFinal() ? 'final ' : '',
+                    $method->isPublic() ? 'public ' : '',
+                    $method->isPrivate() ? 'private ' : '',
+                    $method->isProtected() ? 'protected ' : '',
+                    $method->isStatic() ? 'static ' : '';
+            }
             
             $returnType = getReturnValue( $method );
 
@@ -454,7 +474,12 @@
                 {
                     echo ", ";
                 }
-                if ( isset( $parameterTypes[$param->getName()] ) )
+                $paramClass = $param->getClass();
+                if ( $paramClass )
+                {
+                    echo $paramClass->getName(), " ";
+                }
+                elseif ( isset( $parameterTypes[$param->getName()] ) )
                 { 
                     echo fixType( $parameterTypes[$param->getName()] ), " ";
                 }
@@ -463,6 +488,10 @@
                     echo "PARAM_TYPE_MISSING ";
                 }
                 echo $param->getName();
+                if ( $param->isDefaultValueAvailable() )
+                {
+                    echo " = ", var_export( $param->getDefaultValue(), true );
+                }
                 /*
                 if ( $param->isDefaultValueAvailable() )
                 {
@@ -569,8 +598,14 @@
     // Pick the first type if it can have multiple values: int|bool.
     if ( ( $pos = strpos( $type, "|" ) ) !== false )
     {
-        $type = substr( $type, 0, $pos );
+//        $type = substr( $type, 0, $pos );
+        $type = "RETURN_TYPE_MIXED";
     }
+    elseif ( ( $pos = strpos( $type, "/" ) ) !== false )
+    {
+//        $type = substr( $type, 0, $pos );
+        $type = "RETURN_TYPE_MIXED";
+    }
 
     if ( strncmp( $type, "array(", 6 ) == 0 )
     {

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to