No Code Attached Yet
avatar toroworx
toroworx
17 Mar 2022

Declaration of Joomla\CMS\Uri\Uri::buildQuery(array $params) must be compatible with Joomla\Uri\AbstractUri::buildQuery($params)

Steps to reproduce the issue

Setup a local Joomla development environment
https://docs.joomla.org/J4.x:Setting_Up_Your_Local_Environment/

And you'll see the error:
Fatal error: Declaration of Joomla\CMS\Uri\Uri::buildQuery(array $params) must be compatible with Joomla\Uri\AbstractUri::buildQuery($params) in C:\YOURREPOSITORY\joomla-cms\libraries\src\Uri\Uri.php on line 290

One method has the array declaration, the other is indeed missing it. Adding array to Joomla\Uri\AbstractUri::buildQuery($params) in C:\YOURREPOSITORY\joomla-cms\libraries\vendor\joomla\uri\src\AbstractUri.php makes the line read protected static function buildQuery(array $params) and fixes the error.

Notes

Since this is the first time I'm setting up the Joomla repo for development I might do something wrong. I've followed the manual though and I installed it from scratch.

System information (as much as possible)

I've used the current latest Joomla 4.1-dev branch (commit 8b0b6c3)

avatar toroworx toroworx - open - 17 Mar 2022
avatar joomla-cms-bot joomla-cms-bot - change - 17 Mar 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Mar 2022
avatar richard67
richard67 - comment - 17 Mar 2022

@toroworx So you did first close the repository, then checkout the 4.1-dev branch (the document still says the 4.0-dev branch because that's a bit outdated), then run "composer install" and then "npm ci" and then made a new installation of Joomla by calling the URL in the browser so that the installation form is shown?

When and where did you see the error which you reported?

avatar toroworx
toroworx - comment - 17 Mar 2022

When and where did you see the error which you reported?

After a fresh Joomla dev installation. Running XAMPP, but that shouldn't matter for this.
I've used the 4.1-dev branch on a fresh installation. I ran "composer install" and "npm ci". Called the URL in the browser which should show the installation screen, however it showed the error with the funky orange/red Joomla error background. After editing the declaration as mentioned above, I didn't encounter any issues.

I checked the code with PHPStorm which also flagged the incompatible declarations. I suppose the declaration buildQuery($params) of joomla-cms\libraries\vendor\joomla\uri\src\AbstractUri.php is out of date or not edited properly?

avatar richard67
richard67 - comment - 17 Mar 2022

Which PHP version are you using?

avatar toroworx
toroworx - comment - 17 Mar 2022
--   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   | System Information
  | Setting   | Value
  | PHP Built On   | Windows NT MYPC 10.0 build 19044 (Windows 10) AMD64
  | Database Type   | mysql
  | Database Version   | 10.4.22-MariaDB
  | Database Collation   | utf8mb4_general_ci
  | Database Connection Collation   | utf8mb4_general_ci
  | Database Connection Encryption   | None
  | Database Server Supports Connection Encryption   | No
  | PHP Version   | 8.1.2
  | Web Server   | Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/8.1.2
  | WebServer to PHP Interface   | apache2handler
  | Joomla! Version   | Joomla! 4.1.0 Stable [ Kuamini ] 15-February-2022 09:30 GMT
  | User Agent   | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36

Regardless of PHP version I don't think the declarations should differ?

/edit
This patch version is of another patch currently, but I used the latest 4.1-dev version.

avatar richard67
richard67 - comment - 17 Mar 2022

@toroworx PHP 8.1 handles such differences differently than the older PHP versions up to 8.0. In PHP 8.0 and older that did not cause an error.

avatar richard67 richard67 - comment - 17 Mar 2022
avatar toroworx
toroworx - comment - 17 Mar 2022

Sure, I just did the following:

  1. CD into a new joomla-cms folder.
  2. Clone https://github.com/joomla/joomla-cms into the folder using Sourcetree (4.1-dev branch)
  3. Run CMD and CD in the fresh repo.
  4. Run composer install
  5. Run npm ci
  6. Enter localhost/joomla-cms in Chrome.

Now it just works fine without the need to edit anything. Maybe something went wrong after my initial setup. The first time I was struggling with setting up composer and enabling ldap and g2 which I needed to enable manually. Maybe that caused it. So unless somebody else has this issue, I think it can be closed. Thanks for your help, @richard67!

avatar toroworx toroworx - change - 17 Mar 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-03-17 17:44:11
Closed_By toroworx
avatar toroworx toroworx - close - 17 Mar 2022

Add a Comment

Login with GitHub to post a comment