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
[4.2] Change Codestyle to PSR-12 #37686
Conversation
|
Firstly let me say - AWESOME - this is long overdue. Is the plan once the inital big changes have been done to add automated testing with fixes on all future pr. It will make life so much easier. |
If I figure out how to do it I would say yes. (hound wasn't too successful ;-) /fyi @nikosdion @PhilETaylor if you like to have a look if I broke something completely (at least the tests are working) |
|
Would it be possible to change this into two seperate pr. One for the changed files and one for the build/psr12 scripts I suspect its the scripts only that need commenting on (I know I have a few to make) but its impossible to do that here oin github as there are so many files it crashes the browser. |
|
build\psr12.editorconfig is this an intentional commit as we already have an almost identical one in the root of the filesystem and having two both with root=true that are not the same can cause conflicts |
|
I am sad to see the completely unreadable Egyptian braces being used in control structures. I moved out of that particular code style 12 years ago and reduced the number of my bugs by half. The biggest problem is the Regarding this PR, um, there are 1809 files. Trying to find what you added among all these files is the very definition to a needle in a haystack. Can you please point out what you added so we can figure out what we are seeing? |
it looks like its the build\psr12\ folder |
As brian sad I added the files in build/psr12 that's the scripts that do the complete conversation. It should be enough to run only convert_psr12.php. in the script you have an option array at the beginning first run (disable clean) then commit @brianteeman I will move the PSR12 directory to the other pr #37681 on the next run. You are right the .editorconfig have to be moved to the root folder (it changes the indent_style to space and the indent_size to 4) |
|
not a massive fan of some of the changes but I am a fan of standardisation. The one that really concerns me is the removal of the jexec or die check which appears to be in conflict with #PROD2020/023 - Policy for Full Path Disclosure |
😢 |
strange please create the directory build/tmp/psr12 ... it should be created automatically but seems to fail... oh it could be because the |
Thats what I was just checking and shouldnt it be ROOT/tmp/psr12 ? |
no in the build directory |
|
ok well just tested by manually creating the folder build/tmp/psr12 and that gets rid of PHP Warning: file_put_contents just need to get rid of the php notice on checkpath |
That doesn't effect this because the style checker doesn't allow executable code in the same file as a symbol is defined. So we remove defined or die only in files that have only classes defined. In this there will be no code executed so we don't have a path disclosure. |
ok cool. As you know its hard to check properly here on github the exact contents of the file |
the checkpath just not initialized, actually I didn't tested this code path it should allow us to check only one file/path (comma separated multiple pathes). I fixed that in my local branch already. (just add a $checkPath = false; into the 8th line) |
That's true so it's better to check the PR out in phpstorm (or what ever you use) and check it locally. |
Which I did although even vscode balked at the number of files in review mode |
Correct first word and simplify drone comment. no need to say after complete as its only displayed then. |
I assume that this should be checking all the folders in $baseFolders it is not. It is only checking the last entry |
|
Maybe I'm wrong? |
|
@ReLater I hear you but as long as corrections are dont automatically I dont care |
|
@nikosdion I added you readonly to the repo that should work for codeowners. At least that's writte in https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners But the validation on the codeowners file fails... so it seems still not possible to add someone as codeowner without write permissions. |
|
@HLeithner Ah, bugger. I guess trying to implement a notification (like at-tagging us in the comments) in the automation that assigns labels to PRs is a tall ask, right? I have no idea how that automation works to be honest, I don't even know where its code is, I am just thinking out loud. |
|
Wait, I realised that you commented before I accepted the invite to the repo. Can you double check that the validation still fails? |
I checked it with hannes who also as no write permssion to the repo but was in the organisation. |
This is done in jissues (at least I think it is...) https://github.com/joomla/jissues tbh I never touched this and I personally would like to get rid because no one once to maintain it... but some people like it because it has some features which github doesn't have.... |
|
Yeah, I never understood why we have an issue tracker which is simply an interface to GitHub. The biggest pain for me is when I test a PR I have to go to that site to log my test result otherwise it does not appear on GitHub. I understand the context it was created in — back then GitHub's search was infantile at best. It's just there's no longer a need for it; GitHub can do all the important things and has a powerful search which actually works! |
While definitely true when it was created I would be interested to know what features are still missing. More than likely they do exist on github we just havent implemented them |
at least 2, tests marking and it seems the Categories are used but that's off-topic here |
|
Does this mean that this is now postponed until 4.3? |
not necessary because actually no code change ;-) sadly I'm busy at the moment with other Joomla stuff and paid work, so this 2 prs have to wait a bit |
f2ef82d
to
8d7ccf4
Compare

Pull Request is based on #37681 and continues the work on the PSR-12 move.
This PR introduces a convert script from Joomla coding standard to PSR-12 coding standard. It also converts most of the Joomla! CMS code base to PSR-12.
Motion PROD2021/004: Update the code style to PSR12 as early as possible but latest for 5.0
Motivation
The change of the code style is a long standing issue. Mainly because the last upgrade of the code style is still not completed. On the other side it doesn't make sense to maintain our own code style, mainly because it needs resources to keep the code style up to date to PHP features. So the easiest way is to take a well known code style and move the CMS (and all other Joomla source codes) to this. PSR-12 is maybe not perfect and not everyone likes every part of it but it's the created by the PHP-FIG where Joomla! is part of, so it's obvious to take the "own" and most used one.
Summary of Changes
defined('*') or diewhere it's forbidden and doesn't make senseThe new ruleset.xml can be found at it's temporary location
build/psr12/ruleset.xmlin the same directory are the convert und cleanup script.Testing Instructions
Actual result BEFORE applying this Pull Request
Works
Expected result AFTER applying this Pull Request
Still works
Documentation Changes Required
Additional tasks
Existing PRs
I'm searching for a way to make the transition so painless as possible.
It's maybe possible to run the script before on the own branch, maybe if possible I create PR against each PR automatically which solves the merge conflicts by updating the changed files. Ideas are welcomed.
Annotation for Testers