Skip to content

Commit b08f4d1

Browse files
committed
ext/reflection: make getDocComment() methods return empty string instead of false
Returning false is just annoying for non-existent doc comment
1 parent d6fc743 commit b08f4d1

14 files changed

+58
-58
lines changed

‎ext/reflection/php_reflection.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getDocComment)
20352035
RETURN_STR_COPY(((zend_internal_function *) fptr)->doc_comment);
20362036
}
20372037

2038-
RETURN_FALSE;
2038+
RETURN_EMPTY_STRING();
20392039
}
20402040
/* }}} */
20412041

@@ -4006,7 +4006,7 @@ ZEND_METHOD(ReflectionClassConstant, getDocComment)
40064006
if (ref->doc_comment) {
40074007
RETURN_STR_COPY(ref->doc_comment);
40084008
}
4009-
RETURN_FALSE;
4009+
RETURN_EMPTY_STRING();
40104010
}
40114011
/* }}} */
40124012

@@ -4411,7 +4411,7 @@ ZEND_METHOD(ReflectionClass, getDocComment)
44114411
if (ce->doc_comment) {
44124412
RETURN_STR_COPY(ce->doc_comment);
44134413
}
4414-
RETURN_FALSE;
4414+
RETURN_EMPTY_STRING();
44154415
}
44164416
/* }}} */
44174417

@@ -6335,7 +6335,7 @@ ZEND_METHOD(ReflectionProperty, getDocComment)
63356335
if (ref->prop && ref->prop->doc_comment) {
63366336
RETURN_STR_COPY(ref->prop->doc_comment);
63376337
}
6338-
RETURN_FALSE;
6338+
RETURN_EMPTY_STRING();
63396339
}
63406340
/* }}} */
63416341

‎ext/reflection/php_reflection.stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getClosureCalledClass(): ?ReflectionClass {}
6060
public function getClosureUsedVariables(): array {}
6161

6262
/** @tentative-return-type */
63-
public function getDocComment(): string|false {}
63+
public function getDocComment(): string {}
6464

6565
/** @tentative-return-type */
6666
public function getEndLine(): int|false {}
@@ -286,7 +286,7 @@ public function getStartLine(): int|false {}
286286
public function getEndLine(): int|false {}
287287

288288
/** @tentative-return-type */
289-
public function getDocComment(): string|false {}
289+
public function getDocComment(): string {}
290290

291291
/** @tentative-return-type */
292292
public function getConstructor(): ?ReflectionMethod {}
@@ -537,7 +537,7 @@ public function getModifiers(): int {}
537537
public function getDeclaringClass(): ReflectionClass {}
538538

539539
/** @tentative-return-type */
540-
public function getDocComment(): string|false {}
540+
public function getDocComment(): string {}
541541

542542
/** @tentative-return-type */
543543
public function setAccessible(bool $accessible): void {}
@@ -615,7 +615,7 @@ public function getModifiers(): int {}
615615
public function getDeclaringClass(): ReflectionClass {}
616616

617617
/** @tentative-return-type */
618-
public function getDocComment(): string|false {}
618+
public function getDocComment(): string {}
619619

620620
public function getAttributes(?string $name = null, int $flags = 0): array {}
621621

‎ext/reflection/php_reflection_arginfo.h

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ext/reflection/tests/005.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ foreach($r->getMethods() as $m)
4949
--EXPECT--
5050
string(19) "Comment for class A"
5151
string(15) "Method A::bla()"
52-
bool(false)
53-
bool(false)
52+
string(0) ""
53+
string(0) ""
5454
string(22) "* Comment for A::baz()"

‎ext/reflection/tests/ReflectionClassConstant_basic1.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ object(ReflectionClass)#3 (1) {
145145
string(9) "TestClass"
146146
}
147147
getDocComment():
148-
bool(false)
148+
string(0) ""
149149
hasType():
150150
bool(false)
151151
getType():
@@ -177,7 +177,7 @@ object(ReflectionClass)#3 (1) {
177177
string(9) "TestClass"
178178
}
179179
getDocComment():
180-
bool(false)
180+
string(0) ""
181181
hasType():
182182
bool(false)
183183
getType():
@@ -209,7 +209,7 @@ object(ReflectionClass)#3 (1) {
209209
string(9) "TestClass"
210210
}
211211
getDocComment():
212-
bool(false)
212+
string(0) ""
213213
hasType():
214214
bool(false)
215215
getType():

