Skip to content

Commit

Permalink
[OptionsParser] Renamed OptionsParser to OptionsResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed May 14, 2012
1 parent 04522ca commit 256b708
Show file tree
Hide file tree
Showing 27 changed files with 134 additions and 133 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -42,7 +42,7 @@
"symfony/http-foundation": "self.version",
"symfony/http-kernel": "self.version",
"symfony/locale": "self.version",
"symfony/options-parser": "self.version",
"symfony/options-resolver": "self.version",
"symfony/process": "self.version",
"symfony/routing": "self.version",
"symfony/security": "self.version",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Expand Up @@ -19,7 +19,7 @@
use Symfony\Bridge\Doctrine\Form\EventListener\MergeDoctrineCollectionListener;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

abstract class DoctrineType extends AbstractType
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Propel1/Form/Type/ModelType.php
Expand Up @@ -15,7 +15,7 @@
use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

/**
* ModelType class.
Expand Down
Expand Up @@ -26,7 +26,7 @@
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToBooleanArrayTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class ChoiceType extends AbstractType
{
Expand Down
Expand Up @@ -21,7 +21,7 @@
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class DateTimeType extends AbstractType
{
Expand Down
Expand Up @@ -22,7 +22,7 @@
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
use Symfony\Component\Form\ReversedTransformer;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class DateType extends AbstractType
{
Expand Down
Expand Up @@ -22,7 +22,7 @@
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Exception\FormException;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class FormType extends AbstractType
{
Expand Down
Expand Up @@ -20,7 +20,7 @@
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class TimeType extends AbstractType
{
Expand Down
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
use Symfony\Component\OptionsParser\Options;
use Symfony\Component\OptionsResolver\Options;

class TimezoneType extends AbstractType
{
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Form/FormFactory.php
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Form\Exception\FormException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Exception\TypeDefinitionException;
use Symfony\Component\OptionsParser\OptionsParser;
use Symfony\Component\OptionsResolver\OptionsResolver;

class FormFactory implements FormFactoryInterface
{
Expand Down Expand Up @@ -221,7 +221,7 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
$types = array();
$optionValues = array();
$knownOptions = array();
$optionsParser = new OptionsParser();
$optionsResolver = new OptionsResolver();

// Bottom-up determination of the type hierarchy
// Start with the actual type and look for the parent type
Expand Down Expand Up @@ -255,14 +255,14 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
// options. Default options of children override default options
// of parents.
$typeOptions = $type->getDefaultOptions();
$optionsParser->setDefaults($typeOptions);
$optionsParser->addAllowedValues($type->getAllowedOptionValues());
$optionsResolver->setDefaults($typeOptions);
$optionsResolver->addAllowedValues($type->getAllowedOptionValues());
$knownOptions = array_merge($knownOptions, array_keys($typeOptions));

foreach ($type->getExtensions() as $typeExtension) {
$extensionOptions = $typeExtension->getDefaultOptions();
$optionsParser->setDefaults($extensionOptions);
$optionsParser->addAllowedValues($typeExtension->getAllowedOptionValues());
$optionsResolver->setDefaults($extensionOptions);
$optionsResolver->addAllowedValues($typeExtension->getAllowedOptionValues());
$knownOptions = array_merge($knownOptions, array_keys($extensionOptions));
}
}
Expand All @@ -278,7 +278,7 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
}

// Resolve options
$options = $optionsParser->parse($options);
$options = $optionsResolver->resolve($options);

for ($i = 0, $l = count($types); $i < $l && !$builder; ++$i) {
$builder = $types[$i]->createBuilder($name, $this, $options);
Expand Down
Expand Up @@ -23,7 +23,7 @@ protected function setUp()
}

/**
* @expectedException Symfony\Component\OptionsParser\Exception\InvalidOptionsException
* @expectedException Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testInvalidWidgetOption()
{
Expand All @@ -33,7 +33,7 @@ public function testInvalidWidgetOption()
}

/**
* @expectedException Symfony\Component\OptionsParser\Exception\InvalidOptionsException
* @expectedException Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testInvalidInputOption()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Tests/FormFactoryTest.php
Expand Up @@ -279,7 +279,7 @@ public function testCreateNamedBuilderExpectsBuilderToBeReturned()
}

/**
* @expectedException Symfony\Component\OptionsParser\Exception\InvalidOptionsException
* @expectedException Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testCreateNamedBuilderExpectsOptionsToExist()
{
Expand All @@ -292,7 +292,7 @@ public function testCreateNamedBuilderExpectsOptionsToExist()
}

/**
* @expectedException Symfony\Component\OptionsParser\Exception\InvalidOptionsException
* @expectedException Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testCreateNamedBuilderExpectsOptionsToBeInValidRange()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/composer.json
Expand Up @@ -19,7 +19,7 @@
"php": ">=5.3.3",
"symfony/event-dispatcher": "2.1.*",
"symfony/locale": "2.1.*",
"symfony/options-parser": "2.1.*"
"symfony/options-resolver": "2.1.*"
},
"require-dev": {
"symfony/validator": "2.1.*",
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser\Exception;
namespace Symfony\Component\OptionsResolver\Exception;

/**
* Marker interface for the Options component.
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser\Exception;
namespace Symfony\Component\OptionsResolver\Exception;

/**
* Exception thrown when an invalid option is passed.
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser\Exception;
namespace Symfony\Component\OptionsResolver\Exception;

/**
* Exception thrown when a required option is missing.
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser\Exception;
namespace Symfony\Component\OptionsResolver\Exception;

/**
* Thrown when an option definition is invalid.
Expand Down
File renamed without changes.
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser;
namespace Symfony\Component\OptionsResolver;

use Closure;

Expand Down
Expand Up @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser;
namespace Symfony\Component\OptionsResolver;

use ArrayAccess;
use Iterator;
use OutOfBoundsException;
use Symfony\Component\OptionsParser\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;

/**
* Container for resolving inter-dependent options.
Expand Down
Expand Up @@ -9,18 +9,18 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\OptionsParser;
namespace Symfony\Component\OptionsResolver;

use Symfony\Component\OptionsParser\Exception\OptionDefinitionException;
use Symfony\Component\OptionsParser\Exception\InvalidOptionsException;
use Symfony\Component\OptionsParser\Exception\MissingOptionsException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;

/**
* Helper for merging default and concrete option values.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class OptionsParser
class OptionsResolver
{
/**
* The default option values.
Expand All @@ -29,13 +29,13 @@ class OptionsParser
private $defaultOptions;

/**
* The options known by the parser.
* The options known by the resolver.
* @var array
*/
private $knownOptions = array();

/**
* The options required to be passed to parse().
* The options required to be passed to resolve().
* @var array
*/
private $requiredOptions = array();
Expand Down Expand Up @@ -100,7 +100,7 @@ public function replaceDefaults(array $defaultValues)
*
* This method is identical to `setDefaults`, only that no default values
* are configured for the options. If these options are not passed to
* parse(), they will be missing in the final options array. This can be
* resolve(), they will be missing in the final options array. This can be
* helpful if you want to determine whether an option has been set or not.
*
* @param array $optionNames A list of option names.
Expand All @@ -121,7 +121,7 @@ public function setOptional(array $optionNames)
/**
* Sets required options.
*
* If these options are not passed to parse(), an exception will be thrown.
* If these options are not passed to resolve(), an exception will be thrown.
*
* @param array $optionNames A list of option names.
*
Expand Down Expand Up @@ -189,7 +189,7 @@ public function addAllowedValues(array $allowedValues)
* @throws OptionDefinitionException If a cyclic dependency is detected
* between two lazy options.
*/
public function parse(array $options)
public function resolve(array $options)
{
$this->validateOptionNames(array_keys($options));

Expand Down

0 comments on commit 256b708

Please sign in to comment.