Skip to content

Prado::using() loads a namespaced class only an autoloader finds - #1686

Merged
ctrlaltca merged 1 commit into
pradosoft:masterfrom
belisoful:master-using-autoload
Nov 29, 2026
Merged

ctrlaltca merged 1 commit into
pradosoft:masterfrom
belisoful:master-using-autoload

Conversation

@belisoful

@belisoful belisoful commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Prado::using(), and so Prado::usingClass(), returned null for a namespaced class that was not loaded yet when no class map entry or path alias named it, such as a class Composer autoloads. A component configured by such a class name was rejected. In pradosoft/prado-rpc, a TRpcService provider given as an application's Composer class failed this way, as did the default Prado\\Web\\Services\\TRpcServer before it was loaded. prado-rpc works around it in pradosoft/prado-rpc#2.

  • After the class map and path alias lookups find nothing, using() loads a namespaced class, interface, or trait through the registered autoloaders. One attempt is made per name: an autoloader loads all three kinds by name.
  • Prado::autoload() calls using(). PHP does not autoload a name again while it is autoloading it, so a name no autoloader finds still returns null without recursion.
  • Tests: a class, an interface, and a trait under the Composer-autoloaded Prado\\Test\\Unit\\Harness\\Autoload namespace that nothing loads earlier. There are also tests for an unknown name through autoload() and for a directory namespace without *. The three load tests fail without the fix.
  • HISTORY.md entry.

The same fix for 4.3.3 is #1685 on prado-4.3. Checked: php-cs-fixer passes and the unit suite passes. One pgsql test failed in the full run because another local run dropped the shared test database; it passes alone. PHPStan reports two trait.unused errors in Util/Behaviors/TNoUnserialize*Trait.php, files this PR does not touch.

@ctrlaltca
ctrlaltca merged commit b039711 into pradosoft:master Nov 29, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants