PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null

From: Date: Mon, 23 Oct 2000 08:53:34 +0000
Subject: PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null
Groups: php.dev 
Request: Send a blank email to php-dev+get-35848@lists.php.net to get a copy of this message
ID: 6741 User Update by: ping@alt.it Status: Analyzed Bug Type: Documentation problem Description: gettype of 'user function' returns null This bug now can be circumvented by using the new method_exixts() functionof PHP4. It is only viable for class methods though. I think that for backward compatibility, and to keep in line with the old and new documentation, it shouldn't be too hard to have gettype() return 'user function' too. Otherwise relegate it as a docu error and thanks for the help Meanwile I posted a new version of the php4 implementation of 'remote scripting' that uses 'method_exixts()? instead on php-general list and am awaitimg a feedback from the original author. Previous Comments: --------------------------------------------------------------------------- [2000-10-22 12:27:57] ping@alt.it This missing functionality actually breaks the PHP 'remote scripting' interface, as discussed some time ago in the php mailing list See messages about 'remote scripting' starting at http://marc.theaimsgroup.com/?l=php-general&m=92113045423518&w=2 --------------------------------------------------------------------------- [2000-10-19 12:05:02] ping@alt.it It was not me who invented this function, although I've been using it since 3.12. It is quite useful for marshallizing and serializing things, and it gives a bit of introspection to PHP. And as in PHP4 the developers have thought to increase the scope of gettype() to new types as 'properties', which are still a bit of a mystery, I thought the old ones would still work. Nevertheless $myclass->b in the esample above is an integer variable, better said an 'object property', and not a string (PHP3) nor NULL (PHP4). --------------------------------------------------------------------------- [2000-10-18 06:07:59] stas@php.net What should be working? Function is not a variable, what type do you expect to get from there? Do you want PHP also to return gettype($if) as "PHP language construct" and gettype($Bill_Clinton) as "US president"? gettype returns types of variables, that's it - it can not return type of whatever object that is not a variable. --------------------------------------------------------------------------- [2000-10-15 11:28:15] jmoore@php.net I would not say this is a docu problem but a scripting engine problem, This behaviour should really be working, I dont think the docu's should be changed just because it doesnt, instead it should be fixed. James --------------------------------------------------------------------------- [2000-09-25 20:34:08] ping@alt.it more examples: <? $z=33; function normal() { $a=1; } class class1 { function classfunction1() { $b=2; } } $myclass=new class1; echo "myfunction is of type ", gettype($myclass->classfunction1),"<br>n"; echo "b is of type ", gettype($myclass->b),"<br>n"; echo "z is of type ", gettype($z),"<br>n"; echo "normal is of type ", gettype($normal),"<br>n"; echo "class1 is of type ", gettype($class1),"<br>n"; echo "myclass is of type ", gettype($myclass),"<br>n"; echo "classfunction1 is of type ", gettype($classfunction1),"<br>n"; ?> this piece of code, run both on PHP 3.0.12 and PHP 4.0.2 gives these different results: ouput by PHP 3 .0.12: myfunction is of type user function b is of type string z is of type integer normal is of type string class1 is of type string myclass is of type object classfunction1 is of type string output by PHP 4.02: myfunction is of type NULL b is of type NULL z is of type integer normal is of type NULL class1 is of type NULL myclass is of type object classfunction1 is of type NULL --------------------------------------------------------------------------- The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online. Full Bug description available at: http://bugs.php.net/?id=6741

« previous php.dev (#35848) next »