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

[CS] Fixing JImage constants #14402

Closed
wants to merge 4 commits into from

Conversation

piotr-cz
Copy link
Contributor

@piotr-cz piotr-cz commented Mar 7, 2017

Summary of Changes

  1. Switched from hardcoded variables to class constants when checking for crop type
  2. Using static instead of self in methods

This is a coding style change and doesn't have any effects on functionality.
Only change would if one would extend the JImage class: developer doesn't have to define JImage constants again in extended class.

Testing Instructions

The only place where JImage is used in J! core is template editing feature:

  1. Go to Extensions > Templates > Templates > Protostar Details and Files
  2. Click on template_preview.png
  3. Make sure cropping and resizing works as expected

Expected result

Unit suites should pass
Manual tests pass

Actual result

same as expected result

Documentation Changes Required

No changes required

@mbabker
Copy link
Contributor

mbabker commented Mar 8, 2017

From the looks of things, there isn't actually anything gained by calling static::CONSTANT because it's still referring either to itself or a parent class. It's not like late static bindings where it can resolve to a subclass if that's within the class chain, and https://secure.php.net/manual/en/language.oop5.constants.php#104260 seems to support that.

@piotr-cz
Copy link
Contributor Author

piotr-cz commented Mar 8, 2017

What about scenario when I'd extend the JImage class and let's say add extra information in the getImageFileProperties method?

Any code that would call self::getImageFileProperties method would actually call the JImage class, not the extended one at least as I understand it

@mbabker
Copy link
Contributor

mbabker commented Mar 8, 2017

The method calls are fine, it's the constants that I don't think this works on.

@piotr-cz
Copy link
Contributor Author

piotr-cz commented Mar 8, 2017

Looks like you are right.
Constants shouldn't be overwritten in subclass and so referring to them with static keyword is misleading.

@piotr-cz
Copy link
Contributor Author

piotr-cz commented Mar 8, 2017

I've kept static keyword only when referencing methods, however there is one more case - reference to $formats array

@mbabker
Copy link
Contributor

mbabker commented Mar 8, 2017

That one's good, it's not private. Looks fine to me.

@jonasgonka
Copy link
Contributor

Issue can be closed since the modified class is deprecated.
See /libraries/vendor/joomla/image/src:19

@icampus


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14402.

@piotr-cz
Copy link
Contributor Author

Thanks, @jonasgonka
Superseeded by joomla-framework/image#19

@piotr-cz piotr-cz closed this Jul 23, 2018
@piotr-cz piotr-cz deleted the cs/jimage-constants branch July 23, 2018 11:31
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

5 participants