class MyClass { // Class implementation here. } $reflection = new ReflectionClass('MyClass'); $filename = $reflection->getFilename(); echo $filename; // Prints the filename of MyClass file.
require_once 'vendor/autoload.php'; use PHPUnit\Framework\TestCase; class MyTest extends TestCase { // Test implementation here. } $reflection = new ReflectionClass('MyTest'); $filename = $reflection->getFilename(); echo $filename; // The path to PHPUnit\Framework\TestCase file.In this example, the ReflectionClass::getFilename() method is used to retrieve the file name of the parent class of MyTest which is PHPUnit\Framework\TestCase. The method is called on the ReflectionClass instance of the MyTest class. Package/Library: PHPUnit - a popular testing framework for PHP.