Changeset 40

Show
Ignore:
Timestamp:
08/31/06 22:02:54 (2 years ago)
Author:
mikey
Message:

fix: creation of objects via constructor did not work when constructor did not accept any parameters
fix: reset constructor parameters of it consists of only one parameter and this one is empty

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/XJConf/converters/ConstructorValueConverter.php

    r22 r40  
    4848            $cParams[] = $conParam->convertValue($tag); 
    4949        } 
    50  
     50         
     51        if (count($cParams) == 1 && empty($cParams[0]) == true) { 
     52            $cParams = array(); 
     53        } 
     54         
    5155        // try to create a new instance 
    5256        try { 
    5357                $refClass = new ReflectionClass($this->className); 
    54                 if (method_exists($refClass, 'newInstanceArgs')) { 
    55                   $instance = $refClass->newInstanceArgs($cParams); 
     58                if (count($cParams) > 1 && method_exists($refClass, 'newInstanceArgs') == true) { 
     59                $instance = $refClass->newInstanceArgs($cParams); 
    5660                } elseif (count($cParams) == 1) { 
    5761                    $instance = $refClass->newInstance($cParams[0]); 
     62                } elseif (count($cParams) == 0) { 
     63                    $instance = $refClass->newInstance(); 
    5864                } else { 
    5965                    throw new ValueConversionException('Could not create instance of "' . $this->className . '" as Reflection does not support newInstanceArgs().');