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

Replace get/setSex with get/setGender #95

Closed
wants to merge 8 commits into from

Conversation

heiglandreas
Copy link
Contributor

As explained in #94 it's a good idea to use gender instead of sex.

To not break BC the get/setSex are still available but are marked as deprecated. The current functionality works as before. In addition to that it is possible to set other as gender and the default now is to return unknown instead of NULL.

As explained in #94 it's a good idea to use gender instead of sex. 

To not break BC the get/setSex are still available but are marked as deprecated. The current functionality works as before. In addition to that it is possible to set `other` as gender and the default now is to return `unknown` instead of NULL.
*/
protected $sex;
protected $gender = GENDER_UNKNOWN;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be self::GENDER_UNKNOWN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You got me there! Sure!

if ($sex !== self::SEX_MALE && $sex !== self::SEX_FEMALE) {
throw new \InvalidArgumentException('Argument $sex is not valid');
$genders = [
GENDER_OTHER,
Copy link
Contributor

Choose a reason for hiding this comment

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

All constants should have static:: prefix.

GENDER_MALE,
GENDER_FEMALE,
];
if (! $gender in_array($genders)) {
Copy link
Contributor

@ADmad ADmad Sep 15, 2019

Choose a reason for hiding this comment

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

This isn't valid code :)

heiglandreas and others added 7 commits September 15, 2019 18:55
Such things happen when you try to code in github...
As they are already used removing them is a BC break that we do not want!
This removes the calls to get/setSex with the appropriate get/setGender
calls. Tests are now again passing
The removed docBlock contains redundant information and was therefore
removed
@heiglandreas
Copy link
Contributor Author

heiglandreas commented Sep 15, 2019

The removal of the protected proprety $sex as well as modifying the return-type of the method getSex from ?string to string is technically a BC break.

As the method now does no longer return null any checks expecting null can still be executed on the returned value, so it's not really going to break code.

And the removal of the $sex property only is a BC break for classes that extend the User-class. Currently that should not have happened. For the future I would advise to either mark the class as final or set the visibility of the properties to private instead of public or protected

See result of docker run --rm -v $PWD:/app nyholm/roave-bc-check

[BC] REMOVED: Property SocialConnect\Common\Entity\User#$sex was removed
[BC] CHANGED: The return type of SocialConnect\Common\Entity\User#getSex() changed from ?string to string
[BC] REMOVED: Property SocialConnect\Common\Entity\User#$sex was removed
[BC] CHANGED: The return type of SocialConnect\Common\Entity\User#getSex() changed from ?string to string
4 backwards-incompatible changes detected

@ovr ovr closed this Jan 29, 2020
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.

3 participants