| 56 | | } elseif (count($cParams) == 1) { |
|---|
| 57 | | try { |
|---|
| 58 | | $instance = $refClass->newInstance($cParams[0]); |
|---|
| 59 | | } catch (ReflectionException $re) { |
|---|
| 60 | | $instance = $refClass->newInstance(); |
|---|
| 61 | | } |
|---|
| 62 | | } elseif (count($cParams) == 0) { |
|---|
| 63 | | $instance = $refClass->newInstance(); |
|---|
| 64 | | } else { |
|---|
| 65 | | throw new ValueConversionException('Could not create instance of "' . $this->className . '" as Reflection does not support newInstanceArgs().'); |
|---|
| 66 | | } |
|---|
| | 56 | } elseif (count($cParams) == 1) { |
|---|
| | 57 | // check if the constructor has arguments |
|---|
| | 58 | // if the first argument has a type hint and we have an empty |
|---|
| | 59 | // string replace this with an appropriate value |
|---|
| | 60 | $refMethod = $refClass->getConstructor(); |
|---|
| | 61 | if (null != $refMethod) { |
|---|
| | 62 | $params = $refMethod->getParameters(); |
|---|
| | 63 | if (count($params) >= 1 && $params[0]->getClass() != null && empty($cParams[0]) == true) { |
|---|
| | 64 | $cParams[0] = null; |
|---|
| | 65 | } elseif (count($params) >= 1 && $params[0]->isArray() == true && empty($cParams[0]) == true) { |
|---|
| | 66 | if ($params[0]->allowsNull() == true) { |
|---|
| | 67 | $cParams[0] = null; |
|---|
| | 68 | } else { |
|---|
| | 69 | $cParams[0] = array(); |
|---|
| | 70 | } |
|---|
| | 71 | } |
|---|
| | 72 | } |
|---|
| | 73 | try { |
|---|
| | 74 | $instance = $refClass->newInstance($cParams[0]); |
|---|
| | 75 | } catch (ReflectionException $re) { |
|---|
| | 76 | $instance = $refClass->newInstance(); |
|---|
| | 77 | } |
|---|
| | 78 | } elseif (count($cParams) == 0) { |
|---|
| | 79 | $instance = $refClass->newInstance(); |
|---|
| | 80 | } else { |
|---|
| | 81 | throw new ValueConversionException('Could not create instance of "' . $this->className . '" as Reflection does not support newInstanceArgs().'); |
|---|
| | 82 | } |
|---|