Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

fix Trying to access array offset on value of type nul (7.4) #172

Merged
merged 1 commit into from
Oct 5, 2019
Merged
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
2 changes: 1 addition & 1 deletion src/Scanner/MethodScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ protected function scan()
$tokenType = null;
$tokenContent = $token;
$tokenLine = $tokenLine + substr_count(
$lastTokenArray[1],
$lastTokenArray[1] ?? null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it works, but I would prefer another fix: we shouldn't call substr_count if the first argument is null. This is not a problem now, but when we add strict types it becomes an issue, see: https://www.php.net/substr_count

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a quick trivial fix (keeping same behavior)
But indeed, there is a logic error is this part of the code.

"\n"
); // adjust token line by last known newline count
} else {
Expand Down