Skip to content

Commit

Permalink
return InspectorClass as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Dec 15, 2018
1 parent 1275afb commit 502cfa3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static zend_always_inline zend_bool php_inspector_class_guard(zval *object) {
void php_inspector_class_factory(zend_class_entry *ce, zval *return_value) {
php_reflection_object_t *reflection;

object_init_ex(return_value, reflection_class_ptr);
object_init_ex(return_value, php_inspector_class_ce);

reflection = php_reflection_object_fetch(return_value);
reflection->ptr = ce;
Expand All @@ -57,6 +57,26 @@ void php_inspector_class_factory(zend_class_entry *ce, zval *return_value) {
ZVAL_STR(&v, ce->name);

zend_std_write_property(return_value, &k, &v, NULL);

{
zend_string *name = zend_string_tolower(ce->name);

if (!(ce = zend_hash_find_ptr(EG(class_table), name))) {
reflection->ref_type = PHP_REF_TYPE_PENDING;

php_inspector_table_insert(
PHP_INSPECTOR_ROOT_PENDING,
PHP_INSPECTOR_TABLE_CLASS,
ce->name, return_value);

zend_string_release(name);
return;
}

ce->refcount++;

zend_string_release(name);
}
}
} /* }}} */

Expand Down
2 changes: 1 addition & 1 deletion tests/InspectorMethod/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $inspector =

$inspector = $inspector->getDeclaringClass();

if ($inspector instanceof \ReflectionClass) {
if ($inspector instanceof InspectorClass) {
echo "OK";
}
?>
Expand Down

0 comments on commit 502cfa3

Please sign in to comment.