Arquivos
hhvm/hphp/test/ext/debugger_tests/info.php
T
Sara Golemon 13a055efa4 Add gen-class-map.cpp for bootstrapping constants.h and class_map.cpp
Conversion of PHP versions so we don't need PHP to build HHVM

For the most part, the generated files haven't changed from the
PHP sourced versions (apart from minor indentation and whitespace
changes).

Except for one major exception:
An IDL's function/method argument list includes a "value" field
for default parameters which takes psuedo-serialized values in
several forms. Most are simple scalarish values like:
  "true", "null", "null_array", "null_variant",
  "123", "0x456", "0123", "1.23", "\"foo\""
However referencing other constants is also supported:
  "k_FOO", "q_Bar$$BAZ"
Or even bitmask compositions like:
  "k_FOO|k_BAR|k_BAZ"

Runtime uses of these values are encoded directly into *.ext_hhvm.cpp
files, so they reach userspace code just fine.

The value placed in g_class_map are used exclusively by ext_reflection
to allow introspection at runtime.  Under the old class_map.php parameter
default constant references would be resolved in a (somewhat buggy) eval(),
since we don't have eval within gen-class-map, we reuse the
kUnserializable deferral.

This diff provides a mechanism to resolve this in ReflectionMethod
uses (an improvement from previous behavior), and leaves the current
eval-on-demand behavior for ReflectionFunction.  These two code paths
are different due to the partial state of migration away from using
ClassInfo.
2013-06-12 15:38:53 -07:00

62 linhas
1.7 KiB
PHP

<?php
require_once("hphpd.php");
error_log("");
error_log("In test ".$_SERVER['PHP_SELF']);
$client = get_client("info", "debugger_tests");
if (!$client) {
error_log("No client!");
echo FAIL;
return;
}
function info1($c) {
// Built-in
$c->processCmd('@', null);
$o = $c->processCmd('info', array('array_key_exists'));
VS(trim($o['text']), '/**
* ( excerpt from http://php.net/manual/en/function.array_key_exists.php )
* array_key_exists() returns TRUE if the given key is set in the array.'.
' key can be any value possible for an array index.
*
* @key mixed Value to check.
* @search mixed An array with keys to check.
*
* @return bool Returns TRUE on success or FALSE on failure.
*/
function array_key_exists($key, $search);');
$o = $c->processCmd('info', array('stdClass'));
VS(strpos($o['text'], "class stdClass {\n}") > 0, true);
}
function info2($c) {
// User-defined
$c->processCmd('@', null);
$o = $c->processCmd('info', array('myfunc'));
VS(strpos($o['text'], 'function myfunc($a, $b);') > 0, true);
$o = $c->processCmd('info', array('MyClass'));
VS(strpos($o['text'], "class MyClass {") > 0, true);
$o = $c->processCmd('info', array('MyClass::pub'));
VS(strpos($o['text'], 'public $pub;') > 0, true);
$o = $c->processCmd('info', array('MyClass::pro'));
VS(strpos($o['text'], 'protected $pro;') > 0, true);
$o = $c->processCmd('info', array('MyClass::pri'));
VS(strpos($o['text'], 'private $pri;') > 0, true);
}
try {
info1($client);
$client->processCmd('@', array('include(\'info_t.php\')'));
info2($client);
$o = $client->processCmd('quit', null);
VS($o, true);
echo PASS;
} catch (TestFailure $t) {
error_log($t);
echo FAIL;
} catch (Exception $e) {
error_log($e);
echo FAIL;
}