public function testFunctionSignatureHasher()
{
$hasher = ParameterHasher::functionSignature();
foreach (['strlen', function () {
}, [$this, 'getName'], [$this, 'testFunctionSignatureHasher'], __NAMESPACE__ . '\\userDefinedFunction', [__CLASS__, 'staticFunction']] as $function) {
$this->assertSame($hasher->hash($function), $hasher->hash($function));
}
//Indistinguishable signatures:
$this->assertSame($hasher->hash(function () {
}), $hasher->hash(function () {
}));
$this->assertSame($hasher->hash(function (\stdClass $foo = null) {
}), $hasher->hash(function (\stdClass $foo = null) {
}));
//Case insensitive functions:
$this->assertSame($hasher->hash('StrLen'), $hasher->hash('strleN'));
$this->assertNotSame($hasher->hash('strlen'), $hasher->hash('strpos'));
$this->assertNotSame($hasher->hash('stripos'), $hasher->hash('strpos'));
$this->assertNotSame($hasher->hash([__CLASS__, 'staticFunction']), $hasher->hash(__NAMESPACE__ . '\\userDefinedFunction'));
$this->assertNotSame($hasher->hash([__CLASS__, 'staticFunction']), $hasher->hash(__NAMESPACE__ . '\\userDefinedFunction'));
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function ($o) {
}));
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function &($i) {
}));
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function (&$i) {
}));
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function ($i, $j) {
}));
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function ($i = null) {
}));
//Same signature but distinguishable location
$this->assertNotSame($hasher->hash(function ($i) {
}), $hasher->hash(function ($i) {
}));
}