Browse Source

Changing function name from underscore to camel case

Florian Krämer 8 years ago
parent
commit
56ff8fada9

+ 1 - 1
src/Console/Command.php

@@ -116,7 +116,7 @@ class Command
             throw new RuntimeException(sprintf(
                 "Invalid option parser returned from buildOptionParser(). Expected %s, got %s",
                 ConsoleOptionParser::class,
-                get_var_type($parser)
+                getVarType($parser)
             ));
         }
 

+ 1 - 1
src/Console/CommandRunner.php

@@ -119,7 +119,7 @@ class CommandRunner
         ]);
         $commands = $this->app->console($commands);
         if (!($commands instanceof CommandCollection)) {
-            $type = get_var_type($commands);
+            $type = getVarType($commands);
             throw new RuntimeException(
                 "The application's `console` method did not return a CommandCollection." .
                 " Got '{$type}' instead."

+ 1 - 1
src/Http/Cookie/CookieCollection.php

@@ -183,7 +183,7 @@ class CookieCollection implements IteratorAggregate, Countable
                     sprintf(
                         'Expected `%s[]` as $cookies but instead got `%s` at index %d',
                         static::class,
-                        get_var_type($cookie),
+                        getVarType($cookie),
                         $index
                     )
                 );

+ 1 - 1
src/ORM/Marshaller.php

@@ -247,7 +247,7 @@ class Marshaller
         }
         if (!is_object($options['validate'])) {
             throw new RuntimeException(
-                sprintf('validate must be a boolean, a string or an object. Got %s.', get_var_type($options['validate']))
+                sprintf('validate must be a boolean, a string or an object. Got %s.', getVarType($options['validate']))
             );
         }
 

+ 1 - 1
src/View/Form/ContextFactory.php

@@ -146,7 +146,7 @@ class ContextFactory
             throw new RuntimeException(sprintf(
                 'Context providers must return object implementing %s. Got "%s" instead.',
                 ContextInterface::class,
-                get_var_type($context)
+                getVarType($context)
             ));
         }
 

+ 2 - 2
src/basics.php

@@ -156,14 +156,14 @@ if (!function_exists('loadPHPUnitAliases')) {
     }
 }
 
-if (!function_exists('get_var_type')) {
+if (!function_exists('getVarType')) {
     /**
      * Returns the objects class or var type of it's not an object
      *
      * @param mixed $var Variable to check
      * @return string Returns the class name or variable type
      */
-    function get_var_type($var)
+    function getVarType($var)
     {
         return is_object($var) ? get_class($var) : gettype($var);
     }

+ 14 - 2
tests/TestCase/BasicsTest.php

@@ -576,7 +576,7 @@ EXPECTED;
     public function testEventManagerReset1()
     {
         $eventManager = EventManager::instance();
-        $this->assertInstanceOf('Cake\Event\EventManager', $eventManager);
+        $this->assertInstanceOf(EventManager::class, $eventManager);
 
         return $eventManager;
     }
@@ -589,7 +589,19 @@ EXPECTED;
      */
     public function testEventManagerReset2($prevEventManager)
     {
-        $this->assertInstanceOf('Cake\Event\EventManager', $prevEventManager);
+        $this->assertInstanceOf(EventManager::class, $prevEventManager);
         $this->assertNotSame($prevEventManager, EventManager::instance());
     }
+
+    /**
+     * testing getVarType()
+     *
+     * @return void
+     */
+    public function testGetVarType()
+    {
+        $this->assertEquals('stdClass', getVarType(new \stdClass()));
+        $this->assertEquals('array', getVarType([]));
+        $this->assertEquals('string', getVarType(''));
+    }
 }