Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add @var tag support in dockblocks #41

Closed
wants to merge 1 commit into from
Closed

Add @var tag support in dockblocks #41

wants to merge 1 commit into from

Conversation

red-led
Copy link
Contributor

@red-led red-led commented Feb 7, 2016

Pretty common tag for class variables.

* @param string $variableName
* @return self
*/
public function setVariableName($variableName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this setter, unless strictly required. Making it private is also OK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name is allowed to be null in constructor, so there should be method to set it later. Other tags like @param or @author are working same way.

}

/**
* @return string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/**
* @var string
*/
protected $variableName = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= null redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

class VarTag extends AbstractTypeableTag implements TagInterface
{
/**
* @var string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be null, so should be string|null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

/**
* @return string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{@inheritDoc}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

/**
* @return string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{@inheritDoc}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
public function generate()
{
$output = '@var'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @param array $types
* @param string $description
*/
public function __construct($variableName = null, $types = [], $description = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is $types a TypeGenerator[] here? Can we enforce that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is string or array of strings, passed to\Zend\Code\Generator\DocBlock\Tag\AbstractTypeableTag::setTypes

public function initialize($tagDocblockLine)
{
$match = [];
if (!preg_match('#^(.+)?(\$[\S]+)[\s]*(.*)$#m', $tagDocblockLine, $match)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the [\s]* can be simplified to \s*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@red-led
Copy link
Contributor Author

red-led commented Apr 19, 2017

@Ocramius, updated

@Ocramius Ocramius self-assigned this Jul 23, 2017
@Ocramius Ocramius added this to the 3.2.0 milestone Jul 23, 2017
@Ocramius
Copy link
Member

@red-led this is ready to go. I will still remove any premature mutability (setters) on merge, plus I'll need to rebase, since patch needs to be applied to develop. Expect a merge soon :)

Ocramius added a commit that referenced this pull request Jul 23, 2017
Ocramius added a commit that referenced this pull request Jul 23, 2017
… to prevent misuse, as it is needed for the `TagManager` to work correctly
Ocramius added a commit that referenced this pull request Jul 23, 2017
@Ocramius
Copy link
Member

@red-led thanks, merged manually into develop via cbdd655

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants