User tests: Successful: Unsuccessful:
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.
[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
Yes.
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.
There are also issues with xml standards, for example:
packagename
or packageurl
vs authorEmail
or authorUrl
in package-xml files.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-12-29 23:39:00 |
Closed_By | ⇒ | frankmayer | |
Labels |
Added:
?
|
Status | Closed | ⇒ | New |
Closed_Date | 2016-12-29 23:39:00 | ⇒ | |
Closed_By | frankmayer | ⇒ |
Status | New | ⇒ | Pending |
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.
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.
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)
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
|
@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.
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
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.
Milestone |
Added: |
Milestone |
Added: |
Milestone |
Removed: |
Milestone |
Removed: |
@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.
@frankmayer it was a mistake and I removed it directly afterwards
@brianteeman ah, yes, and I misread the notification in the timeline. Sorry to bother you. Have a nice day.
Title |
|
Labels |
Added:
?
?
?
Removed: ? ? |
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.
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: ? |
Strangest thing, my GitHub account just got flagged...
... I guess that's why the travis tests didn't run after my last commit?