[TASK] Extbase: Use strpos() instead of strstr() where possible
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Jun 2011 20:38:01 +0000 (22:38 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 9 Jul 2011 20:47:22 +0000 (22:47 +0200)
Faster and less memory-intensive if just checking for presence
of one character (according to PHP-documentation).

Change-Id: Idb05355dcacc8257f497ee7fc5abe293c9d592f7

typo3/sysext/extbase/Classes/MVC/Controller/Argument.php
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php

index 7b5697e..e780d01 100644 (file)
@@ -207,7 +207,7 @@ class Tx_Extbase_MVC_Controller_Argument {
         */
        public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService) {
                $this->reflectionService = $reflectionService;
-               $this->dataTypeClassSchema = (strstr($this->dataType, '_') !== FALSE) ? $this->reflectionService->getClassSchema($this->dataType) : NULL;
+               $this->dataTypeClassSchema = (strpos($this->dataType, '_') !== FALSE) ? $this->reflectionService->getClassSchema($this->dataType) : NULL;
        }
 
        /**
index 865cb6f..70b9d71 100644 (file)
@@ -201,7 +201,7 @@ class Tx_Extbase_Validation_ValidatorResolver implements t3lib_Singleton {
                $validatorConjunction = $this->objectManager->get('Tx_Extbase_Validation_Validator_ConjunctionValidator');
 
                // Model based validator
-               if (strstr($dataType, '_') !== FALSE && class_exists($dataType)) {
+               if (strpos($dataType, '_') !== FALSE && class_exists($dataType)) {
                        $validatorCount = 0;
                        $objectValidator = $this->createValidator('GenericObject');
 
@@ -309,7 +309,7 @@ class Tx_Extbase_Validation_ValidatorResolver implements t3lib_Singleton {
         * @return string Name of the validator object or FALSE
         */
        protected function resolveValidatorObjectName($validatorName) {
-               if (strstr($validatorName, '_') !== FALSE && class_exists($validatorName)) return $validatorName;
+               if (strpos($validatorName, '_') !== FALSE && class_exists($validatorName)) return $validatorName;
 
                $possibleClassName = 'Tx_Extbase_Validation_Validator_' . $this->unifyDataType($validatorName) . 'Validator';
                if (class_exists($possibleClassName)) return $possibleClassName;