Skip to content
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

Add default value for new parameter #53

Merged
merged 1 commit into from
Jul 29, 2020
Merged

Add default value for new parameter #53

merged 1 commit into from
Jul 29, 2020

Conversation

garak
Copy link
Collaborator

@garak garak commented Jul 29, 2020

For BC

@garak garak requested a review from JellyBellyDev July 29, 2020 11:38
src/Poser.php Outdated
@@ -34,7 +34,7 @@ public function __construct($renders)
* @param $style
* @param $format
*/
public function generate(string $subject, string $status, string $color, string $style, string $format): Image
public function generate(string $subject, string $status, string $color, string $style, string $format = 'svg'): Image
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use null value here and assign it on svg if null inside of the methods? And it will be better to use Badge::DEFAULT_FORMAT here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what's the point of passing null and assigning value later?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If anybody extends Poser class, then default value may be different then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can't be different even now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wrong, you may overwrite default value in extended class. Just saw this way of defining default values very frequently and thought it's protecting vs this case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

in my opinion, it's okay to set the default here, but I'd use the constant Badge::DEFAULT_FORMAT

src/Poser.php Outdated
@@ -34,7 +34,7 @@ public function __construct($renders)
* @param $style
* @param $format
*/
public function generate(string $subject, string $status, string $color, string $style, string $format): Image
public function generate(string $subject, string $status, string $color, string $style, string $format = 'svg'): Image
Copy link
Collaborator

Choose a reason for hiding this comment

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

in my opinion, it's okay to set the default here, but I'd use the constant Badge::DEFAULT_FORMAT

@JellyBellyDev
Copy link
Collaborator

@garak please update the changelog! Thanks!

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Copy link
Collaborator

@JellyBellyDev JellyBellyDev left a comment

Choose a reason for hiding this comment

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

LGTM

@JellyBellyDev JellyBellyDev merged commit ded7ae4 into master Jul 29, 2020
@JellyBellyDev JellyBellyDev deleted the garak-patch-1 branch July 29, 2020 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants