PSR-1 namespace entries?

I'm looking for the right way (if that's right, let me know) to write namespaces in PHP classes that follow the PSR-1 standard. I looked around, but saw nothing. The right way to use

Namespace Foo\Bar;

or correctly use curly braces such as

Namespace Foo\Bar
{
    // ....
}

If both are correct, is there a specific reason to use one over the other? I understand that this part can be based on opinions.

+4
source share
2 answers

A copied namespace is the recommended method for defining multiple namespaces in a single file.

, .

PSR-1 , , , .

+2

PSR-1 standrad:

"" PSR: [PSR-0, PSR-4].

, : .

, PHP 5.3 :

:

namespace Vendor\Model;

class Foo
{
}

, PSR-1 , ( ) , PSR-1 .

+2

Source: https://habr.com/ru/post/1584582/


All Articles