Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is @package required with PHP 5.3 namespaces?

I've switched to PHP 5.3 and the namespaces. It seems like the @package tag is redundant and useless now.

Is it still required by phpDoc, or can I ignore this tag now ?

Thanks

like image 472
Matthieu Napoli Avatar asked Mar 28 '11 18:03

Matthieu Napoli


People also ask

What is the best approach for working with classes and namespaces in PHP?

To address this problem, namespaces were introduced in PHP as of PHP 5.3. The best way to understand namespaces is by analogy to the directory structure concept in a filesystem. The directory which is used to group related files serves the purpose of a namespace.

How does PHP namespace work?

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: Name collisions between code you create, and internal PHP classes/functions/constants or third-party classes/functions/constants.

What is namespace in pho?

Namespaces are qualifiers that solve two different problems: They allow for better organization by grouping classes that work together to perform a task. They allow the same name to be used for more than one class.

Why do we need namespace in PHP?

A namespace is used to avoid conflicting definitions and introduce more flexibility and organization in the code base. Just like directories, namespace can contain a hierarchy know as subnamespaces. PHP uses the backslash as its namespace separator.


1 Answers

It is not required.

Latest doc now states that @package should be avoided if you use namespace and you don't need a different structure for documentation:

If, across the board, both logical and functional subdivisions are equal is it NOT RECOMMENDED to use the @package tag, to prevent maintenance overhead.

http://phpdoc.org/docs/latest/references/phpdoc/tags/package.html

like image 115
PowerKiKi Avatar answered Oct 22 '22 23:10

PowerKiKi