Skip to content

Commit 0d3aad0

Browse files
committed
PHP 8.4 NULL deprecations fix
1 parent 8a42bdf commit 0d3aad0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Node.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function getRoot() : Node {
151151
* @param callable|null $shouldDescendIntoChildrenFn
152152
* @return \Generator|Node[]|Token[]
153153
*/
154-
public function getDescendantNodesAndTokens(callable $shouldDescendIntoChildrenFn = null) {
154+
public function getDescendantNodesAndTokens(?callable $shouldDescendIntoChildrenFn = null) {
155155
// TODO - write unit tests to prove invariants
156156
// (concatenating all descendant Tokens should produce document, concatenating all Nodes should produce document)
157157
foreach ($this->getChildNodesAndTokens() as $child) {
@@ -176,7 +176,7 @@ public function getDescendantNodesAndTokens(callable $shouldDescendIntoChildrenF
176176
* @param callable|null $shouldDescendIntoChildrenFn
177177
* @return void
178178
*/
179-
public function walkDescendantNodesAndTokens(callable $callback, callable $shouldDescendIntoChildrenFn = null) {
179+
public function walkDescendantNodesAndTokens(callable $callback, ?callable $shouldDescendIntoChildrenFn = null) {
180180
// TODO - write unit tests to prove invariants
181181
// (concatenating all descendant Tokens should produce document, concatenating all Nodes should produce document)
182182
foreach (static::CHILD_NAMES as $name) {
@@ -209,7 +209,7 @@ public function walkDescendantNodesAndTokens(callable $callback, callable $shoul
209209
* @param callable|null $shouldDescendIntoChildrenFn
210210
* @return \Generator|Node[]
211211
*/
212-
public function getDescendantNodes(callable $shouldDescendIntoChildrenFn = null) {
212+
public function getDescendantNodes(?callable $shouldDescendIntoChildrenFn = null) {
213213
foreach ($this->getChildNodes() as $child) {
214214
yield $child;
215215
if ($shouldDescendIntoChildrenFn === null || $shouldDescendIntoChildrenFn($child)) {
@@ -223,7 +223,7 @@ public function getDescendantNodes(callable $shouldDescendIntoChildrenFn = null)
223223
* @param callable|null $shouldDescendIntoChildrenFn
224224
* @return \Generator|Token[]
225225
*/
226-
public function getDescendantTokens(callable $shouldDescendIntoChildrenFn = null) {
226+
public function getDescendantTokens(?callable $shouldDescendIntoChildrenFn = null) {
227227
foreach ($this->getChildNodesAndTokens() as $child) {
228228
if ($child instanceof Node) {
229229
if ($shouldDescendIntoChildrenFn == null || $shouldDescendIntoChildrenFn($child)) {

src/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected function makeLexer(string $fileContents): TokenStreamProviderInterface
175175
* @param string $fileContents
176176
* @return SourceFileNode
177177
*/
178-
public function parseSourceFile(string $fileContents, string $uri = null) : SourceFileNode {
178+
public function parseSourceFile(string $fileContents, ?string $uri = null) : SourceFileNode {
179179
$this->lexer = $this->makeLexer($fileContents);
180180

181181
$this->reset();

src/Token.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getLeadingCommentsAndWhitespaceText(string $document) : string {
4242
* @param string|null $document
4343
* @return bool|null|string
4444
*/
45-
public function getText(string $document = null) {
45+
public function getText(?string $document = null) {
4646
if ($document === null) {
4747
return null;
4848
}

0 commit comments

Comments
 (0)