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-- Calls to file_get_contents are logged --SKIPIF-- <?php if (!extension_loaded("sco..

Decoded Output download

--TEST--
Calls to file_get_contents are logged
--SKIPIF--
<?php if (!extension_loaded("scoutapm")) die("skip scoutapm extension required."); ?>
--FILE--
<?php

namespace {
    var_dump(in_array('file_get_contents', scoutapm_list_instrumented_functions()));
    scoutapm_enable_instrumentation(true);
}

namespace SomeNamespace {
    function file_get_contents(string $_) {}

    echo "should not be logged: function defined in namespace, call implicitly resolves to namespaced function
";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    echo "should not be logged - explicit, unimported call to another namespace
";
    \SomeNamespaceile_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    use function SomeNamespaceile_get_contents;

    echo "should not be logged - imported call resolves to namespaced function
";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    echo "SHOULD be logged
";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}
?>
--EXPECTF--
bool(true)
should not be logged: function defined in namespace, call implicitly resolves to namespaced function
array(0) {
}
should not be logged - explicit, unimported call to another namespace
array(0) {
}
should not be logged - imported call resolves to namespaced function
array(0) {
}
SHOULD be logged
array(1) {
  [0]=>
  array(5) {
    ["function"]=>
    string(17) "file_get_contents"
    ["entered"]=>
    float(%f)
    ["exited"]=>
    float(%f)
    ["time_taken"]=>
    float(%f)
    ["argv"]=>
    array(1) {
      [0]=>
      string(%d) "%s%etests%e004-namespaced-fgc-is-not-logged.php"
    }
  }
}

Did this file decode correctly?

Original Code

--TEST--
Calls to file_get_contents are logged
--SKIPIF--
<?php if (!extension_loaded("scoutapm")) die("skip scoutapm extension required."); ?>
--FILE--
<?php

namespace {
    var_dump(in_array('file_get_contents', scoutapm_list_instrumented_functions()));
    scoutapm_enable_instrumentation(true);
}

namespace SomeNamespace {
    function file_get_contents(string $_) {}

    echo "should not be logged: function defined in namespace, call implicitly resolves to namespaced function\n";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    echo "should not be logged - explicit, unimported call to another namespace\n";
    \SomeNamespace\file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    use function SomeNamespace\file_get_contents;

    echo "should not be logged - imported call resolves to namespaced function\n";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}

namespace {
    echo "SHOULD be logged\n";
    file_get_contents(__FILE__);
    var_dump(scoutapm_get_calls());
}
?>
--EXPECTF--
bool(true)
should not be logged: function defined in namespace, call implicitly resolves to namespaced function
array(0) {
}
should not be logged - explicit, unimported call to another namespace
array(0) {
}
should not be logged - imported call resolves to namespaced function
array(0) {
}
SHOULD be logged
array(1) {
  [0]=>
  array(5) {
    ["function"]=>
    string(17) "file_get_contents"
    ["entered"]=>
    float(%f)
    ["exited"]=>
    float(%f)
    ["time_taken"]=>
    float(%f)
    ["argv"]=>
    array(1) {
      [0]=>
      string(%d) "%s%etests%e004-namespaced-fgc-is-not-logged.php"
    }
  }
}

Function Calls

None

Variables

None

Stats

MD5 aef78bbc5fffd1656264a3362e1c2e9c
Eval Count 0
Decode Time 95 ms