The order of your namespace clauses makes a difference here; in the first example, a Database namespace clause is declared before a clause that defines the Models\Model class.
A similar example of this difference can be found in the documentation :
(...) However, the following example causes a fatal error in a name conflict because MyClass is defined in the same file as the use statement.
Individual files or the same file are modeled here by moving the Database namespace lower or higher, respectively.
However, the documentation also states :
As a coding practice, it is highly recommended that you combine multiple namespaces in the same file. The main use case is to combine several PHP scripts into the same file.
Update
Interestingly, this problem is what the Drupal 8 developers recently found out , but according to this, an error report was reported more than two years ago.
A transfer request was sent to solve this problem for the next major version (it can be migrated to 5.x).
JaΝ’ck
source share