[TASK] Optimization in AbstractViewHelper 96/25496/2
authorWouter Wolters <typo3@wouterwolters.nl>
Mon, 18 Nov 2013 21:27:22 +0000 (22:27 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 18 Nov 2013 23:03:14 +0000 (00:03 +0100)
Small optimization in AbstractViewHelper to fetch the type
after the check for the default value of the argument.

Change-Id: Ie9b68d892f4a20521606709b8fdfba83099c3d70
Resolves: #53746
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/25496
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php

index f795093..3383e94 100644 (file)
@@ -382,10 +382,11 @@ abstract class AbstractViewHelper {
                }
                foreach ($argumentDefinitions as $argumentName => $registeredArgument) {
                        if ($this->hasArgument($argumentName)) {
-                               $type = $registeredArgument->getType();
                                if ($this->arguments[$argumentName] === $registeredArgument->getDefaultValue()) {
                                        continue;
                                }
+
+                               $type = $registeredArgument->getType();
                                if ($type === 'array') {
                                        if (!is_array($this->arguments[$argumentName]) && !$this->arguments[$argumentName] instanceof \ArrayAccess && !$this->arguments[$argumentName] instanceof \Traversable) {
                                                throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "array", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '"', 1237900529);
@@ -485,4 +486,4 @@ abstract class AbstractViewHelper {
        }
 }
 
-?>
\ No newline at end of file
+?>