-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Stop using deprecated defaultOption method #228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
php: | ||
- '7.4' | ||
- '8.0' | ||
- '8.1' | ||
- '8.2' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,22 +33,25 @@ abstract class LatLongParserBase implements ValueParser { | |
*/ | ||
public const OPT_SEPARATOR_SYMBOL = 'separator'; | ||
|
||
/** | ||
* @var ParserOptions | ||
*/ | ||
private $options; | ||
private ParserOptions $options; | ||
|
||
public function __construct( ?ParserOptions $options = null ) { | ||
$this->options = $options ?: new ParserOptions(); | ||
|
||
$this->options->defaultOption( ValueParser::OPT_LANG, 'en' ); | ||
$this->defaultOption( ValueParser::OPT_LANG, 'en' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for preferring the private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was the quickest fix |
||
|
||
$this->options->defaultOption( self::OPT_NORTH_SYMBOL, 'N' ); | ||
$this->options->defaultOption( self::OPT_EAST_SYMBOL, 'E' ); | ||
$this->options->defaultOption( self::OPT_SOUTH_SYMBOL, 'S' ); | ||
$this->options->defaultOption( self::OPT_WEST_SYMBOL, 'W' ); | ||
$this->defaultOption( self::OPT_NORTH_SYMBOL, 'N' ); | ||
$this->defaultOption( self::OPT_EAST_SYMBOL, 'E' ); | ||
$this->defaultOption( self::OPT_SOUTH_SYMBOL, 'S' ); | ||
$this->defaultOption( self::OPT_WEST_SYMBOL, 'W' ); | ||
|
||
$this->options->defaultOption( self::OPT_SEPARATOR_SYMBOL, ',' ); | ||
$this->defaultOption( self::OPT_SEPARATOR_SYMBOL, ',' ); | ||
} | ||
|
||
private function defaultOption( string $option, mixed $default ): void { | ||
if ( !$this->options->hasOption( $option ) ) { | ||
$this->options->setOption( $option, $default ); | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also works, but I couldn't be bothered in this case