Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- SplObjectStorage::getHash implementation --FILE-- <?php $s = new SplObjectStorage..

Decoded Output download

--TEST--
SplObjectStorage::getHash implementation
--FILE--
<?php
$s = new SplObjectStorage();
$o1 = new Stdclass;
$o2 = new Stdclass;
$s[$o1] = "some_value
";
echo $s->offsetGet($o1);

class MySplObjectStorage extends SplObjectStorage {
    #[ReturnTypeWillChange]
    public function getHash($obj) {
        return 2;
    }
}

try {
    $s1 = new MySplObjectStorage;
    $s1[$o1] = "foo";
} catch(Exception $e) {
    echo "caught 1
";
}

class MySplObjectStorage2 extends SplObjectStorage {
    public function getHash($obj): string {
        throw new Exception("foo");
        return "asd";
    }
}

try {
    $s2 = new MySplObjectStorage2;
    $s2[$o2] = "foo";
} catch(Exception $e) {
    echo "caught 2
";
}

class MySplObjectStorage3 extends SplObjectStorage {
    public function getHash($obj): string {
        return "asd";
    }
}

$s3 = new MySplObjectStorage3;
$s3[$o1] = $o1;
var_dump($s3[$o1]);
$s3[$o2] = $o2;

var_dump($s3[$o1] === $s3[$o2]);

?>
--EXPECT--
some_value
caught 1
caught 2
object(stdClass)#2 (0) {
}
bool(true)

Did this file decode correctly?

Original Code

--TEST--
SplObjectStorage::getHash implementation
--FILE--
<?php
$s = new SplObjectStorage();
$o1 = new Stdclass;
$o2 = new Stdclass;
$s[$o1] = "some_value\n";
echo $s->offsetGet($o1);

class MySplObjectStorage extends SplObjectStorage {
    #[ReturnTypeWillChange]
    public function getHash($obj) {
        return 2;
    }
}

try {
    $s1 = new MySplObjectStorage;
    $s1[$o1] = "foo";
} catch(Exception $e) {
    echo "caught 1\n";
}

class MySplObjectStorage2 extends SplObjectStorage {
    public function getHash($obj): string {
        throw new Exception("foo");
        return "asd";
    }
}

try {
    $s2 = new MySplObjectStorage2;
    $s2[$o2] = "foo";
} catch(Exception $e) {
    echo "caught 2\n";
}

class MySplObjectStorage3 extends SplObjectStorage {
    public function getHash($obj): string {
        return "asd";
    }
}

$s3 = new MySplObjectStorage3;
$s3[$o1] = $o1;
var_dump($s3[$o1]);
$s3[$o2] = $o2;

var_dump($s3[$o1] === $s3[$o2]);

?>
--EXPECT--
some_value
caught 1
caught 2
object(stdClass)#2 (0) {
}
bool(true)

Function Calls

None

Variables

None

Stats

MD5 d35ef0bd5a3b2639d1401c0abe27b980
Eval Count 0
Decode Time 98 ms