php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34078 Reflection API problems in methods with boolean or null default values
Submitted: 2005-08-11 03:37 UTC Modified: 2005-08-11 23:33 UTC
From: leon at lost dot co dot nz Assigned: tony2001 (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-08-11 (dev) OS: Debian Sarge (2.6.12 kernel)
Private report: No CVE-ID: None
 [2005-08-11 03:37 UTC] leon at lost dot co dot nz
Description:
------------
This problem came up when moving our homebrew 'PHPDoc' type class to PHP5.1.  When built with --enable-debug PHP throws up warnings up when the class to be documented ('A' below) contains methods with default values that are either NULL or boolean  

In the code snippet below we get two warnings, one for each default parameter.  Changing the default values to a string or number (even zero) eliminates the warnings.

This is a serious problem for us.  When documenting some of our bigger classes we have seen lots of 'odd' behaviour, including permanent 100% CPU usage by Apache!  It has taken *days* to track down the problem to the snippet below.  If there is anything elso I can do to help fix it please let me know...

Reproduce code:
---------------
$r = new ReflectionClass('A');
$methods = $r->getMethods();
foreach($methods as $method)
{
	$parameters = $method->getParameters();
	foreach($parameters as $p)
	{
		if($p->isDefaultValueAvailable())
			$p->getDefaultValue();
	}
}

class A
{
	function foo($p=null, $q=false)
	{
	}
}

Expected result:
----------------
No output at all -- I've trimed all the output code out.

Actual result:
--------------
$ php bug2.php
Warning: String is not zero-terminated (ZZZZZ?*) (source: /tmp/php5-200508110030/Zend/zend_variables.h:35) in Unknown on line 0
[Thu Aug 11 13:18:58 2005]  Script:  'bug2.php'
---------------------------------------
/tmp/php5-200508110030/Zend/zend_variables.h(35) : Block 0x08514F30 status:
/tmp/php5-200508110030/Zend/zend_variables.c(36) : Actual location (location was relayed)
Beginning:      Cached (allocated on Zend/zend_language_scanner.c:4689, 5 bytes)
      End:      OK
---------------------------------------

Warning: String is not zero-terminated (ZZZZZZ?*) (source: /tmp/php5-200508110030/Zend/zend_variables.h:35) in Unknown on line 0
[Thu Aug 11 13:18:58 2005]  Script:  'bug2.php'
---------------------------------------
/tmp/php5-200508110030/Zend/zend_variables.h(35) : Block 0x085150C8 status:
/tmp/php5-200508110030/Zend/zend_variables.c(36) : Actual location (location was relayed)
Beginning:      Cached (allocated on Zend/zend_language_scanner.c:4689, 6 bytes)
      End:      OK
---------------------------------------



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-11 12:50 UTC] tony2001@php.net
The fix is ready, but we have to wait for Andrey & Dmitry to finish merging of Unicode patches.
 [2005-08-11 22:47 UTC] leon at lost dot co dot nz
Great work!  

I can understand you having to wait to merge into the 5.5/6.0 series, but it would be great if the fix could be pushed into just the 5.1 tree before the next release (beta4? rc4?).

We -- like many other companies -- are waiting for the 5.1 release to move everything from PHP4 to PHP5.  Unfortunately this bug is a 'show stopper' for us right now.
 [2005-08-11 23:18 UTC] tony2001@php.net
Okay, I discussed it with Marcus and committed the fix to 5.0 & 5.1 branches.
I'll commit it to 6.0 too when I'll be able to do it.
 [2005-08-11 23:22 UTC] leon at lost dot co dot nz
As Homer would say: Woo-hoo! You absolutely rock!  I just can't wait for the next 5.1 snapshot...  :-)
 [2005-08-11 23:33 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC