? Pending

User tests: Successful: Unsuccessful:

avatar piotr-cz
piotr-cz
7 Mar 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

avatar piotr-cz piotr-cz - open - 7 Mar 2017
avatar piotr-cz piotr-cz - change - 7 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 7 Mar 2017
Category Libraries
avatar mbabker
mbabker - comment - 8 Mar 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.

avatar piotr-cz
piotr-cz - comment - 8 Mar 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

avatar mbabker
mbabker - comment - 8 Mar 2017

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

avatar piotr-cz
piotr-cz - comment - 8 Mar 2017

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

avatar piotr-cz piotr-cz - change - 8 Mar 2017
Labels Added: ?
avatar piotr-cz
piotr-cz - comment - 8 Mar 2017

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

avatar mbabker
mbabker - comment - 8 Mar 2017

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

avatar jonasgonka
jonasgonka - comment - 23 Jul 2018

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.

avatar piotr-cz
piotr-cz - comment - 23 Jul 2018

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

avatar piotr-cz piotr-cz - change - 23 Jul 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-07-23 11:31:28
Closed_By piotr-cz
avatar piotr-cz piotr-cz - close - 23 Jul 2018

Add a Comment

Login with GitHub to post a comment