Exemplo n.º 1
0
	KValueRef KPHPArrayObject::Get(const char *name)
	{
		if (KList::IsInt(name))
		{
			unsigned int index = (unsigned int) atoi(name);
			if (index >= 0)
				return this->At(index);
		}

		unsigned long hashval = zend_get_hash_value((char *) name, strlen(name));
		zval **copyval;

		if (zend_hash_quick_find(Z_ARRVAL_P(this->list),
					(char *) name,
					strlen(name),
					hashval,
					(void**)&copyval) == FAILURE)
		{
			return Value::Undefined;
		}

		TSRMLS_FETCH();
		KValueRef v = PHPUtils::ToKrollValue((zval *) copyval TSRMLS_CC);
		return v;
	}
Exemplo n.º 2
0
		
		return filteredNames;
	}

	zval* KPHPObject::ToPHP()
	{
		return this->object;
	}

	bool KPHPObject::PropertyExists(const char* property TSRMLS_DC)
	{
		unsigned int propertyLength = strlen(property);
		zend_class_entry* classEntry = Z_OBJCE_P(object);

		// Check in the class entry for the property.
		ulong hashEntry = zend_get_hash_value(property, propertyLength + 1);
		zend_property_info* propertyInfo;
		if (SUCCESS == zend_hash_quick_find(&classEntry->properties_info,
			property, propertyLength + 1,
			hashEntry, (void **) &propertyInfo))
		{
			return propertyInfo->flags & ZEND_ACC_SHADOW;
		}

		// Check with the has_property handler in the class for the property.
		zval zPropertyName;
		ZVAL_STRINGL(&zPropertyName, property, propertyLength, 0);
		return (Z_OBJ_HANDLER_P(object, has_property) &&
			Z_OBJ_HANDLER_P(object, has_property)(object, &zPropertyName, 2 TSRMLS_CC));
	}
	
Exemplo n.º 3
0
  | Modified by Dmitry Zenovich <*****@*****.**>                    |
  +----------------------------------------------------------------------+
*/

/* $Id$ */

#include "php_runkit.h"
#include "php_runkit_zval.h"

#ifdef PHP_RUNKIT_MANIPULATION

#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
/* {{{ php_runkit_make_object_property_public */
static inline void php_runkit_make_object_property_public(const char *propname, int propname_len, zend_object *object, int offset, zend_property_info *property_info_ptr TSRMLS_DC) {
	zval *prop_val = NULL;
	long h = zend_get_hash_value((char *) propname, propname_len + 1);
	if (!object->properties) {
		prop_val = object->properties_table[offset];
		rebuild_object_properties(object);
	} else if (object->properties_table[offset]) {
		prop_val = *(zval **) object->properties_table[offset];
	}
	if ((property_info_ptr->flags & (ZEND_ACC_PRIVATE | ZEND_ACC_PROTECTED | ZEND_ACC_SHADOW)) && prop_val) {
		Z_ADDREF_P(prop_val);
		if (h != property_info_ptr->h) {
			zend_hash_quick_del(object->properties, property_info_ptr->name, property_info_ptr->name_length+1, property_info_ptr->h);
		}
		zend_hash_quick_update(object->properties, propname, propname_len+1, h,
				 &prop_val, sizeof(zval *), (void *) &object->properties_table[offset]);
		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Making %s::%s public to remove it "
				 "from class without objects overriding", object->ce->name, propname);