[BUG]: #1193 was closed but still not working #1199

Closed
opened 2025-01-12 10:16:08 +00:00 by gerben65 · 2 comments

What Happened?

#1193 was closed, but is still an problem:

It seems that the JCB's Super Power feature incorrectly is placing additional use statements in the file below defined('_JEXEC') or die; and
#[\AllowDynamicProperties] , resulting in a syntax error.

// No direct access to this file
\defined('_JEXEC') or die;

/**

  • Foaralden Html View class for the Persons
  • @since 1.6
    */
    #[\AllowDynamicProperties]
    use JCB\Joomla\Utilities\ArrayHelper;
    use JCB\Joomla\Utilities\StringHelper;
    class HtmlView extends BaseHtmlView
    {

It seems to occure with the following powers:

use JCB\Joomla\Utilities\ArrayHelper;
use JCB\Joomla\Utilities\StringHelper;

Steps to reproduce the Bug

It occured after adding Add [AllowDynamicProperties] in the base view class for J5 in v5.0.1 alpha 1. With v5.03 all works fine.

Installing on my Synology NAS (Docker) made no difference.

Callstack:

Er heeft zich een fout voorgedaan.
0 syntax error, unexpected token "use"
Call Stack

Function Location

1 () JROOT\administrator\components\com_**\src\View\Familytrees\HtmlView.php:47
2 Composer\Autoload{closure}() JROOT\libraries\vendor\composer\ClassLoader.php:427
3 Composer\Autoload\ClassLoader->loadClass() JROOT\libraries\src\Autoload\ClassLoader.php:59
4 Joomla\CMS\Autoload\ClassLoader->loadClass()
5 class_exists() JROOT\libraries\src\MVC\Factory\MVCFactory.php:299
6 Joomla\CMS\MVC\Factory\MVCFactory->getClassName() JROOT\libraries\src\MVC\Factory\MVCFactory.php:214
7 Joomla\CMS\MVC\Factory\MVCFactory->createView() JROOT\libraries\src\MVC\Controller\BaseController.php:610
8 Joomla\CMS\MVC\Controller\BaseController->createView() JROOT\libraries\src\MVC\Controller\BaseController.php:879
9 Joomla\CMS\MVC\Controller\BaseController->getView() JROOT\libraries\src\MVC\Controller\BaseController.php:656
10 Joomla\CMS\MVC\Controller\BaseController->display() JROOT\administrator\components\com_foaralden\src\Controller\DisplayController.php:52
11 JCB\Component\Foaralden\Administrator\Controller\DisplayController->display() JROOT\libraries\src\MVC\Controller\BaseController.php:731
12 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT\libraries\src\Dispatcher\ComponentDispatcher.php:143
13 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT\libraries\src\Component\ComponentHelper.php:361
14 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT\libraries\src\Application\AdministratorApplication.php:150
15 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT\libraries\src\Application\AdministratorApplication.php:195
16 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT\libraries\src\Application\CMSApplication.php:306
17 Joomla\CMS\Application\CMSApplication->execute() JROOT\administrator\includes\app.php:58
18 require_once() JROOT\administrator\index.php:32

Which Joomla version are you compiling in?

see above

Which PHP version are you compiling in?

8.1

Which Joomla versions are you targeting?

see above

Which PHP version are you targeting?

8.1

Which Web server is JCB running on?

Apache 2.4

Which Relational Database is JCB running on?

MariaDB

Which OS is JCB running on?

xampp/synology

Which JCB version are you using?

see above

Where in JCB did this issue occur?

Compilation of a component

On which browsers did you encounter the issue?

Firefox

Additional Comments

Is it related to #1121?

### What Happened? #1193 was closed, but is still an problem: It seems that the JCB's Super Power feature incorrectly is placing additional use statements in the file below defined('_JEXEC') or die; and #[\AllowDynamicProperties] , resulting in a syntax error. // No direct access to this file \defined('_JEXEC') or die; /** * Foaralden Html View class for the Persons * * @since 1.6 */ #[\AllowDynamicProperties] use JCB\Joomla\Utilities\ArrayHelper; use JCB\Joomla\Utilities\StringHelper; class HtmlView extends BaseHtmlView { It seems to occure with the following powers: use JCB\Joomla\Utilities\ArrayHelper; use JCB\Joomla\Utilities\StringHelper; ### Steps to reproduce the Bug It occured after adding Add [AllowDynamicProperties] in the base view class for J5 in v5.0.1 alpha 1. With v5.03 all works fine. Installing on my Synology NAS (Docker) made no difference. Callstack: Er heeft zich een fout voorgedaan. 0 syntax error, unexpected token "use" Call Stack # Function Location 1 () JROOT\administrator\components\com_**\src\View\Familytrees\HtmlView.php:47 2 Composer\Autoload\{closure}() JROOT\libraries\vendor\composer\ClassLoader.php:427 3 Composer\Autoload\ClassLoader->loadClass() JROOT\libraries\src\Autoload\ClassLoader.php:59 4 Joomla\CMS\Autoload\ClassLoader->loadClass() 5 class_exists() JROOT\libraries\src\MVC\Factory\MVCFactory.php:299 6 Joomla\CMS\MVC\Factory\MVCFactory->getClassName() JROOT\libraries\src\MVC\Factory\MVCFactory.php:214 7 Joomla\CMS\MVC\Factory\MVCFactory->createView() JROOT\libraries\src\MVC\Controller\BaseController.php:610 8 Joomla\CMS\MVC\Controller\BaseController->createView() JROOT\libraries\src\MVC\Controller\BaseController.php:879 9 Joomla\CMS\MVC\Controller\BaseController->getView() JROOT\libraries\src\MVC\Controller\BaseController.php:656 10 Joomla\CMS\MVC\Controller\BaseController->display() JROOT\administrator\components\com_foaralden\src\Controller\DisplayController.php:52 11 JCB\Component\Foaralden\Administrator\Controller\DisplayController->display() JROOT\libraries\src\MVC\Controller\BaseController.php:731 12 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT\libraries\src\Dispatcher\ComponentDispatcher.php:143 13 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT\libraries\src\Component\ComponentHelper.php:361 14 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT\libraries\src\Application\AdministratorApplication.php:150 15 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT\libraries\src\Application\AdministratorApplication.php:195 16 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT\libraries\src\Application\CMSApplication.php:306 17 Joomla\CMS\Application\CMSApplication->execute() JROOT\administrator\includes\app.php:58 18 require_once() JROOT\administrator\index.php:32 ### Which Joomla version are you compiling in? see above ### Which PHP version are you compiling in? 8.1 ### Which Joomla versions are you targeting? see above ### Which PHP version are you targeting? 8.1 ### Which Web server is JCB running on? Apache 2.4 ### Which Relational Database is JCB running on? MariaDB ### Which OS is JCB running on? xampp/synology ### Which JCB version are you using? see above ### Where in JCB did this issue occur? Compilation of a component ### On which browsers did you encounter the issue? Firefox ### Additional Comments Is it related to #1121?
gerben65 added the
Bug
label 2025-01-12 10:16:09 +00:00
Lemuel pinned this 2025-01-12 15:42:53 +00:00
Lemuel unpinned this 2025-01-12 15:42:56 +00:00
Owner

Thank you for raising this issue. After carefully reviewing your report, we’ve tested the same functionality within the environments we use for JCB development, and we have not been able to reproduce the behavior you described. This includes testing the generation of HTMLView.php files where use statements are positioned correctly above the #[\AllowDynamicProperties] tag.

As a team, we develop and test JCB within a consistent environment using Docker deployed via Octojoom, primarily on Ubuntu systems. This is not because we believe this setup is inherently better than others, but simply because it allows us to maintain a reliable and unified environment for development and testing.

Given that we cannot reproduce the issue in our environment, we are unable to diagnose or resolve this problem without further insights. We kindly suggest trying to replicate your setup within a similar environment to ours—specifically using Octojoom with Docker on Ubuntu or Mac to see if the issue persists. If it does, we’d be happy to assist further.

Unfortunately, our current resources do not allow us to investigate or address platform-specific issues outside of this development environment. We hope for your understanding in this matter and deeply value your contributions to improving JCB.

Please let us know if you’d like assistance setting up a similar environment or if you encounter additional issues.

Thank you for raising this issue. After carefully reviewing your report, we’ve tested the same functionality within the environments we use for JCB development, and we have not been able to reproduce the behavior you described. This includes testing the generation of `HTMLView.php` files where `use` statements are positioned correctly above the `#[\AllowDynamicProperties]` tag. As a team, we develop and test JCB within a consistent environment using **Docker** deployed via **Octojoom**, primarily on **Ubuntu** systems. This is not because we believe this setup is inherently better than others, but simply because it allows us to maintain a reliable and unified environment for development and testing. Given that we cannot reproduce the issue in our environment, we are unable to diagnose or resolve this problem without further insights. We kindly suggest trying to replicate your setup within a similar environment to ours—specifically using [Octojoom](https://git.vdm.dev/octoleo/octojoom) with Docker on Ubuntu or Mac to see if the issue persists. If it does, we’d be happy to assist further. Unfortunately, our current resources do not allow us to investigate or address platform-specific issues outside of this development environment. We hope for your understanding in this matter and deeply value your contributions to improving JCB. Please let us know if you’d like assistance setting up a similar environment or if you encounter additional issues.
Owner

We have thoroughly reviewed our code, specifically the logic in Parser.php and Injector.php and can confirm that the dynamic injection of use statements is handled correctly. In our implementation, all use statements are inserted before any class attributes (including #[\AllowDynamicProperties]), as per PHP’s syntax requirements.

In fact, the #[\AllowDynamicProperties] attribute is not part of the dynamic injection logic at all it is included directly in our class templates. Our testing and that of hundreds of developers using JCB across various environments have shown no issues related to the placement of these statements.

If you believe there is a specific scenario where the code misbehaves, please feel free to review the code and submit a pull request with a reproducible test case. We remain committed to maintaining a robust and reliable codebase and welcome any contributions that help improve JCB.

Thank you for your understanding and collaboration.

After OpenAI reviewing both files Parser.php and Injector.php it can confirm the following:

  1. Correct Logic for Use Statement Injection:
    The code in Parser.php (which is responsible for analyzing and preparing the file content) and Injector.php (which actually performs the insertion of dynamic use statements) clearly enforces that all use statements are placed at the top of the file. There is no logic that would ever insert a use statement after an attribute (such as #[\AllowDynamicProperties]). In our codebase, the attribute is applied only immediately before the class declaration, and all dynamic use statements are injected prior to this point.

  2. No Evidence of the Reported Behavior:
    We have not observed any conditions under which the dynamic injection would place the use statements below the attribute. The processing flow in both files has been carefully designed and reviewed. In fact, the AllowDynamicProperties attribute isn’t even part of the dynamic injection logic in our system—it is hard-coded into our class templates where needed.

  3. Invitation for Collaboration:
    Given that our code has been used by hundreds of developers without reproducing the issue, we believe that the reported behavior might be the result of a misinterpretation or an environmental discrepancy rather than a bug in JCB’s logic. We encourage anyone who finds concrete evidence of a misplacement to submit a pull request. The project is open source, and we welcome community contributions that help improve the tool.

We have thoroughly reviewed our code, specifically the logic in [Parser.php](https://git.vdm.dev/joomla/Component-Builder/src/branch/5.x/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Power/Parser.php) and [Injector.php](https://git.vdm.dev/joomla/Component-Builder/src/branch/5.x/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Power/Injector.php) and can confirm that the dynamic injection of `use` statements is handled correctly. In our implementation, all `use` statements are inserted before any class attributes (including `#[\AllowDynamicProperties]`), as per PHP’s syntax requirements. In fact, the `#[\AllowDynamicProperties]` attribute is not part of the dynamic injection logic at all it is included directly in our class templates. Our testing and that of hundreds of developers using JCB across various environments have shown no issues related to the placement of these statements. If you believe there is a specific scenario where the code misbehaves, please feel free to review the code and submit a pull request with a reproducible test case. We remain committed to maintaining a robust and reliable codebase and welcome any contributions that help improve JCB. Thank you for your understanding and collaboration. ## After OpenAI reviewing both files **Parser.php** and **Injector.php** it can confirm the following: 1. **Correct Logic for Use Statement Injection:** The code in **Parser.php** (which is responsible for analyzing and preparing the file content) and **Injector.php** (which actually performs the insertion of dynamic `use` statements) clearly enforces that all `use` statements are placed at the top of the file. There is no logic that would ever insert a `use` statement after an attribute (such as `#[\AllowDynamicProperties]`). In our codebase, the attribute is applied **only** immediately before the class declaration, and **all** dynamic `use` statements are injected prior to this point. 2. **No Evidence of the Reported Behavior:** We have not observed any conditions under which the dynamic injection would place the `use` statements below the attribute. The processing flow in both files has been carefully designed and reviewed. In fact, the `AllowDynamicProperties` attribute isn’t even part of the dynamic injection logic in our system—it is hard-coded into our class templates where needed. 3. **Invitation for Collaboration:** Given that our code has been used by hundreds of developers without reproducing the issue, we believe that the reported behavior might be the result of a misinterpretation or an environmental discrepancy rather than a bug in JCB’s logic. We encourage anyone who finds concrete evidence of a misplacement to submit a pull request. The project is open source, and we welcome community contributions that help improve the tool.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1199
No description provided.