Default to false removeDuplicates when instantiating Readline #842
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A user experienced this error when using Laravel Tinker:
Cause of bug
The error is caused by line 53 of Transient.php, where the constructor sets the value of $eraseDups.
The constructor has this signature:
Types are not declared(Parent does declare). When this constructor is used with the parameters explicitly being null, it will overwrite defaults in PHP8.0 and greater.
In the constructor body, it sets the value of the eraseDups variable.
This can result in the constructor trying to assign null to the $eraseDups variable. This causes an error as the variable is not declared nullable.
Changes made
Configuration.php
Pass the default value of false when instantiating the ReadLine class in the getReadLine function.
The setEraseDuplicates function type casting was removed. It wasn't related to this bug, but the function signature declares the type as bool, making the cast redundant.
Transient.php
The constructor now sets the value of eraseDups to false if the parameter is null.
The constructor also sets a default history size where the parameter is null.
Updated function signature with types
Readline.php (Interface)
Updated constructor signature with more accurate type declarations.