Pinq\Providers\DSL\Compilation\Parameters\ParameterHasher::functionSignature PHP Method

functionSignature() public static method

public static functionSignature ( Pinq\Parsing\IFunctionInterpreter $functionInterpreter = null ) : FunctionSignatureHasher
$functionInterpreter Pinq\Parsing\IFunctionInterpreter
return FunctionSignatureHasher
    public static function functionSignature(IFunctionInterpreter $functionInterpreter = null)
    {
        return new FunctionSignatureHasher($functionInterpreter);
    }

Usage Example

示例#1
0
 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) {
     }));
 }
All Usage Examples Of Pinq\Providers\DSL\Compilation\Parameters\ParameterHasher::functionSignature