- var_dump: documentation ( source)
- explode: documentation ( source)
- strtolower: documentation ( source)
<?php
namespace
{
function callable_equals(callable ...$callables){
$normalizeCallable = function(callable $callable){
if(is_string($callable)){
$callable = strtolower($callable);
$pieces = explode("::", $callable);
if(count($pieces) == 2){
return [$pieces[0], $pieces[1]];
}
return $callable;
}
if(is_string($callable[0])){
$callable[0] = strtolower($callable[0]);
}
$callable[1] = strtolower($callable[1]);
return $callable;
};
foreach($callables as $i => $callable)
$callables[$i] = $normalizeCallable($callable);
var_dump($a, $b);
return $a === $b;
}
class Foo{static function bar(){}}
}
namespace A\b\C\d
{
class Foo{static function bar(){}}
}
namespace
{
var_dump(callable_equals(
['Foo', 'bar'],
'foo::BAR'
));
var_dump(callable_equals(
['A\\b\\C\\d\\Foo', 'bAr'],
'a\\B\\c\\D\\FoO::bar'
));
}