public static functionSignature ( Pinq\Parsing\IFunctionInterpreter $functionInterpreter = null ) : |
||
$functionInterpreter | Pinq\Parsing\IFunctionInterpreter | |
return |
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) { })); }
/** * Adds the necessary expression(s) to the supplied collection. * * @param IFunction $function * @param O\Expression $expression * @param Parameters\ParameterCollection $parameters * * @return void */ public function parameterize(IFunction $function, O\Expression $expression, Parameters\ParameterCollection $parameters) { /** @var O\InvocationExpression $expression */ $this->addParameter($parameters, $function, $expression->getValue(), ParameterHasher::functionSignature()); }