似乎不存在的命名空间正在工作,但为什么呢?

Namespace that seems it doesn't exist is working but why?

我有这个练习文件夹,其中提供了有关如何安装 Web 应用程序的说明:

因此此文件夹包含一个 .sh 文件,用于安装必要的东西:

npm install
curl -o phpunit -L https://phar.phpunit.de/phpunit-7.phar
chmod +x phpunit
./phpunit --version

所以基本上这会在根文件夹中添加一个名为 phpunit 的文件。所以到目前为止我有点了解发生了什么,所以这安装了节点依赖项并安装了 phpunit(我认为是这样),但是这个项目有一个测试示例单元:

<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

final class HelloWorldTest extends TestCase
{
  public function testWhenGetDataFromHelloWorld(): void
  {
    $this->assertEquals('Hello World', 'Hello World');
  }
}

此时我不知道 use PHPUnit\Framework\TestCase; 是如何工作的,因为我没有任何名为 PHPUnit 的文件夹,我知道 use 就像导入 class,但是,这仍然是如何工作的(当我 运行 测试时它没有给我任何类型的错误)?另外,似乎 vscode 将导入检测为错误,因为好像不存在

我的文件树如下:

有人可以解释一下吗?

这是因为所有依赖项都在 phpunit-7.phar 文件中,该文件被该脚本命名为 phpunit

"The easiest way to obtain PHPUnit is to download a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file."

PHPUnit - Installing PHPUnit - PHP Archive (PHAR)