Skip to content

ext/reflection: make getDocComment() methods return empty string instead of false #18928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getDocComment)
RETURN_STR_COPY(((zend_internal_function *) fptr)->doc_comment);
}

RETURN_FALSE;
RETURN_EMPTY_STRING();
}
/* }}} */

Expand Down Expand Up @@ -4006,7 +4006,7 @@ ZEND_METHOD(ReflectionClassConstant, getDocComment)
if (ref->doc_comment) {
RETURN_STR_COPY(ref->doc_comment);
}
RETURN_FALSE;
RETURN_EMPTY_STRING();
}
/* }}} */

Expand Down Expand Up @@ -4411,7 +4411,7 @@ ZEND_METHOD(ReflectionClass, getDocComment)
if (ce->doc_comment) {
RETURN_STR_COPY(ce->doc_comment);
}
RETURN_FALSE;
RETURN_EMPTY_STRING();
}
/* }}} */

Expand Down Expand Up @@ -6335,7 +6335,7 @@ ZEND_METHOD(ReflectionProperty, getDocComment)
if (ref->prop && ref->prop->doc_comment) {
RETURN_STR_COPY(ref->prop->doc_comment);
}
RETURN_FALSE;
RETURN_EMPTY_STRING();
}
/* }}} */

Expand Down
8 changes: 4 additions & 4 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getClosureCalledClass(): ?ReflectionClass {}
public function getClosureUsedVariables(): array {}

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

/** @tentative-return-type */
public function getEndLine(): int|false {}
Expand Down Expand Up @@ -286,7 +286,7 @@ public function getStartLine(): int|false {}
public function getEndLine(): int|false {}

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

/** @tentative-return-type */
public function getConstructor(): ?ReflectionMethod {}
Expand Down Expand Up @@ -537,7 +537,7 @@ public function getModifiers(): int {}
public function getDeclaringClass(): ReflectionClass {}

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

/** @tentative-return-type */
public function setAccessible(bool $accessible): void {}
Expand Down Expand Up @@ -615,7 +615,7 @@ public function getModifiers(): int {}
public function getDeclaringClass(): ReflectionClass {}

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

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

Expand Down
46 changes: 23 additions & 23 deletions ext/reflection/php_reflection_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/reflection/tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ foreach($r->getMethods() as $m)
--EXPECT--
string(19) "Comment for class A"
string(15) "Method A::bla()"
bool(false)
bool(false)
string(0) ""
string(0) ""
string(22) "* Comment for A::baz()"
6 changes: 3 additions & 3 deletions ext/reflection/tests/ReflectionClassConstant_basic1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ object(ReflectionClass)#3 (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""
hasType():
bool(false)
getType():
Expand Down Expand Up @@ -177,7 +177,7 @@ object(ReflectionClass)#3 (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""
hasType():
bool(false)
getType():
Expand Down Expand Up @@ -209,7 +209,7 @@ object(ReflectionClass)#3 (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""
hasType():
bool(false)
getType():
Expand Down
8 changes: 4 additions & 4 deletions ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ string(26) "/** My DocComment for B */"


---> Doc comment for class C:
bool(false)
string(0) ""


---> Doc comment for class D:
bool(false)
string(0) ""


---> Doc comment for class E:
bool(false)
string(0) ""


---> Doc comment for class F:
bool(false)
string(0) ""


---> Doc comment for class G:
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/tests/ReflectionClass_toString_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Stringable, Refle

- Parameters [0] {
}
- Tentative return [ string|false ]
- Tentative return [ string ]
}

Method [ <internal:Reflection> public method getConstructor ] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ var_dump((new ReflectionClassConstant(Foo::class, 'Baz'))->getDocComment());
?>
--EXPECT--
string(26) "/** Example doc comment */"
bool(false)
string(0) ""
string(26) "/** Example doc comment */"
bool(false)
string(0) ""
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ dumpFuncInfo('extract');
string(%d) "/**
* my doc comment
*/"
bool(false)
bool(false)
string(0) ""
string(0) ""
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ string(%d) "/**


---> Doc comment for B::f():
bool(false)
string(0) ""


---> Doc comment for B::privf():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ string(24) "/**
* doc 1
*/"
X::y
bool(false)
string(0) ""
X::z
string(12) "/** doc 2 */"
8 changes: 4 additions & 4 deletions ext/reflection/tests/ReflectionProperty_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object(ReflectionClass)#%d (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""

**********************************
**********************************
Expand All @@ -78,7 +78,7 @@ object(ReflectionClass)#%d (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""

**********************************
**********************************
Expand Down Expand Up @@ -116,7 +116,7 @@ object(ReflectionClass)#%d (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""

**********************************
**********************************
Expand All @@ -134,6 +134,6 @@ object(ReflectionClass)#%d (1) {
string(9) "TestClass"
}
getDocComment():
bool(false)
string(0) ""

**********************************
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ string(%d) "/**


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


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


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


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


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


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


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


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


---> Doc comment for B::$e:
Expand Down
Loading