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

Add omit property value type #131

Merged

Conversation

janvernieuwe
Copy link
Contributor

Fixes #28

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

@janvernieuwe since this is an improvement, could you please target develop?

return $output . ';';
}

$output .= ' = ' . ($defaultValue !== null ? $defaultValue->generate() : 'null;');
Copy link
Member

Choose a reason for hiding this comment

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

Can return directly here

@@ -50,6 +50,7 @@ class ValueGenerator extends AbstractGenerator
const TYPE_CONSTANT = 'constant';
const TYPE_NULL = 'null';
const TYPE_OBJECT = 'object';
const TYPE_OMIT = 'omit';
Copy link
Member

Choose a reason for hiding this comment

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

omit is not really a type

$output .= $this->indentation . $this->getVisibility() . ($this->isStatic() ? ' static' : '') . ' $' . $name;

if ($this->defaultValue instanceof PropertyValueGenerator &&
$this->defaultValue->getType() === ValueGenerator::TYPE_OMIT) {
Copy link
Member

Choose a reason for hiding this comment

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

$this->defaultValue->omitType() instead - that gets rid of the ugly constant too ;-)

public function testOmitType()
{
$property = new PropertyGenerator('test', null);
$property->setDefaultValue(null, ValueGenerator::TYPE_OMIT);
Copy link
Member

Choose a reason for hiding this comment

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

That's really really ugly. Would rather prefer ->removeDefaultValue() or ->omitDefaultValue() instead of having a ValueGenerator with special purposes (there is a big impedance between the concept of a value generator and the concept of a lack of value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove the constant, and move it to a property in the PropertyGenerator.

Copy link
Member

Choose a reason for hiding this comment

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

If you look at the other comments, I suggest not touching the PropertyGenerator at all

@janvernieuwe janvernieuwe changed the base branch from master to develop October 3, 2017 13:28
@janvernieuwe
Copy link
Contributor Author

I'm not too sure about how omitDefaultValue is better implemented, see the last commit.

@Ocramius
Copy link
Member

Ocramius commented Oct 3, 2017

@janvernieuwe the idea is to have the PropertyGenerator and ParameterGenerator have the public function omitDefaultValue() :-)

use a property instead of constant
@Ocramius Ocramius self-assigned this Oct 3, 2017
@Ocramius Ocramius added this to the 3.3.0 milestone Oct 3, 2017
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@Ocramius Ocramius merged commit e1808d1 into zendframework:develop Oct 3, 2017
@Ocramius
Copy link
Member

Ocramius commented Oct 3, 2017

Thanks @janvernieuwe \o/

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