Skip to content

Commit 3e71793

Browse files
committed
Add nullable type hints to setters and Since ctor
Add explicit nullable type declarations for optional parameters to improve type safety: Argument::set_param_tag(?Param), Hook::set_doc_comment(?\PhpParser\Comment\Doc), Hook::set_changelog(?Changelog), and Since::__construct(..., ?string $description, ?PhpDocSince $tag). No runtime behavior changes—just stronger typing.
1 parent 36efce6 commit 3e71793

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Argument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function get_param_tag() {
8080
*
8181
* @param Param|null $param_tag Param tag.
8282
*/
83-
public function set_param_tag( Param $param_tag = null ) {
83+
public function set_param_tag( ?Param $param_tag = null ) {
8484
$this->param_tag = $param_tag;
8585
}
8686

src/Hook.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function get_doc_comment() {
130130
*
131131
* @param \PhpParser\Comment\Doc|null $doc_comment Doc comment.
132132
*/
133-
public function set_doc_comment( \PhpParser\Comment\Doc $doc_comment = null ) {
133+
public function set_doc_comment( ?\PhpParser\Comment\Doc $doc_comment = null ) {
134134
$this->doc_comment = $doc_comment;
135135
}
136136

@@ -286,7 +286,7 @@ public function get_changelog() {
286286
*
287287
* @param Changelog|null $changelog Changelog.
288288
*/
289-
public function set_changelog( Changelog $changelog = null ) {
289+
public function set_changelog( ?Changelog $changelog = null ) {
290290
$this->changelog = $changelog;
291291
}
292292

src/Since.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Since {
4848
* @param string|null $description Description.
4949
* @param PhpDocSince|null $tag Tag.
5050
*/
51-
public function __construct( $version, $description = null, $tag = null ) {
51+
public function __construct( $version, ?string $description = null, ?PhpDocSince $tag = null ) {
5252
$this->version = $version;
5353
$this->description = $description;
5454
$this->tag = $tag;

0 commit comments

Comments
 (0)