fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
419 stars 290 forks source link

Deprecated constructor in ChartSex #4915

Closed Jefferson49 closed 6 months ago

Jefferson49 commented 6 months ago

After scanning the webtrees code, my IDE reports a deprecated constructor for the ChartSex class: "'ChartSex' has a deprecated constructor. Methods with the same name as their class will not be constructors in a future version of PHP."

I do not know what the webtrees policy is about those kind of deprecations; just want to report it if it might be of any use.

The deprecated constructor, can be found in the following line: https://github.com/fisharebest/webtrees/blob/main/app/Statistics/Google/ChartSex.php#L41

I do not have an overview what kind of risk might be associated with changing the constructor. As far as I can see, the constructor is only used in one other line of code: https://github.com/fisharebest/webtrees/blob/main/app/Statistics/Repository/IndividualRepository.php#L1935

Jefferson49 commented 6 months ago

Sorry, my issue does not make sense. Just recognized that the method is not a constructor, but rather some kind of static method.

fisharebest commented 6 months ago

The policy is to fix all deprecations as soon as they are discovered, so thanks for reporting!

This one only affects PHP 7.4, and deprecation notices are suppressed in stable releases. So this would only affect someone using a development version of webtrees on PHP 7.4

See https://3v4l.org/8nRYK

The fix would be to add an empty constructor (so that matches the other charts).