[BUG]: SPK usage inside own powers does not add use class in the correct place inside the class. #1232

Open
opened 2025-07-14 20:45:40 +00:00 by Tom van der Laan · 0 comments

What Happened?

I added the Joomla Power: Factory inside my own power. When i compiled it. It did not add the use statement to the top of the file rather inside the class tag.

Steps to reproduce the Bug

create new power and add a Joomla SPK inside the function you create.

Expect the use statement to be added to top of the file.

Result:

<?php
	/**
	 * @package    [[[Component]]]
	 *
	 * @created    15th juni, 2025
	 * @author     Tom van der Laan <https://www.tlwebdesign.nl>
	 * @copyright  Copyright (C) 2025. All Rights Reserved
	 * @license    GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
	 *
	 * [[[Component]]] urenregistratie
	 */
	
	namespace [[[Component]]]\Joomla;
	
	
	/**
	 * Helper class for various functions throughout the application
	 */
	class Helpers
	{
	
	/***[JCBGUI.power.main_class_code.922.$$$$]***/use Joomla\CMS\Factory;
	
		public static function getVuser($userId) {
	    $db = Factory::getContainer()->get('DatabaseDriver');

The code inside the gui was:

	public static function getVuser($userId) {
	    $db = Joomla___39403062_84fb_46e0_bac4_0023f766e827___Power::getContainer()->get('DatabaseDriver');

Which Joomla version are you compiling in?

5.3.2

Which PHP version are you compiling in?

8.3

Which Joomla versions are you targeting?

5

Which PHP version are you targeting?

8.3

Which Web server is JCB running on?

Litespeed

Which Relational Database is JCB running on?

MariaDB 11.4

Which OS is JCB running on?

Almalinux

Which JCB version are you using?

5.1.1 stable

Where in JCB did this issue occur?

Compilation of a component

On which browsers did you encounter the issue?

Firefox

Additional Comments

No response

### What Happened? I added the Joomla Power: Factory inside my own power. When i compiled it. It did not add the use statement to the top of the file rather inside the class tag. ### Steps to reproduce the Bug create new power and add a Joomla SPK inside the function you create. Expect the use statement to be added to top of the file. Result: ``` <?php /** * @package [[[Component]]] * * @created 15th juni, 2025 * @author Tom van der Laan <https://www.tlwebdesign.nl> * @copyright Copyright (C) 2025. All Rights Reserved * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html * * [[[Component]]] urenregistratie */ namespace [[[Component]]]\Joomla; /** * Helper class for various functions throughout the application */ class Helpers { /***[JCBGUI.power.main_class_code.922.$$$$]***/use Joomla\CMS\Factory; public static function getVuser($userId) { $db = Factory::getContainer()->get('DatabaseDriver'); ``` The code inside the gui was: ``` public static function getVuser($userId) { $db = Joomla___39403062_84fb_46e0_bac4_0023f766e827___Power::getContainer()->get('DatabaseDriver'); ``` ### Which Joomla version are you compiling in? 5.3.2 ### Which PHP version are you compiling in? 8.3 ### Which Joomla versions are you targeting? 5 ### Which PHP version are you targeting? 8.3 ### Which Web server is JCB running on? Litespeed ### Which Relational Database is JCB running on? MariaDB 11.4 ### Which OS is JCB running on? Almalinux ### Which JCB version are you using? 5.1.1 stable ### Where in JCB did this issue occur? Compilation of a component ### On which browsers did you encounter the issue? Firefox ### Additional Comments _No response_
Tom van der Laan added the
Bug
label 2025-07-14 20:45:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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