updated mailgun librarie

This commit is contained in:
2019-05-14 10:47:30 +02:00
parent c97e0f8ba1
commit dc39ddbbea
1588 changed files with 40009 additions and 143222 deletions

View File

@@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml

View File

@@ -0,0 +1,52 @@
CHANGELOG
=========
3.4.0
-----
* added `OptionsResolverIntrospector` to inspect options definitions inside an `OptionsResolver` instance
* added array of types support in allowed types (e.g int[])
2.6.0
-----
* deprecated OptionsResolverInterface
* [BC BREAK] removed "array" type hint from OptionsResolverInterface methods
setRequired(), setAllowedValues(), addAllowedValues(), setAllowedTypes() and
addAllowedTypes()
* added OptionsResolver::setDefault()
* added OptionsResolver::hasDefault()
* added OptionsResolver::setNormalizer()
* added OptionsResolver::isRequired()
* added OptionsResolver::getRequiredOptions()
* added OptionsResolver::isMissing()
* added OptionsResolver::getMissingOptions()
* added OptionsResolver::setDefined()
* added OptionsResolver::isDefined()
* added OptionsResolver::getDefinedOptions()
* added OptionsResolver::remove()
* added OptionsResolver::clear()
* deprecated OptionsResolver::replaceDefaults()
* deprecated OptionsResolver::setOptional() in favor of setDefined()
* deprecated OptionsResolver::isKnown() in favor of isDefined()
* [BC BREAK] OptionsResolver::isRequired() returns true now if a required
option has a default value set
* [BC BREAK] merged Options into OptionsResolver and turned Options into an
interface
* deprecated Options::overload() (now in OptionsResolver)
* deprecated Options::set() (now in OptionsResolver)
* deprecated Options::get() (now in OptionsResolver)
* deprecated Options::has() (now in OptionsResolver)
* deprecated Options::replace() (now in OptionsResolver)
* [BC BREAK] Options::get() (now in OptionsResolver) can only be used within
lazy option/normalizer closures now
* [BC BREAK] removed Traversable interface from Options since using within
lazy option/normalizer closures resulted in exceptions
* [BC BREAK] removed Options::all() since using within lazy option/normalizer
closures resulted in exceptions
* [BC BREAK] OptionDefinitionException now extends LogicException instead of
RuntimeException
* [BC BREAK] normalizers are not executed anymore for unset options
* normalizers are executed after validating the options now
* [BC BREAK] an UndefinedOptionsException is now thrown instead of an
InvalidOptionsException when non-existing options are passed

View File

