在PHP中用名称空间扩展类时,是否应该对类使用相同的名称?

在PHP中用名称空间扩展类时,是否应该对类使用相同的名称?,php,class,namespaces,extends,Php,Class,Namespaces,Extends,假设我有一门课: class Person { public function doSeomthing() { // ... } } 我想使用自己的名称空间扩展这个类以添加额外的功能。使用相同的类名是好主意还是坏主意?例如: 命名空间自定义 class Person extends \Person { public function doSomethingElse() { // ... } } 我特别感兴趣的是PSR标准对此的感受。使用相同的类名,或名

假设我有一门课:

class Person
{
  public function doSeomthing()
  {
    // ...
  }
}
我想使用自己的名称空间扩展这个类以添加额外的功能。使用相同的类名是好主意还是坏主意?例如:

命名空间自定义

class Person extends \Person
{
  public function doSomethingElse()
  {
    // ...
  }
}

我特别感兴趣的是PSR标准对此的感受。

使用相同的类名,或
名称冲突
是名称空间专门设计用来解决的问题之一


只要它是您的名称空间,我认为您应该命名它,因为它对您更有意义。
In the PHP world, namespaces are designed to solve two problems that authors 
of libraries and applications encounter when creating re-usable code elements 
such as classes or functions:

1.Name collisions between code you create, and internal PHP 
classes/functions/constants or third-party classes/functions/constants.

2. Ability to alias (or shorten) Extra_Long_Names designed to alleviate 
the first problem, improving readability of source code.