Merge branch '2.7' into 2.8
* 2.7: Typo fix [2.3] Static Code Analysis for Components Added support \IteratorAggregate for UniqueEntityValidator Update AbstractChoiceListTest.php Fix #17306 Paths with % in it are note allowed (like urlencoded) Use proper class to fetch $versionStrategy property Added sort order SORT_STRING for params in UriSigner Remove normalizer cache in Serializer class
This commit is contained in:
commit
4ed54a39ab
@ -10,7 +10,7 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
| -------- | ---
|
| -------- | ---
|
||||||
| `registerNamespaces()` | `addPrefixes()`
|
| `registerNamespaces()` | `addPrefixes()`
|
||||||
| `registerPrefixes()` | `addPrefixes()`
|
| `registerPrefixes()` | `addPrefixes()`
|
||||||
| `registerNamespaces()` | `addPrefix()`
|
| `registerNamespace()` | `addPrefix()`
|
||||||
| `registerPrefix()` | `addPrefix()`
|
| `registerPrefix()` | `addPrefix()`
|
||||||
| `getNamespaces()` | `getPrefixes()`
|
| `getNamespaces()` | `getPrefixes()`
|
||||||
| `getNamespaceFallbacks()` | `getFallbackDirs()`
|
| `getNamespaceFallbacks()` | `getFallbackDirs()`
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints;
|
namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Doctrine\Common\Persistence\ObjectRepository;
|
use Doctrine\Common\Persistence\ObjectRepository;
|
||||||
@ -336,6 +337,44 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
$this->assertNoViolation();
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider resultTypesProvider
|
||||||
|
*/
|
||||||
|
public function testValidateResultTypes($entity1, $result)
|
||||||
|
{
|
||||||
|
$constraint = new UniqueEntity(array(
|
||||||
|
'message' => 'myMessage',
|
||||||
|
'fields' => array('name'),
|
||||||
|
'em' => self::EM_NAME,
|
||||||
|
'repositoryMethod' => 'findByCustom',
|
||||||
|
));
|
||||||
|
|
||||||
|
$repository = $this->createRepositoryMock();
|
||||||
|
$repository->expects($this->once())
|
||||||
|
->method('findByCustom')
|
||||||
|
->will($this->returnValue($result))
|
||||||
|
;
|
||||||
|
$this->em = $this->createEntityManagerMock($repository);
|
||||||
|
$this->registry = $this->createRegistryMock($this->em);
|
||||||
|
$this->validator = $this->createValidator();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
|
||||||
|
$this->validator->validate($entity1, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resultTypesProvider()
|
||||||
|
{
|
||||||
|
$entity = new SingleIntIdEntity(1, 'foo');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array($entity, array($entity)),
|
||||||
|
array($entity, new \ArrayIterator(array($entity))),
|
||||||
|
array($entity, new ArrayCollection(array($entity))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAssociatedEntity()
|
public function testAssociatedEntity()
|
||||||
{
|
{
|
||||||
$constraint = new UniqueEntity(array(
|
$constraint = new UniqueEntity(array(
|
||||||
|
@ -114,6 +114,10 @@ class UniqueEntityValidator extends ConstraintValidator
|
|||||||
$repository = $em->getRepository(get_class($entity));
|
$repository = $em->getRepository(get_class($entity));
|
||||||
$result = $repository->{$constraint->repositoryMethod}($criteria);
|
$result = $repository->{$constraint->repositoryMethod}($criteria);
|
||||||
|
|
||||||
|
if ($result instanceof \IteratorAggregate) {
|
||||||
|
$result = $result->getIterator();
|
||||||
|
}
|
||||||
|
|
||||||
/* If the result is a MongoCursor, it must be advanced to the first
|
/* If the result is a MongoCursor, it must be advanced to the first
|
||||||
* element. Rewinding should have no ill effect if $result is another
|
* element. Rewinding should have no ill effect if $result is another
|
||||||
* iterator implementation.
|
* iterator implementation.
|
||||||
|
@ -98,19 +98,16 @@ class AssetExtension extends \Twig_Extension
|
|||||||
{
|
{
|
||||||
if ($version) {
|
if ($version) {
|
||||||
$package = $this->packages->getPackage($packageName);
|
$package = $this->packages->getPackage($packageName);
|
||||||
$class = new \ReflectionClass($package);
|
|
||||||
|
|
||||||
while ('Symfony\Component\Asset\Package' !== $class->getName()) {
|
$v = new \ReflectionProperty('Symfony\Component\Asset\Package', 'versionStrategy');
|
||||||
$class = $class->getParentClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
$v = $class->getProperty('versionStrategy');
|
|
||||||
$v->setAccessible(true);
|
$v->setAccessible(true);
|
||||||
|
|
||||||
$currentVersionStrategy = $v->getValue($package);
|
$currentVersionStrategy = $v->getValue($package);
|
||||||
|
|
||||||
if (property_exists($currentVersionStrategy, 'format')) {
|
if (property_exists($currentVersionStrategy, 'format')) {
|
||||||
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
||||||
$f->setAccessible(true);
|
$f->setAccessible(true);
|
||||||
|
|
||||||
$format = $f->getValue($currentVersionStrategy);
|
$format = $f->getValue($currentVersionStrategy);
|
||||||
|
|
||||||
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
||||||
|
@ -689,16 +689,17 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
|
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
|
||||||
}
|
}
|
||||||
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
|
$rootDir = $container->getParameter('kernel.root_dir');
|
||||||
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
|
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
|
||||||
$dirs[] = $dir;
|
$dirs[] = $dir;
|
||||||
}
|
}
|
||||||
if (is_dir($dir = sprintf($overridePath, $bundle))) {
|
if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $bundle))) {
|
||||||
$dirs[] = $dir;
|
$dirs[] = $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($config['paths'] as $dir) {
|
foreach ($config['paths'] as $dir) {
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$dirs[] = $dir;
|
$dirs[] = $dir;
|
||||||
@ -706,7 +707,8 @@ class FrameworkExtension extends Extension
|
|||||||
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
|
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/translations')) {
|
|
||||||
|
if (is_dir($dir = $rootDir.'/Resources/translations')) {
|
||||||
$dirs[] = $dir;
|
$dirs[] = $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,13 +95,14 @@ class AssetsHelper extends Helper
|
|||||||
if ($version) {
|
if ($version) {
|
||||||
$package = $this->packages->getPackage($packageName);
|
$package = $this->packages->getPackage($packageName);
|
||||||
|
|
||||||
$v = new \ReflectionProperty($package, 'versionStrategy');
|
$v = new \ReflectionProperty('Symfony\Component\Asset\Package', 'versionStrategy');
|
||||||
$v->setAccessible(true);
|
$v->setAccessible(true);
|
||||||
|
|
||||||
$currentVersionStrategy = $v->getValue($package);
|
$currentVersionStrategy = $v->getValue($package);
|
||||||
|
|
||||||
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
||||||
$f->setAccessible(true);
|
$f->setAccessible(true);
|
||||||
|
|
||||||
$format = $f->getValue($currentVersionStrategy);
|
$format = $f->getValue($currentVersionStrategy);
|
||||||
|
|
||||||
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
|
||||||
use Symfony\Component\Asset\Package;
|
use Symfony\Component\Asset\Package;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
|
use Symfony\Component\Asset\PathPackage;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
|
||||||
class AssetsHelperTest extends \PHPUnit_Framework_TestCase
|
class AssetsHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -23,11 +24,14 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLegacyGetUrl()
|
public function testLegacyGetUrl()
|
||||||
{
|
{
|
||||||
$package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
|
$versionStrategy = new StaticVersionStrategy('22', '%s?version=%s');
|
||||||
$packages = new Packages($package);
|
$package = new Package($versionStrategy);
|
||||||
|
$imagePackage = new PathPackage('images', $versionStrategy);
|
||||||
|
$packages = new Packages($package, array('images' => $imagePackage));
|
||||||
$helper = new AssetsHelper($packages);
|
$helper = new AssetsHelper($packages);
|
||||||
|
|
||||||
$this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
|
$this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
|
||||||
|
$this->assertEquals('/images/me.png?version=42', $helper->getUrl('me.png', 'images', '42'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +149,7 @@ abstract class Client
|
|||||||
*/
|
*/
|
||||||
public function getServerParameter($key, $default = '')
|
public function getServerParameter($key, $default = '')
|
||||||
{
|
{
|
||||||
return (isset($this->server[$key])) ? $this->server[$key] : $default;
|
return isset($this->server[$key]) ? $this->server[$key] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ class TableHelper extends Helper
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
|
throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
|
||||||
};
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
|||||||
PHP_OS,
|
PHP_OS,
|
||||||
);
|
);
|
||||||
|
|
||||||
return false !== stristr(implode(';', $checks), 'OS400');
|
return false !== stripos(implode(';', $checks), 'OS400');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -580,7 +580,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
|||||||
*/
|
*/
|
||||||
public static function underscore($id)
|
public static function underscore($id)
|
||||||
{
|
{
|
||||||
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
|
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), str_replace('_', '.', $id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __clone()
|
private function __clone()
|
||||||
|
@ -91,9 +91,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
|||||||
$container->addResource(new FileResource($r->getFileName()));
|
$container->addResource(new FileResource($r->getFileName()));
|
||||||
|
|
||||||
if (!method_exists($class, '__construct')) {
|
if (!method_exists($class, '__construct')) {
|
||||||
$configuration = new $class();
|
return new $class();
|
||||||
|
|
||||||
return $configuration;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,9 @@ class XmlFileLoader extends FileLoader
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultDirectory = dirname($file);
|
||||||
foreach ($imports as $import) {
|
foreach ($imports as $import) {
|
||||||
$this->setCurrentDir(dirname($file));
|
$this->setCurrentDir($defaultDirectory);
|
||||||
$this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
|
$this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,12 +95,13 @@ class YamlFileLoader extends FileLoader
|
|||||||
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
|
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultDirectory = dirname($file);
|
||||||
foreach ($content['imports'] as $import) {
|
foreach ($content['imports'] as $import) {
|
||||||
if (!is_array($import)) {
|
if (!is_array($import)) {
|
||||||
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
|
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setCurrentDir(dirname($file));
|
$this->setCurrentDir($defaultDirectory);
|
||||||
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
|
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ class Filesystem
|
|||||||
return strspn($file, '/\\', 0, 1)
|
return strspn($file, '/\\', 0, 1)
|
||||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||||
&& substr($file, 1, 1) === ':'
|
&& substr($file, 1, 1) === ':'
|
||||||
&& (strspn($file, '/\\', 2, 1))
|
&& strspn($file, '/\\', 2, 1)
|
||||||
)
|
)
|
||||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||||
;
|
;
|
||||||
|
@ -17,7 +17,7 @@ namespace Symfony\Component\Form\Tests\ChoiceList;
|
|||||||
abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
|
* @var \Symfony\Component\Form\ChoiceList\ChoiceListInterface
|
||||||
*/
|
*/
|
||||||
protected $list;
|
protected $list;
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
|
* @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function createChoiceList();
|
abstract protected function createChoiceList();
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function get($key, $default = null, $first = true)
|
public function get($key, $default = null, $first = true)
|
||||||
{
|
{
|
||||||
$key = strtr(strtolower($key), '_', '-');
|
$key = str_replace('_', '-', strtolower($key));
|
||||||
|
|
||||||
if (!array_key_exists($key, $this->headers)) {
|
if (!array_key_exists($key, $this->headers)) {
|
||||||
if (null === $default) {
|
if (null === $default) {
|
||||||
@ -137,7 +137,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function set($key, $values, $replace = true)
|
public function set($key, $values, $replace = true)
|
||||||
{
|
{
|
||||||
$key = strtr(strtolower($key), '_', '-');
|
$key = str_replace('_', '-', strtolower($key));
|
||||||
|
|
||||||
$values = array_values((array) $values);
|
$values = array_values((array) $values);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function has($key)
|
public function has($key)
|
||||||
{
|
{
|
||||||
return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers);
|
return array_key_exists(str_replace('_', '-', strtolower($key)), $this->headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,7 +184,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function remove($key)
|
public function remove($key)
|
||||||
{
|
{
|
||||||
$key = strtr(strtolower($key), '_', '-');
|
$key = str_replace('_', '-', strtolower($key));
|
||||||
|
|
||||||
unset($this->headers[$key]);
|
unset($this->headers[$key]);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class ResponseHeaderBag extends HeaderBag
|
|||||||
{
|
{
|
||||||
parent::set($key, $values, $replace);
|
parent::set($key, $values, $replace);
|
||||||
|
|
||||||
$uniqueKey = strtr(strtolower($key), '_', '-');
|
$uniqueKey = str_replace('_', '-', strtolower($key));
|
||||||
$this->headerNames[$uniqueKey] = $key;
|
$this->headerNames[$uniqueKey] = $key;
|
||||||
|
|
||||||
// ensure the cache-control header has sensible defaults
|
// ensure the cache-control header has sensible defaults
|
||||||
@ -118,7 +118,7 @@ class ResponseHeaderBag extends HeaderBag
|
|||||||
{
|
{
|
||||||
parent::remove($key);
|
parent::remove($key);
|
||||||
|
|
||||||
$uniqueKey = strtr(strtolower($key), '_', '-');
|
$uniqueKey = str_replace('_', '-', strtolower($key));
|
||||||
unset($this->headerNames[$uniqueKey]);
|
unset($this->headerNames[$uniqueKey]);
|
||||||
|
|
||||||
if ('cache-control' === $uniqueKey) {
|
if ('cache-control' === $uniqueKey) {
|
||||||
|
@ -191,7 +191,7 @@ abstract class Bundle implements BundleInterface
|
|||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
$ns = $prefix;
|
$ns = $prefix;
|
||||||
if ($relativePath = $file->getRelativePath()) {
|
if ($relativePath = $file->getRelativePath()) {
|
||||||
$ns .= '\\'.strtr($relativePath, '/', '\\');
|
$ns .= '\\'.str_replace('/', '\\', $relativePath);
|
||||||
}
|
}
|
||||||
$class = $ns.'\\'.$file->getBasename('.php');
|
$class = $ns.'\\'.$file->getBasename('.php');
|
||||||
if ($this->container) {
|
if ($this->container) {
|
||||||
|
@ -38,10 +38,8 @@ class Store implements StoreInterface
|
|||||||
public function __construct($root)
|
public function __construct($root)
|
||||||
{
|
{
|
||||||
$this->root = $root;
|
$this->root = $root;
|
||||||
if (!is_dir($this->root)) {
|
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
||||||
if (false === @mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
|
||||||
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->keyCache = new \SplObjectStorage();
|
$this->keyCache = new \SplObjectStorage();
|
||||||
$this->locks = array();
|
$this->locks = array();
|
||||||
@ -249,10 +247,8 @@ class Store implements StoreInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($modified) {
|
if ($modified && false === $this->save($key, serialize($entries))) {
|
||||||
if (false === $this->save($key, serialize($entries))) {
|
throw new \RuntimeException('Unable to store the metadata.');
|
||||||
throw new \RuntimeException('Unable to store the metadata.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +269,7 @@ class Store implements StoreInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (preg_split('/[\s,]+/', $vary) as $header) {
|
foreach (preg_split('/[\s,]+/', $vary) as $header) {
|
||||||
$key = strtr(strtolower($header), '_', '-');
|
$key = str_replace('_', '-', strtolower($header));
|
||||||
$v1 = isset($env1[$key]) ? $env1[$key] : null;
|
$v1 = isset($env1[$key]) ? $env1[$key] : null;
|
||||||
$v2 = isset($env2[$key]) ? $env2[$key] : null;
|
$v2 = isset($env2[$key]) ? $env2[$key] : null;
|
||||||
if ($v1 !== $v2) {
|
if ($v1 !== $v2) {
|
||||||
|
@ -193,9 +193,8 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface
|
|||||||
$stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
|
$stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$return = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
return $return;
|
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function close($db)
|
protected function close($db)
|
||||||
|
@ -33,6 +33,7 @@ class UriSignerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertTrue($signer->check($signer->sign('http://example.com/foo')));
|
$this->assertTrue($signer->check($signer->sign('http://example.com/foo')));
|
||||||
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
|
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
|
||||||
|
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&0=integer')));
|
||||||
|
|
||||||
$this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
|
$this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class UriSigner
|
|||||||
|
|
||||||
$uri = $this->buildUrl($url, $params);
|
$uri = $this->buildUrl($url, $params);
|
||||||
|
|
||||||
return $uri.(false === (strpos($uri, '?')) ? '?' : '&').'_hash='.$this->computeHash($uri);
|
return $uri.(false === strpos($uri, '?') ? '?' : '&').'_hash='.$this->computeHash($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +91,7 @@ class UriSigner
|
|||||||
|
|
||||||
private function buildUrl(array $url, array $params = array())
|
private function buildUrl(array $url, array $params = array())
|
||||||
{
|
{
|
||||||
ksort($params);
|
ksort($params, SORT_STRING);
|
||||||
$url['query'] = http_build_query($params, '', '&');
|
$url['query'] = http_build_query($params, '', '&');
|
||||||
|
|
||||||
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
|
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
|
||||||
|
@ -170,10 +170,8 @@ class DigestData
|
|||||||
throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s" (%s)', $this->header, implode(', ', $keys)));
|
throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s" (%s)', $this->header, implode(', ', $keys)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('auth' === $this->elements['qop']) {
|
if ('auth' === $this->elements['qop'] && !isset($this->elements['nc'], $this->elements['cnonce'])) {
|
||||||
if (!isset($this->elements['nc']) || !isset($this->elements['cnonce'])) {
|
throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s"', $this->header));
|
||||||
throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s"', $this->header));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expectedRealm !== $this->elements['realm']) {
|
if ($expectedRealm !== $this->elements['realm']) {
|
||||||
|
@ -187,17 +187,10 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
|||||||
{
|
{
|
||||||
if ($isObject = is_object($data)) {
|
if ($isObject = is_object($data)) {
|
||||||
$class = get_class($data);
|
$class = get_class($data);
|
||||||
if (isset($this->normalizerCache[$class][$format])) {
|
|
||||||
return $this->normalizerCache[$class][$format];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->normalizers as $normalizer) {
|
foreach ($this->normalizers as $normalizer) {
|
||||||
if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($data, $format)) {
|
if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($data, $format)) {
|
||||||
if ($isObject) {
|
|
||||||
$this->normalizerCache[$class][$format] = $normalizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $normalizer;
|
return $normalizer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,14 +207,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
|||||||
*/
|
*/
|
||||||
private function getDenormalizer($data, $class, $format)
|
private function getDenormalizer($data, $class, $format)
|
||||||
{
|
{
|
||||||
if (isset($this->denormalizerCache[$class][$format])) {
|
|
||||||
return $this->denormalizerCache[$class][$format];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->normalizers as $normalizer) {
|
foreach ($this->normalizers as $normalizer) {
|
||||||
if ($normalizer instanceof DenormalizerInterface && $normalizer->supportsDenormalization($data, $class, $format)) {
|
if ($normalizer instanceof DenormalizerInterface && $normalizer->supportsDenormalization($data, $class, $format)) {
|
||||||
$this->denormalizerCache[$class][$format] = $normalizer;
|
|
||||||
|
|
||||||
return $normalizer;
|
return $normalizer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,6 +251,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
|||||||
if ($normalizer = $this->getNormalizer($object, $format)) {
|
if ($normalizer = $this->getNormalizer($object, $format)) {
|
||||||
return $normalizer->normalize($object, $format, $context);
|
return $normalizer->normalize($object, $format, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($object)));
|
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($object)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +277,15 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
|
|||||||
if ($normalizer = $this->getDenormalizer($data, $class, $format)) {
|
if ($normalizer = $this->getDenormalizer($data, $class, $format)) {
|
||||||
return $normalizer->denormalize($data, $class, $format, $context);
|
return $normalizer->denormalize($data, $class, $format, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->normalizers as $normalizer) {
|
||||||
|
if ($normalizer instanceof DenormalizerInterface
|
||||||
|
&& $normalizer->supportsDenormalization($data, $class, $format)) {
|
||||||
|
|
||||||
|
return $normalizer->denormalize($data, $class, $format, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
|
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,50 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($serializer->normalize('test'));
|
$this->assertNull($serializer->normalize('test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNormalizeWithSupportOnData()
|
||||||
|
{
|
||||||
|
$normalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
|
||||||
|
$normalizer1->method('supportsNormalization')
|
||||||
|
->willReturnCallback(function ($data, $format) {
|
||||||
|
return isset($data->test);
|
||||||
|
});
|
||||||
|
$normalizer1->method('normalize')->willReturn('test1');
|
||||||
|
|
||||||
|
$normalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
|
||||||
|
$normalizer2->method('supportsNormalization')
|
||||||
|
->willReturn(true);
|
||||||
|
$normalizer2->method('normalize')->willReturn('test2');
|
||||||
|
|
||||||
|
$serializer = new Serializer(array($normalizer1, $normalizer2));
|
||||||
|
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->test = true;
|
||||||
|
$this->assertEquals('test1', $serializer->normalize($data));
|
||||||
|
|
||||||
|
$this->assertEquals('test2', $serializer->normalize(new \stdClass()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDenormalizeWithSupportOnData()
|
||||||
|
{
|
||||||
|
$denormalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
|
||||||
|
$denormalizer1->method('supportsDenormalization')
|
||||||
|
->willReturnCallback(function ($data, $type, $format) {
|
||||||
|
return isset($data['test1']);
|
||||||
|
});
|
||||||
|
$denormalizer1->method('denormalize')->willReturn('test1');
|
||||||
|
|
||||||
|
$denormalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
|
||||||
|
$denormalizer2->method('supportsDenormalization')
|
||||||
|
->willReturn(true);
|
||||||
|
$denormalizer2->method('denormalize')->willReturn('test2');
|
||||||
|
|
||||||
|
$serializer = new Serializer(array($denormalizer1, $denormalizer2));
|
||||||
|
|
||||||
|
$this->assertEquals('test1', $serializer->denormalize(array('test1' => true), 'test'));
|
||||||
|
|
||||||
|
$this->assertEquals('test2', $serializer->denormalize(array(), 'test'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testSerialize()
|
public function testSerialize()
|
||||||
{
|
{
|
||||||
$serializer = new Serializer(array(new GetSetMethodNormalizer()), array('json' => new JsonEncoder()));
|
$serializer = new Serializer(array(new GetSetMethodNormalizer()), array('json' => new JsonEncoder()));
|
||||||
|
@ -190,7 +190,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
*/
|
*/
|
||||||
private function loadClassMetadataFromXml(ClassMetadata $metadata, $classDescription)
|
private function loadClassMetadataFromXml(ClassMetadata $metadata, $classDescription)
|
||||||
{
|
{
|
||||||
foreach ($classDescription->{'group-sequence-provider'} as $_) {
|
if (count($classDescription->{'group-sequence-provider'}) > 0) {
|
||||||
$metadata->setGroupSequenceProvider(true);
|
$metadata->setGroupSequenceProvider(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user