PHP 8.1: Uncaught scenarios with ReflectionClass::newInstanceWithoutConstructor on Namespaced Classes
I'm prototyping a solution and I've searched everywhere and can't find a clear answer. Does anyone know how to I'm working with an behavior when using `ReflectionClass::newInstanceWithoutConstructor()` on a namespaced class in PHP 8.1... The goal is to instantiate an object without invoking its constructor, but I'm getting an `Uncaught behavior: Class 'Namespace\MyClass' not found` when trying to create an instance. Here's the relevant code snippet: ```php namespace Namespace; class MyClass { public function __construct() { echo 'Constructor called'; } } $reflectionClass = new \ReflectionClass('Namespace\MyClass'); $instance = $reflectionClass->newInstanceWithoutConstructor(); // The following line throws an behavior var_dump($instance); ``` I've verified that the class name is spelled correctly, and I've also checked my autoloading configuration in `composer.json`: ```json { "autoload": { "psr-4": { "Namespace\\": "src/" } } } ``` After running `composer dump-autoload`, I still receive the behavior. I've ensured that the file structure matches PSR-4 expectations, with `MyClass.php` located in the `src/Namespace/` directory. Additionally, I've tried using `class_exists('Namespace\MyClass')` before instantiation, which returns `true`. What could be causing this scenario? Is there a specific characteristic of the namespaced class that I'm overlooking when using Reflection in PHP 8.1? I recently upgraded to Php 3.10. This is for a desktop app running on Ubuntu 20.04. How would you solve this?