@@ -0,0 +1,102 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Debug;
use Symfony\Component\OptionsResolver\Exception\NoConfigurationException;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*
* @final
*/
class OptionsResolverIntrospector
{
private $get;
public function __construct(OptionsResolver $optionsResolver)
{
$this->get = \Closure::bind(function ($property, $option, $message) {
/** @var OptionsResolver $this */
if (!$this->isDefined($option)) {
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option));
}
if (!\array_key_exists($option, $this->{$property})) {
throw new NoConfigurationException($message);
}
return $this->{$property}[$option];
}, $optionsResolver, $optionsResolver);
}
/**
* @param string $option
*
* @return mixed
*
* @throws NoConfigurationException on no configured value
*/
public function getDefault($option)
{
return \call_user_func($this->get, 'defaults', $option, sprintf('No default value was set for the "%s" option.', $option));
}
/**
* @param string $option
*
* @return \Closure[]
*
* @throws NoConfigurationException on no configured closures
*/
public function getLazyClosures($option)
{
return \call_user_func($this->get, 'lazy', $option, sprintf('No lazy closures were set for the "%s" option.', $option));
}
/**
* @param string $option
*
* @return string[]
*
* @throws NoConfigurationException on no configured types
*/
public function getAllowedTypes($option)
{
return \call_user_func($this->get, 'allowedTypes', $option, sprintf('No allowed types were set for the "%s" option.', $option));
}
/**
* @param string $option
*
* @return mixed[]
*
* @throws NoConfigurationException on no configured values
*/
public function getAllowedValues($option)
{
return \call_user_func($this->get, 'allowedValues', $option, sprintf('No allowed values were set for the "%s" option.', $option));
}
/**
* @param string $option
*
* @return \Closure
*
* @throws NoConfigurationException on no configured normalizer
*/
public function getNormalizer($option)
{
return \call_user_func($this->get, 'normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option));
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Thrown when trying to read an option outside of or write it inside of
* {@link \Symfony\Component\OptionsResolver\Options::resolve()}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class AccessException extends \LogicException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Marker interface for all exceptions thrown by the OptionsResolver component.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Thrown when an argument is invalid.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Thrown when the value of an option does not match its validation rules.
*
* You should make sure a valid value is passed to the option.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class InvalidOptionsException extends InvalidArgumentException
{
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Exception thrown when a required option is missing.
*
* Add the option to the passed options array.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class MissingOptionsException extends InvalidArgumentException
{
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector;
/**
* Thrown when trying to introspect an option definition property
* for which no value was configured inside the OptionsResolver instance.
*
* @see OptionsResolverIntrospector
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
class NoConfigurationException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Thrown when trying to read an option that has no value set.
*
* When accessing optional options from within a lazy option or normalizer you should first
* check whether the optional option is set. You can do this with `isset($options['optional'])`.
* In contrast to the {@link UndefinedOptionsException}, this is a runtime exception that can
* occur when evaluating lazy options.
*
* @author Tobias Schultze <http://tobion.de>
*/
class NoSuchOptionException extends \OutOfBoundsException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Thrown when two lazy options have a cyclic dependency.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class OptionDefinitionException extends \LogicException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,24 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Exception;
/**
* Exception thrown when an undefined option is passed.
*
* You should remove the options in question from your code or define them
* beforehand.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class UndefinedOptionsException extends InvalidArgumentException
{
}

View File

@@ -0,0 +1,19 @@
Copyright (c) 2004-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver;
/**
* Contains resolved option values.
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Tobias Schultze <http://tobion.de>
*/
interface Options extends \ArrayAccess, \Countable
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
OptionsResolver Component
=========================
The OptionsResolver component is `array_replace` on steroids. It allows you to
create an options system with required options, defaults, validation (type,
value), normalization and more.
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/options_resolver.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)

View File

@@ -0,0 +1,203 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\OptionsResolver\Tests\Debug;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
class OptionsResolverIntrospectorTest extends TestCase
{
public function testGetDefault()
{
$resolver = new OptionsResolver();
$resolver->setDefault($option = 'foo', 'bar');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getDefault($option));
}
public function testGetDefaultNull()
{
$resolver = new OptionsResolver();
$resolver->setDefault($option = 'foo', null);
$debug = new OptionsResolverIntrospector($resolver);
$this->assertNull($debug->getDefault($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
* @expectedExceptionMessage No default value was set for the "foo" option.
*/
public function testGetDefaultThrowsOnNoConfiguredValue()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getDefault($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
* @expectedExceptionMessage The option "foo" does not exist.
*/
public function testGetDefaultThrowsOnNotDefinedOption()
{
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getDefault('foo'));
}
public function testGetLazyClosures()
{
$resolver = new OptionsResolver();
$closures = [];
$resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {});
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($closures, $debug->getLazyClosures($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
* @expectedExceptionMessage No lazy closures were set for the "foo" option.
*/
public function testGetLazyClosuresThrowsOnNoConfiguredValue()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getLazyClosures($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
* @expectedExceptionMessage The option "foo" does not exist.
*/
public function testGetLazyClosuresThrowsOnNotDefinedOption()
{
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getLazyClosures('foo'));
}
public function testGetAllowedTypes()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = ['string', 'bool']);
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($allowedTypes, $debug->getAllowedTypes($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
* @expectedExceptionMessage No allowed types were set for the "foo" option.
*/
public function testGetAllowedTypesThrowsOnNoConfiguredValue()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getAllowedTypes($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
* @expectedExceptionMessage The option "foo" does not exist.
*/
public function testGetAllowedTypesThrowsOnNotDefinedOption()
{
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getAllowedTypes('foo'));
}
public function testGetAllowedValues()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$resolver->setAllowedValues($option = 'foo', $allowedValues = ['bar', 'baz']);
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($allowedValues, $debug->getAllowedValues($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
* @expectedExceptionMessage No allowed values were set for the "foo" option.
*/
public function testGetAllowedValuesThrowsOnNoConfiguredValue()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getAllowedValues($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
* @expectedExceptionMessage The option "foo" does not exist.
*/
public function testGetAllowedValuesThrowsOnNotDefinedOption()
{
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getAllowedValues('foo'));
}
public function testGetNormalizer()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$resolver->setNormalizer($option = 'foo', $normalizer = function () {});
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($normalizer, $debug->getNormalizer($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
* @expectedExceptionMessage No normalizer was set for the "foo" option.
*/
public function testGetNormalizerThrowsOnNoConfiguredValue()
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getNormalizer($option));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
* @expectedExceptionMessage The option "foo" does not exist.
*/
public function testGetNormalizerThrowsOnNotDefinedOption()
{
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame('bar', $debug->getNormalizer('foo'));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
{
"name": "symfony/options-resolver",
"type": "library",
"description": "Symfony OptionsResolver Component",
"keywords": ["options", "config", "configuration"],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": "^5.5.9|>=7.0.8"
},
"autoload": {
"psr-4": { "Symfony\\Component\\OptionsResolver\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
}
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony OptionsResolver Component Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>