[BUG]: use statement before namespace declaration #1121
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#1121
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What Happened?
In com_/src/Controller/DisplayController.php, the first lines of the file (after the initial comment) are the following:
as you can see, we have 2 issues:
Changing the statement order and removing the second use of ArrayHelper, fixes the issues.
Similar issue in com_/src/Helper/RouteHelper.php:
Putting as first instruction the namespace declaration fixes the issue.
Steps to reproduce the Bug
Compile the component
Which Joomla version are you compiling in?
3.10.12
Which PHP version are you compiling in?
8.2.2
Which Joomla versions are you targeting?
4.4.4
Which PHP version are you targeting?
8.2.4
Which Web server is JCB running on?
Apache 2.4
Which Relational Database is JCB running on?
MySql 8.0
Which OS is JCB running on?
Windows 11
Which JCB version are you using?
3.2.1-rc5
Where in JCB did this issue occur?
Compilation of a component
On which browsers did you encounter the issue?
Firefox, Chrome
Additional Comments
Maybe related to #1117? Same context
Can you please run Joomla 3 on PHP 8.0 and only use Firefox to run compilation of your components.
There are known issues with Joomla 3 in higher versions of PHP, specially related to the File and Folder classes across multiple OS.
We have a class that search for existing
use
statements and then try to add the new statements to them. So if it can't find any it looks for thedefined('_JEXEC') or die('Restricted access');
and then adds the statements there. This is what I see is going wrong here... why I am not sure.Here is the Injector->addUseStatements method that is doing this. You will see the fail-save is on line 563 which is causing this issue... we can improve this, but my real question is why is it not able to detect the other use statements correctly in the first place. Since this works on all our systems (we only run on Linux) I am wondering if this is OS related. I would be very grateful if you can help us debug this some more...
The class extracting the use statements is our own little parser. We opt for our own small parser for this task since all the other parsers are so large and really over kill. It could be that since I am looking for a class declaration we are missing it.
Let me know what you find.
I've updated to 3.2.1-rc6 version.
And manually replaced the compiler folder just to be sured that it's up to date.
I've downgraded php to 8.0.27 version (of course, I always use Firefox to compile).
Here is the generated file
And the RouterHelper.php file