File tree Expand file tree Collapse file tree
ext/reflection/tests/gh22681 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in doc comment truncate ReflectionClassConstant::__toString()
3+ --FILE--
4+ <?php
5+
6+ eval (<<<END
7+ class Demo {
8+ /** F \0oo */
9+ public const DEMO = true;
10+ }
11+ END
12+ );
13+
14+ $ r = new ReflectionClassConstant (Demo::class, 'DEMO ' );
15+ echo $ r ;
16+ var_dump ( $ r ->getDocComment () );
17+
18+ echo new ReflectionClass (Demo::class);
19+
20+ ?>
21+ --EXPECTF--
22+ /** F
23+ Constant [ public bool DEMO ] { 1 }
24+ string(11) "/** F%0oo */"
25+ Class [ <user> class Demo ] {
26+ @@ %s(%d) : eval()'d code %d-%d
27+
28+ - Constants [1] {
29+ /** F
30+ Constant [ public bool DEMO ] { 1 }
31+ }
32+
33+ - Static properties [0] {
34+ }
35+
36+ - Static methods [0] {
37+ }
38+
39+ - Properties [0] {
40+ }
41+
42+ - Methods [0] {
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in doc comment truncate ReflectionClass::__toString()
3+ --FILE--
4+ <?php
5+
6+ eval (<<<END
7+ /** F \0oo */
8+ class Demo {}
9+ END
10+ );
11+
12+ $ r = new ReflectionClass (Demo::class);
13+ echo $ r ;
14+ var_dump ( $ r ->getDocComment () );
15+
16+ ?>
17+ --EXPECTF--
18+ /** F
19+ Class [ <user> class Demo ] {
20+ @@ %s(%d) : eval()'d code %d-%d
21+
22+ - Constants [0] {
23+ }
24+
25+ - Static properties [0] {
26+ }
27+
28+ - Static methods [0] {
29+ }
30+
31+ - Properties [0] {
32+ }
33+
34+ - Methods [0] {
35+ }
36+ }
37+ string(11) "/** F%0oo */"
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in name truncate ReflectionConstant::__toString()
3+ --FILE--
4+ <?php
5+
6+ define ("F \0oo " , true );
7+
8+ $ r = new ReflectionConstant ("F \0oo " );
9+ echo $ r ;
10+ var_dump ( $ r ->getName () );
11+
12+ ?>
13+ --EXPECTF--
14+ Constant [ bool F ] { 1 }
15+ string(4) "F%0oo"
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in doc comment truncate ReflectionEnum::__toString()
3+ --FILE--
4+ <?php
5+
6+ eval (<<<END
7+ enum Demo {
8+ /** F \0oo */
9+ case C;
10+ }
11+ END
12+ );
13+
14+ $ r = new ReflectionEnum (Demo::class);
15+ echo $ r ;
16+ var_dump ( new ReflectionEnumUnitCase (Demo::class, 'C ' )->getDocComment () );
17+ ?>
18+ --EXPECTF--
19+ Class [ <user> final class Demo implements UnitEnum ] {
20+ @@ %s(%d) : eval()'d code %d-%d
21+
22+ - Constants [1] {
23+ /** F
24+ Constant [ public Demo C ] { Object }
25+ }
26+
27+ - Static properties [0] {
28+ }
29+
30+ - Static methods [1] {
31+ Method [ <internal, prototype UnitEnum> static public method cases ] {
32+
33+ - Parameters [0] {
34+ }
35+ - Return [ array ]
36+ }
37+ }
38+
39+ - Properties [1] {
40+ Property [ public protected(set) readonly string $name ]
41+ }
42+
43+ - Methods [0] {
44+ }
45+ }
46+ string(11) "/** F%0oo */"
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in INI values truncate ReflectionExtension::__toString()
3+ --FILE--
4+ <?php
5+
6+ ini_set ('arg_separator.output ' , "f \0oo " );
7+ $ r = new ReflectionExtension ('core ' );
8+ $ str = (string )$ r ;
9+ $ index = strpos ($ str , 'Entry [ arg_separator.output ' );
10+ $ str = substr ($ str , $ index );
11+ $ index = strpos ($ str , 'Entry ' , 1 );
12+ $ str = substr ($ str , 0 , $ index );
13+ echo $ str . "\n" ;
14+ var_dump ( $ r ->getINIEntries ()['arg_separator.output ' ] );
15+
16+ ?>
17+ --EXPECTF--
18+ Entry [ arg_separator.output <ALL> ]
19+ Current = 'f'
20+ Default = '&'
21+ }
22+
23+ string(4) "f%0oo"
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in doc comment truncate ReflectionFunctionAbstract::__toString()
3+ --FILE--
4+ <?php
5+
6+ eval (<<<END
7+ /** F \0oo */
8+ function demo() {}
9+
10+ class Demo {
11+ /** B \0ar */
12+ public function demo() {}
13+ }
14+ END
15+ );
16+
17+ $ r = new ReflectionFunction ('demo ' );
18+ echo $ r ;
19+ var_dump ( $ r ->getDocComment () );
20+
21+ $ r = new ReflectionMethod (Demo::class, 'demo ' );
22+ echo $ r ;
23+ var_dump ( $ r ->getDocComment () );
24+
25+ ?>
26+ --EXPECTF--
27+ /** F
28+ Function [ <user> function demo ] {
29+ @@ %s(%d) : eval()'d code %d - %d
30+ }
31+ string(11) "/** F%0oo */"
32+ /** B
33+ Method [ <user> public method demo ] {
34+ @@ %s(%d) : eval()'d code %d - %d
35+ }
36+ string(11) "/** B%0ar */"
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in doc comment truncate ReflectionProperty::__toString()
3+ --FILE--
4+ <?php
5+
6+ eval (<<<END
7+ class Demo {
8+ /** F \0oo */
9+ public \$prop;
10+ }
11+ END
12+ );
13+
14+ $ r = new ReflectionProperty (Demo::class, 'prop ' );
15+ echo $ r ;
16+ var_dump ( $ r ->getDocComment () );
17+
18+ echo new ReflectionClass (Demo::class);
19+
20+ ?>
21+ --EXPECTF--
22+ /** F
23+ Property [ public $prop = NULL ]
24+ string(11) "/** F%0oo */"
25+ Class [ <user> class Demo ] {
26+ @@ %s(%d) : eval()'d code %d-%d
27+
28+ - Constants [0] {
29+ }
30+
31+ - Static properties [0] {
32+ }
33+
34+ - Static methods [0] {
35+ }
36+
37+ - Properties [1] {
38+ /** F
39+ Property [ public $prop = NULL ]
40+ }
41+
42+ - Methods [0] {
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22681: null bytes in name truncate ReflectionProperty::__toString()
3+ --FILE--
4+ <?php
5+
6+ $ obj = (object )["F \0oo " => true ];
7+ $ r = new ReflectionProperty ($ obj , "F \0oo " );
8+ echo $ r ;
9+ var_dump ( $ r ->getDocComment () );
10+
11+ echo new ReflectionObject ($ obj );
12+
13+ ?>
14+ --EXPECT--
15+ Property [ <dynamic> public $F ]
16+ bool(false)
17+ Object of class [ <internal:Core> class stdClass ] {
18+
19+ - Constants [0] {
20+ }
21+
22+ - Static properties [0] {
23+ }
24+
25+ - Static methods [0] {
26+ }
27+
28+ - Properties [0] {
29+ }
30+
31+ - Dynamic properties [1] {
32+ Property [ <dynamic> public $F ]
33+ }
34+
35+ - Methods [0] {
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments