Skip to content

Commit 56ff8fa

Browse files
committed
Changing function name from underscore to camel case
1 parent 9eb5a52 commit 56ff8fa

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

src/Console/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function getOptionParser()
116116
throw new RuntimeException(sprintf(
117117
"Invalid option parser returned from buildOptionParser(). Expected %s, got %s",
118118
ConsoleOptionParser::class,
119-
get_var_type($parser)
119+
getVarType($parser)
120120
));
121121
}
122122

src/Console/CommandRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function run(array $argv, ConsoleIo $io = null)
119119
]);
120120
$commands = $this->app->console($commands);
121121
if (!($commands instanceof CommandCollection)) {
122-
$type = get_var_type($commands);
122+
$type = getVarType($commands);
123123
throw new RuntimeException(
124124
"The application's `console` method did not return a CommandCollection." .
125125
" Got '{$type}' instead."

src/Http/Cookie/CookieCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected function checkCookies(array $cookies)
183183
sprintf(
184184
'Expected `%s[]` as $cookies but instead got `%s` at index %d',
185185
static::class,
186-
get_var_type($cookie),
186+
getVarType($cookie),
187187
$index
188188
)
189189
);

src/ORM/Marshaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected function _validate($data, $options, $isNew)
247247
}
248248
if (!is_object($options['validate'])) {
249249
throw new RuntimeException(
250-
sprintf('validate must be a boolean, a string or an object. Got %s.', get_var_type($options['validate']))
250+
sprintf('validate must be a boolean, a string or an object. Got %s.', getVarType($options['validate']))
251251
);
252252
}
253253

src/View/Form/ContextFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function get(ServerRequest $request, array $data = [])
146146
throw new RuntimeException(sprintf(
147147
'Context providers must return object implementing %s. Got "%s" instead.',
148148
ContextInterface::class,
149-
get_var_type($context)
149+
getVarType($context)
150150
));
151151
}
152152

src/basics.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ function loadPHPUnitAliases()
156156
}
157157
}
158158

159-
if (!function_exists('get_var_type')) {
159+
if (!function_exists('getVarType')) {
160160
/**
161161
* Returns the objects class or var type of it's not an object
162162
*
163163
* @param mixed $var Variable to check
164164
* @return string Returns the class name or variable type
165165
*/
166-
function get_var_type($var)
166+
function getVarType($var)
167167
{
168168
return is_object($var) ? get_class($var) : gettype($var);
169169
}

tests/TestCase/BasicsTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public function testCollection()
576576
public function testEventManagerReset1()
577577
{
578578
$eventManager = EventManager::instance();
579-
$this->assertInstanceOf('Cake\Event\EventManager', $eventManager);
579+
$this->assertInstanceOf(EventManager::class, $eventManager);
580580

581581
return $eventManager;
582582
}
@@ -589,7 +589,19 @@ public function testEventManagerReset1()
589589
*/
590590
public function testEventManagerReset2($prevEventManager)
591591
{
592-
$this->assertInstanceOf('Cake\Event\EventManager', $prevEventManager);
592+
$this->assertInstanceOf(EventManager::class, $prevEventManager);
593593
$this->assertNotSame($prevEventManager, EventManager::instance());
594594
}
595+
596+
/**
597+
* testing getVarType()
598+
*
599+
* @return void
600+
*/
601+
public function testGetVarType()
602+
{
603+
$this->assertEquals('stdClass', getVarType(new \stdClass()));
604+
$this->assertEquals('array', getVarType([]));
605+
$this->assertEquals('string', getVarType(''));
606+
}
595607
}

0 commit comments

Comments
 (0)