Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d03aa48

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 d03aa48

16 files changed

+61
-61
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():

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /