|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
??? ?? 1999, Version 4.0 Beta 2
+- Added get_class($obj), get_parent_class($obj) and method_exists($obj,"name")
+ (Andi & Zeev)
+- Fixed various inheritance problems (Andi & Zeev, libzend)
- Children now inherit their parent's constructor, if they do not supply a
constructor of their own.
- Fixed runtime inheritence of classes (parent methods/properties were
PHP_FE(is_string, first_arg_allow_ref)
PHP_FE(is_array, first_arg_allow_ref)
PHP_FE(is_object, first_arg_allow_ref)
+ PHP_FE(get_class, NULL)
+ PHP_FE(get_parent_class, NULL)
+ PHP_FE(method_exists, NULL)
PHP_FE(leak, NULL)
PHP_FE(error_log, NULL)
}
-PHP_FUNCTION(is_long) { php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_LONG); }
-PHP_FUNCTION(is_double) { php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_DOUBLE); }
-PHP_FUNCTION(is_string) { php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_STRING); }
-PHP_FUNCTION(is_array) { php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_ARRAY); }
-PHP_FUNCTION(is_object) { php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_OBJECT); }
+PHP_FUNCTION(is_long)
+{
+ php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_LONG);
+}
+
+PHP_FUNCTION(is_double)
+{
+ php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_DOUBLE);
+}
+
+PHP_FUNCTION(is_string)
+{
+ php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_STRING);
+}
+
+PHP_FUNCTION(is_array)
+{
+ php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_ARRAY);
+}
+
+PHP_FUNCTION(is_object)
+{
+ php3_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_OBJECT);
+}
+
+PHP_FUNCTION(get_class)
+{
+ pval *arg;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)==FAILURE) {
+ RETURN_FALSE;
+ }
+ if (arg->type != IS_OBJECT) {
+ RETURN_FALSE;
+ }
+ RETURN_STRINGL(arg->value.obj.ce->name, arg->value.obj.ce->name_length, 1);
+}
+
+PHP_FUNCTION(get_parent_class)
+{
+ pval *arg;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)==FAILURE) {
+ RETURN_FALSE;
+ }
+ if ((arg->type != IS_OBJECT) || !arg->value.obj.ce->parent) {
+ RETURN_FALSE;
+ }
+ RETURN_STRINGL(arg->value.obj.ce->parent->name, arg->value.obj.ce->parent->name_length, 1);
+}
+PHP_FUNCTION(method_exists)
+{
+ pval *arg1, *arg2;
+
+ if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
+ RETURN_FALSE;
+ }
+ if (arg1->type != IS_OBJECT) {
+ RETURN_FALSE;
+ }
+ convert_to_string(arg2);
+ RETURN_LONG(zend_hash_exists(&arg1->value.obj.ce->function_table, arg2->value.str.val, arg2->value.str.len+1));
+}
PHP_FUNCTION(leak)
{
PHP_FUNCTION(is_array);
PHP_FUNCTION(is_object);
+PHP_FUNCTION(get_class);
+PHP_FUNCTION(get_parent_class);
+PHP_FUNCTION(method_exists);
+
PHP_FUNCTION(leak);
PHP_FUNCTION(error_log);
PHP_FUNCTION(soundex)
{
char *somestring;
- int i, small, len, code, last;
+ int i, _small, len, code, last;
pval *arg;
char soundex[4 + 1];
/* build soundex string */
last = -1;
- for (i = 0, small = 0; i < len && small < 4; i++) {
+ for (i = 0, _small = 0; i < len && _small < 4; i++) {
/* convert chars to upper case and strip non-letter chars */
/* BUG: should also map here accented letters used in non */
/* English words or names (also found in English text!): */
/* esstsett, thorn, n-tilde, c-cedilla, s-caron, ... */
code = toupper(somestring[i]);
if (code >= 'A' && code <= 'Z') {
- if (small == 0) {
+ if (_small == 0) {
/* remember first valid char */
- soundex[small++] = code;
+ soundex[_small++] = code;
last = soundex_table[code - 'A'];
}
else {
code = soundex_table[code - 'A'];
if (code != last) {
if (code != 0) {
- soundex[small++] = code;
+ soundex[_small++] = code;
}
last = code;
}
}
}
/* pad with '0' and terminate with 0 ;-) */
- while (small < 4) {
- soundex[small++] = '0';
+ while (_small < 4) {
+ soundex[_small++] = '0';
}
- soundex[small] = '\0';
+ soundex[_small] = '\0';
- return_value->value.str.val = estrndup(soundex, small);
- return_value->value.str.len = small;
+ return_value->value.str.val = estrndup(soundex, _small);
+ return_value->value.str.len = _small;
return_value->type = IS_STRING;
}
/* }}} */
<?
+define("endl","\n");
+
+if (1) {
class foobar {
function foobar() {
- print "foobar!\n";
$this->initialized = 1;
}
};
+class barbara extends foobar {
+
+};
+}
+
$foo = new foobar; // or die("Unable to construct foobar\n");
-print $foo->initialized;
+//print $foo->initialized;
+
+$boo = new barbara;
+print get_class($foo).endl;
+print get_parent_class($foo).endl;
+print get_class($boo).endl;
+print get_parent_class($boo).endl;
+print method_exists($foo,"foobar").endl;
+print method_exists($boo,"foobar").endl;
+print method_exists($boo,"barbara").endl;
//$word = new COm("word.application");
//$word->visible = true;
//sleep(5);