? Ready to take over ? Failure

User tests: Successful: Unsuccessful:

avatar frankmayer
frankmayer
29 Dec 2016

Summary of Changes

This commit is a proof of concept for changing part of the "code standard hell" that exists at the moment, and at the same time, stay backward compatible. It would be great if Joomla 4.0 would be free of it. That would mean that we have to introduce new ones and deprecate(for 4.0) "wrong" property-names, in 3.x, so we can have a clean slate with 4.0.

Why?
Code standards (http://joomla.github.io/coding-standards/?coding-standards/chapters/php.md) say:

Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.

Now, I don't know if this document is out-of-date, but nowadays most properties in Joomla are written in camelCase and from what I see it is the de facto standard.

I accidentally stumbled upon libraries/cms/installer/manifest/library.php and started working on that, in order to assure that its public accessible properties are following a standard.

There were three types in one class alone: camelCase, under_scored and alllowercased.
Now, there is camelCase only. Where applicable, the wrongly named properties have been deprecated and have been referenced to the new variable names, in order to remain backward compatible.

In this PR I have only patched the JInstallerManifest base class, the two subclasses JInstallerManifestLibrary and JInstallerManifestPackage and the JInstaller class. I have intentionally not patched any other code that makes use of those classes and, specifically for this PR, their public properties.

The big thing of course is to try to have an up-to-date coding standard, and really follow that.

Testing Instructions

[EDIT] pls wait on testing. More info below in comment "Important update [1]"
[EDIT] OK, to test now

Install/Uninstall packages and libraries.
Code review

Documentation Changes Required

Yes.

  • in classes
  • in code standards

Note 1

As you may have noticed, for the property-names having URL in them, I chose to go for authorURL instead of authorUrl, which is because URL is an abbreviation of three words and not a word of itself. For that reason IMHO it ought to be URL and not Url. However, that's only my personal opinion and not the most important thing, here, and I am also open to the authorUrl way.

Note 2

There are also issues with xml standards, for example:
packagename or packageurl vs authorEmail or authorUrl in package-xml files.

avatar frankmayer frankmayer - open - 29 Dec 2016
avatar frankmayer frankmayer - change - 29 Dec 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Dec 2016
Category Libraries
avatar frankmayer frankmayer - change - 29 Dec 2016
The description was changed
avatar frankmayer frankmayer - close - 29 Dec 2016
avatar frankmayer frankmayer - reopen - 29 Dec 2016
avatar frankmayer
frankmayer - comment - 29 Dec 2016

Strangest thing, my GitHub account just got flagged...
... I guess that's why the travis tests didn't run after my last commit?

avatar frankmayer frankmayer - close - 29 Dec 2016
avatar frankmayer frankmayer - change - 29 Dec 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-12-29 23:39:00
Closed_By frankmayer
Labels Added: ?
avatar frankmayer frankmayer - close - 29 Dec 2016
avatar frankmayer frankmayer - reopen - 29 Dec 2016
avatar frankmayer frankmayer - change - 29 Dec 2016
Status Closed New
Closed_Date 2016-12-29 23:39:00
Closed_By frankmayer
avatar frankmayer frankmayer - change - 29 Dec 2016
Status New Pending
avatar frankmayer frankmayer - reopen - 29 Dec 2016
avatar frankmayer
frankmayer - comment - 29 Dec 2016

Never seen that one before...
screenshot-github com 2016-12-30 01-22-02

However, I contacted GitHub support and things went back to normal within 20 minutes or so. 👍

avatar mbabker
mbabker - comment - 30 Dec 2016

If I remember right, the JInstallerManifest objects are supposed to map directly to the XML attributes in each extension types manifest. So the one where you are changing from snake case to camel case, this should be done in the XML schema if required with compatibility proxies. The attributes where you are just changing case, it is fine since we are not case sensitive with these declarations.

avatar frankmayer
frankmayer - comment - 30 Dec 2016

Hmm, OK, there seems to be no snake case in the xml mappings, so this shouldn't be an issue, but I think we will need the proxies nevertheless if we want to (and we should) "standardize" camelCase on the xml files also. As of now, the xml files have mixed style tags.

avatar frankmayer
frankmayer - comment - 30 Dec 2016

Important update [1]: Well, it seems I picked just the right one to propose these kind of changes... 😸
So, with the current commit, everything works B/C, but doing a test with fixed cases in the XML-files will not. So, hold your horses for now. Will fix this, soon.
The backward compatibility issue when using corrected XML element names, is fixed now. (with da14e8e)

avatar frankmayer frankmayer - change - 30 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 30 Dec 2016
avatar frankmayer frankmayer - change - 30 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 30 Dec 2016
avatar frankmayer frankmayer - change - 30 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 30 Dec 2016
avatar frankmayer frankmayer - change - 30 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 30 Dec 2016
avatar joomla-cms-bot joomla-cms-bot - change - 30 Dec 2016
Category Libraries Libraries Unit Tests
avatar frankmayer frankmayer - change - 30 Dec 2016
Labels Added: ?
avatar frankmayer frankmayer - change - 31 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 31 Dec 2016
avatar frankmayer frankmayer - change - 31 Dec 2016
The description was changed
avatar frankmayer frankmayer - edited - 31 Dec 2016
avatar photodude
photodude - comment - 1 Jan 2017

@frankmayer I believe you are right and that portion of the Coding standards is out of date. The example for that PHP code page is in mixed-HTML format rather than PHP

Private class members (meaning class members that are intended to be used only from within the same class in which they are declared) are preceded by a single underscore. Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.

I don't believe we follow the single underscore for Private class members anymore since that was more of a php 4 convention and I believe the Properties should be camelCase following the rest of the naming convention.

One thing to watch out for in fixing the snake_case to camelCase naming, is some of those are long-standing names in the database architecture. There has been resistance to fixing those since it will break 3rd party extensions.

avatar frankmayer
frankmayer - comment - 1 Jan 2017

@photodude

I believe you are right and that portion of the Coding standards is out of date. The example for that PHP code page is in mixed-HTML format rather than PHP

Not sure if it's only meant for mixed PHP/HTML as it mentions private class members and properties, which means that classes are involved.

I don't believe we follow the single underscore for Private class members anymore since that was more of a php 4 convention and I believe the Properties should be camelCase following the rest of the naming convention.

That is good to hear. Wasn't sure about this. When we have a confirmation on this, we should definitely change the docs on this.

One thing to watch out for in fixing the snake_case to camelCase naming, is some of those are long-standing names in the database architecture. There has been resistance to fixing those since it will break 3rd party extensions.

Yes, I know. That is why I wrote in the initial description:

This commit is a proof of concept for changing part of the "code standard hell" that exists at the moment, and at the same time, stay backward compatible. It would be great if Joomla 4.0 would be free of it. That would mean that we have to introduce new ones and deprecate(for 4.0) "wrong" property-names, in 3.x, so we can have a clean slate with 4.0.

If we manage to introduce the correct names in the 3.x line and provide BC then we can break BC in 4.0.
Note, that I am not talking on changing DB field names, here. Only the property names.

This PR also has to deal with issues with XML element names, on top of that 😄

avatar mbabker
mbabker - comment - 1 Jan 2017

I don't believe we follow the single underscore for Private class members anymore since that was more of a php 4 convention and I believe the Properties should be camelCase following the rest of the naming convention.

That is good to hear. Wasn't sure about this. When we have a confirmation on this, we should definitely change the docs on this.

FWIW, I think the only part of the code that HAS to retain the underscore notation is JTable. And that's in part thanks to how the database columns are directly set as class variables and a feature in its parent JObject class that treats underscored properties as non-public (so calling $table->getProperties() which does happen in JTable in a couple of places will filter out all of the underscored properties). And without changing the database schema to use camel case column names, you can't really do anything about snake case properties here.

avatar brianteeman brianteeman - change - 8 Jun 2017
Milestone Added:
avatar brianteeman brianteeman - change - 8 Jun 2017
Milestone Added:
avatar brianteeman brianteeman - change - 8 Jun 2017
Milestone Removed:
avatar brianteeman brianteeman - change - 8 Jun 2017
Milestone Removed:
avatar frankmayer
frankmayer - comment - 10 Jun 2017

@brianteeman I saw that you modified the milestone to 4.0. Wouldn't it be better to have these kinds changes done in the 3.9 line and deprecate them before 4.0? It would help to have a cleaner 4.0.

avatar brianteeman
brianteeman - comment - 10 Jun 2017

@frankmayer it was a mistake and I removed it directly afterwards

avatar frankmayer
frankmayer - comment - 10 Jun 2017

@brianteeman ah, yes, and I misread the notification in the timeline. Sorry to bother you. Have a nice day.

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Jul 2019
Title
A stab at class property standardization (assuming camelCase).
[POC] A stab at class property standardization (assuming camelCase).
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Jul 2019
avatar frankmayer frankmayer - change - 23 Sep 2021
Labels Added: ? ? ?
Removed: ? ?
avatar laoneo
laoneo - comment - 12 Mar 2022

Can you rebase this one for 4.2 as we should deprecate now for version 5? It is is not applicable anymore for Joomla 4, please close the pr.

avatar laoneo laoneo - change - 25 Mar 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-03-25 16:09:57
Closed_By laoneo
Labels Added: Ready to take over
Removed: ?
avatar laoneo laoneo - close - 25 Mar 2022

Add a Comment

Login with GitHub to post a comment