‎ext/reflection/tests/ReflectionClass_getDocComment_001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ string(26) "/** My DocComment for B */"
7373

7474

7575
---> Doc comment for class C:
76-
bool(false)
76+
string(0) ""
7777

7878

7979
---> Doc comment for class D:
80-
bool(false)
80+
string(0) ""
8181

8282

8383
---> Doc comment for class E:
84-
bool(false)
84+
string(0) ""
8585

8686

8787
---> Doc comment for class F:
88-
bool(false)
88+
string(0) ""
8989

9090

9191
---> Doc comment for class G:

‎ext/reflection/tests/ReflectionClass_toString_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Stringable, Refle
119119

120120
- Parameters [0] {
121121
}
122-
- Tentative return [ string|false ]
122+
- Tentative return [ string ]
123123
}
124124

125125
Method [ <internal:Reflection> public method getConstructor ] {

‎ext/reflection/tests/ReflectionEnumUnitCase_getDocComment.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ var_dump((new ReflectionClassConstant(Foo::class, 'Baz'))->getDocComment());
1818
?>
1919
--EXPECT--
2020
string(26) "/** Example doc comment */"
21-
bool(false)
21+
string(0) ""
2222
string(26) "/** Example doc comment */"
23-
bool(false)
23+
string(0) ""

‎ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ dumpFuncInfo('extract');
3838
string(%d) "/**
3939
* my doc comment
4040
*/"
41-
bool(false)
42-
bool(false)
41+
string(0) ""
42+
string(0) ""

‎ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ string(%d) "/**
8888

8989

9090
---> Doc comment for B::f():
91-
bool(false)
91+
string(0) ""
9292

9393

9494
---> Doc comment for B::privf():

‎ext/reflection/tests/ReflectionMethod_getDocComment_property_list.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ string(24) "/**
3636
* doc 1
3737
*/"
3838
X::y
39-
bool(false)
39+
string(0) ""
4040
X::z
4141
string(12) "/** doc 2 */"

‎ext/reflection/tests/ReflectionProperty_basic2.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ object(ReflectionClass)#%d (1) {
6060
string(9) "TestClass"
6161
}
6262
getDocComment():
63-
bool(false)
63+
string(0) ""
6464

6565
**********************************
6666
**********************************
@@ -78,7 +78,7 @@ object(ReflectionClass)#%d (1) {
7878
string(9) "TestClass"
7979
}
8080
getDocComment():
81-
bool(false)
81+
string(0) ""
8282

8383
**********************************
8484
**********************************
@@ -116,7 +116,7 @@ object(ReflectionClass)#%d (1) {
116116
string(9) "TestClass"
117117
}
118118
getDocComment():
119-
bool(false)
119+
string(0) ""
120120

121121
**********************************
122122
**********************************
@@ -134,6 +134,6 @@ object(ReflectionClass)#%d (1) {
134134
string(9) "TestClass"
135135
}
136136
getDocComment():
137-
bool(false)
137+
string(0) ""
138138

139139
**********************************

‎ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ string(%d) "/**
5050

5151

5252
---> Doc comment for A::$b:
53-
bool(false)
53+
string(0) ""
5454

5555

5656
---> Doc comment for A::$c:
57-
bool(false)
57+
string(0) ""
5858

5959

6060
---> Doc comment for A::$d:
@@ -64,7 +64,7 @@ string(%d) "/**
6464

6565

6666
---> Doc comment for A::$e:
67-
bool(false)
67+
string(0) ""
6868

6969

7070
---> Doc comment for A::$f:
@@ -74,15 +74,15 @@ string(%d) "/**
7474

7575

7676
---> Doc comment for B::$a:
77-
bool(false)
77+
string(0) ""
7878

7979

8080
---> Doc comment for B::$b:
8181
string(%d) "/** A doc comment for $b */"
8282

8383

8484
---> Doc comment for B::$c:
85-
bool(false)
85+
string(0) ""
8686

8787

8888
---> Doc comment for B::$e:

0 commit comments

Comments
 (0)