Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see a lot of "#@+" & "#@-" strings in the comments of the some Magento 2 classes. \Magento\Customer\Api\Data\AttributeMetadataInterface

interface AttributeMetadataInterface extends \Magento\Framework\Api\MetadataObjectInterface
{
    /**#@+
     * Constants used as keys of data array
     */
    const ATTRIBUTE_CODE = 'attribute_code';
    ...
    const IS_SEARCHABLE_IN_GRID = 'is_searchable_in_grid';
    /**#@-*/
    ...
}

What is the purpose of these markers?

share|improve this question

Those characters are used to declare a PHPDoc DocBlock template:

The purpose of a DocBlock template is to reduce redundant typing. For instance, if a large number of class variables are private, one would use a DocBlock template to mark them as private. DocBlock templates simply augment any normal DocBlocks found in the template block.

A DocBlock template is distinguished from a normal DocBlock by its header.

/**#@+
 *
 */

The text that marks this as a DocBlock template is "/**#@+" - all 6 characters must be present. DocBlock templates are applied to all documentable elements until the ending template marker:

/**#@-*/

Note that all 8 characters must appear as "/**#@-*/" in order for phpDocumentor to recognize them as a template.

More information can be found here: http://codingexplained.com/coding/php/how-to-use-docblock-templates-in-phpdoc

Some explanations are also available on the official Magento documentation: http://devdocs.magento.com/guides/v2.0/coding-standards/docblock-standard-general.html

share|improve this answer

If there is declaration of multiple consecutive elements of same type, the same contents of DocBlock may be relevant to all of them. In this case individual DocBlocks for those elements they may be replaced by a DocBlock template.

DocBlock template consists of two DocBlock comments:

Starting comment is before first element of the group, distinguished using #@+ and formatted as follows:

/**#@+
 *
 */

Ending comment is after the last element of the group, distinguished using #@- and formatted as follows:/**#@-*/

For example, declaration of multiple class constants or attributes:

class Mage_Core_Model_Layout extends Varien_Simplexml_Config
{
    /**#@+
     * Supported layout directives
     * @var string
     */
    const TYPE_BLOCK = 'block';
    const TYPE_CONTAINER = 'container';
    /**#@-*/

    /**#@+
     * Scheduled structure elements operations
     *
     * @var array
     */
    protected $scheduledMoves   = array();
    protected $scheduledRemoves = array();
    /**#@-*/

Reference here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.