Skip to content

Instantly share code, notes, and snippets.

@kdambekalns
Created October 17, 2011 08:39
Show Gist options
  • Save kdambekalns/1292212 to your computer and use it in GitHub Desktop.
Save kdambekalns/1292212 to your computer and use it in GitHub Desktop.
Correct(?) test for PHP bug #55156 (ReflectionClass->getDocComment() returns something though it shouldn't)
<?php
/** test */
namespace foo {
class test { }
$x = new \ReflectionClass('foo\test');
var_dump($x->getDocComment());
// should be false
/** test1 */
class bar { }
/** test2 */
class foo extends namespace\bar { }
class quux { }
$x = new \ReflectionClass('foo\bar');
var_dump($x->getDocComment());
// should be /** test1 */
$x = new \ReflectionClass('foo\foo');
var_dump($x->getDocComment());
// should be /** test2 */
$x = new \ReflectionClass('foo\quux');
var_dump($x->getDocComment());
// should be false
}
?>
karsten@kmac:apc $ php -v
PHP 5.3.8 (cli) (built: Oct 15 2011 19:48:39)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.2.0-dev, Copyright (c) 2002-2011, by Derick Rethans
karsten@kmac:apc $ php ~/phpt55156.php
string(11) "/** test */"
string(12) "/** test1 */"
string(12) "/** test2 */"
bool(false)
karsten@kmac:apc $
@afoeder
Copy link

afoeder commented Oct 17, 2011

my result:

string(11) "/** test /"
string(12) "/
* test1 /"
string(12) "/
* test2 */"
bool(false)

// PHP 5.3.8-ZS5.5.0 (cli) (built: Aug 24 2011 15:25:45)
// Windows 7 SP1

@asm89
Copy link

asm89 commented Oct 17, 2011

~ $ php -v
PHP 5.3.8 with Suhosin-Patch (cli) (built: Sep 30 2011 05:29:37)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
~ $ php /tmp/test.php
string(11) "/** test /"
string(12) "/
* test1 /"
string(12) "/
* test2 */"
bool(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment