Merge branch '2.5'
* 2.5: [DependencyInjection] fix @return anno created by PhpDumper Fixed the phpdoc of the VoterInterface [DoctrineBridge] Fix empty parameter logging in the dbal logger [Validator] remove duplicate interface implementations [Validator] fix return doc of ClassMetadata::getCascadingStrategy Fixed #11675 ValueToDuplicatesTransformer accept "0" value check for the correct field type fix handling of nullable XML attributes [DomCrawler] fix the axes handling in a bc way
This commit is contained in:
commit
c46125438c
@ -56,15 +56,15 @@ class DbalLogger implements SQLLogger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// non utf-8 strings break json encoding
|
// non utf-8 strings break json encoding
|
||||||
if (!preg_match('#[\p{L}\p{N} ]#u', $params[$index])) {
|
if (!preg_match('//u', $params[$index])) {
|
||||||
$params[$index] = self::BINARY_DATA_VALUE;
|
$params[$index] = self::BINARY_DATA_VALUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect if the too long string must be shorten
|
// detect if the too long string must be shorten
|
||||||
if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($params[$index])) {
|
if (function_exists('mb_strlen')) {
|
||||||
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], $encoding)) {
|
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) {
|
||||||
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, $encoding).' [...]';
|
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,10 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array('SQL', null, array()),
|
array('SQL', null, array()),
|
||||||
array('SQL', array(), array()),
|
array('SQL', array(), array()),
|
||||||
array('SQL', array('foo' => 'bar'), array('foo' => 'bar'))
|
array('SQL', array('foo' => 'bar'), array('foo' => 'bar')),
|
||||||
|
array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||||
|
array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||||
|
array('SQL', array('foo' => ''), array('foo' => '')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ class PhpDumper extends Dumper
|
|||||||
if ($definition->isSynthetic()) {
|
if ($definition->isSynthetic()) {
|
||||||
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
|
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
|
||||||
} elseif ($class = $definition->getClass()) {
|
} elseif ($class = $definition->getClass()) {
|
||||||
$return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : $class, $class);
|
$return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
|
||||||
} elseif ($definition->getFactoryClass()) {
|
} elseif ($definition->getFactoryClass()) {
|
||||||
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod());
|
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod());
|
||||||
} elseif ($definition->getFactoryService()) {
|
} elseif ($definition->getFactoryService()) {
|
||||||
|
@ -46,7 +46,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getTestService()
|
protected function getTestService()
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooService()
|
protected function getFooService()
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getBarService()
|
protected function getBarService()
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Baz A Baz instance.
|
* @return \Baz A Baz instance.
|
||||||
*/
|
*/
|
||||||
protected function getBazService()
|
protected function getBazService()
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getConfiguredServiceService()
|
protected function getConfiguredServiceService()
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDecoratedService()
|
protected function getDecoratedService()
|
||||||
{
|
{
|
||||||
@ -118,7 +118,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDecoratorServiceService()
|
protected function getDecoratorServiceService()
|
||||||
{
|
{
|
||||||
@ -131,7 +131,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDecoratorServiceWithNameService()
|
protected function getDecoratorServiceWithNameService()
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDependsOnRequestService()
|
protected function getDependsOnRequestService()
|
||||||
{
|
{
|
||||||
@ -161,7 +161,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar A Bar instance.
|
* @return \Bar A Bar instance.
|
||||||
*/
|
*/
|
||||||
protected function getFactoryServiceService()
|
protected function getFactoryServiceService()
|
||||||
{
|
{
|
||||||
@ -174,7 +174,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooService()
|
protected function getFooService()
|
||||||
{
|
{
|
||||||
@ -227,7 +227,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Foo A Foo instance.
|
* @return \Foo A Foo instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooWithInlineService()
|
protected function getFooWithInlineService()
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getMethodCall1Service()
|
protected function getMethodCall1Service()
|
||||||
{
|
{
|
||||||
@ -298,7 +298,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* If you want to be able to request this service from the container directly,
|
* If you want to be able to request this service from the container directly,
|
||||||
* make it public, otherwise you might end up with broken code.
|
* make it public, otherwise you might end up with broken code.
|
||||||
*
|
*
|
||||||
* @return ConfClass A ConfClass instance.
|
* @return \ConfClass A ConfClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getConfiguratorServiceService()
|
protected function getConfiguratorServiceService()
|
||||||
{
|
{
|
||||||
@ -319,7 +319,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* If you want to be able to request this service from the container directly,
|
* If you want to be able to request this service from the container directly,
|
||||||
* make it public, otherwise you might end up with broken code.
|
* make it public, otherwise you might end up with broken code.
|
||||||
*
|
*
|
||||||
* @return Bar A Bar instance.
|
* @return \Bar A Bar instance.
|
||||||
*/
|
*/
|
||||||
protected function getInlinedService()
|
protected function getInlinedService()
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getBarService()
|
protected function getBarService()
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Baz A Baz instance.
|
* @return \Baz A Baz instance.
|
||||||
*/
|
*/
|
||||||
protected function getBazService()
|
protected function getBazService()
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getConfiguredServiceService()
|
protected function getConfiguredServiceService()
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDecoratorServiceService()
|
protected function getDecoratorServiceService()
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDecoratorServiceWithNameService()
|
protected function getDecoratorServiceWithNameService()
|
||||||
{
|
{
|
||||||
@ -143,7 +143,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return stdClass A stdClass instance.
|
* @return \stdClass A stdClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getDependsOnRequestService()
|
protected function getDependsOnRequestService()
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar A Bar instance.
|
* @return \Bar A Bar instance.
|
||||||
*/
|
*/
|
||||||
protected function getFactoryServiceService()
|
protected function getFactoryServiceService()
|
||||||
{
|
{
|
||||||
@ -173,7 +173,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooService()
|
protected function getFooService()
|
||||||
{
|
{
|
||||||
@ -197,7 +197,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return BazClass A BazClass instance.
|
* @return \BazClass A BazClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getFoo_BazService()
|
protected function getFoo_BazService()
|
||||||
{
|
{
|
||||||
@ -211,7 +211,7 @@ class ProjectServiceContainer extends Container
|
|||||||
/**
|
/**
|
||||||
* Gets the 'foo_bar' service.
|
* Gets the 'foo_bar' service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooBarService()
|
protected function getFooBarService()
|
||||||
{
|
{
|
||||||
@ -224,7 +224,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Foo A Foo instance.
|
* @return \Foo A Foo instance.
|
||||||
*/
|
*/
|
||||||
protected function getFooWithInlineService()
|
protected function getFooWithInlineService()
|
||||||
{
|
{
|
||||||
@ -246,7 +246,7 @@ class ProjectServiceContainer extends Container
|
|||||||
* This service is shared.
|
* This service is shared.
|
||||||
* This method always returns the same instance of the service.
|
* This method always returns the same instance of the service.
|
||||||
*
|
*
|
||||||
* @return Bar\FooClass A Bar\FooClass instance.
|
* @return \Bar\FooClass A Bar\FooClass instance.
|
||||||
*/
|
*/
|
||||||
protected function getMethodCall1Service()
|
protected function getMethodCall1Service()
|
||||||
{
|
{
|
||||||
|
@ -259,9 +259,11 @@ class Crawler extends \SplObjectStorage
|
|||||||
public function addNodeList(\DOMNodeList $nodes)
|
public function addNodeList(\DOMNodeList $nodes)
|
||||||
{
|
{
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
|
if ($node instanceof \DOMNode) {
|
||||||
$this->addNode($node);
|
$this->addNode($node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an array of \DOMNode instances to the list of nodes.
|
* Adds an array of \DOMNode instances to the list of nodes.
|
||||||
@ -898,18 +900,22 @@ class Crawler extends \SplObjectStorage
|
|||||||
// BC for Symfony 2.4 and lower were elements were adding in a fake _root parent
|
// BC for Symfony 2.4 and lower were elements were adding in a fake _root parent
|
||||||
if (0 === strpos($expression, '/_root/')) {
|
if (0 === strpos($expression, '/_root/')) {
|
||||||
$expression = './'.substr($expression, 7);
|
$expression = './'.substr($expression, 7);
|
||||||
|
} elseif (0 === strpos($expression, 'self::*/')) {
|
||||||
|
$expression = './'.substr($expression, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add prefix before absolute element selector
|
// add prefix before absolute element selector
|
||||||
if (empty($expression)) {
|
if (empty($expression)) {
|
||||||
$expression = $nonMatchingExpression;
|
$expression = $nonMatchingExpression;
|
||||||
} elseif (0 === strpos($expression, '//')) {
|
} elseif (0 === strpos($expression, '//')) {
|
||||||
$expression = 'descendant-or-self::' . substr($expression, 2);
|
$expression = 'descendant-or-self::'.substr($expression, 2);
|
||||||
} elseif (0 === strpos($expression, './/')) {
|
} elseif (0 === strpos($expression, './/')) {
|
||||||
$expression = 'descendant-or-self::' . substr($expression, 3);
|
$expression = 'descendant-or-self::'.substr($expression, 3);
|
||||||
} elseif (0 === strpos($expression, './')) {
|
} elseif (0 === strpos($expression, './')) {
|
||||||
$expression = 'self::' . substr($expression, 2);
|
$expression = 'self::'.substr($expression, 2);
|
||||||
} elseif ('/' === $expression[0]) {
|
} elseif (0 === strpos($expression, 'child::')) {
|
||||||
|
$expression = 'self::'.substr($expression, 7);
|
||||||
|
} elseif ('/' === $expression[0] || 0 === strpos($expression, 'self::')) {
|
||||||
// the only direct child in Symfony 2.4 and lower is _root, which is already handled previously
|
// the only direct child in Symfony 2.4 and lower is _root, which is already handled previously
|
||||||
// so let's drop the expression entirely
|
// so let's drop the expression entirely
|
||||||
$expression = $nonMatchingExpression;
|
$expression = $nonMatchingExpression;
|
||||||
@ -917,9 +923,12 @@ class Crawler extends \SplObjectStorage
|
|||||||
// '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results
|
// '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results
|
||||||
$expression = $nonMatchingExpression;
|
$expression = $nonMatchingExpression;
|
||||||
} elseif (0 === strpos($expression, 'descendant::')) {
|
} elseif (0 === strpos($expression, 'descendant::')) {
|
||||||
$expression = 'descendant-or-self::' . substr($expression, strlen('descendant::'));
|
$expression = 'descendant-or-self::'.substr($expression, strlen('descendant::'));
|
||||||
} elseif (!preg_match('/^(ancestor|ancestor-or-self|attribute|child|descendant-or-self|following|following-sibling|parent|preceding|preceding-sibling|self)::/', $expression)) {
|
} elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) {
|
||||||
$expression = 'self::' .$expression;
|
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
|
||||||
|
$expression = $nonMatchingExpression;
|
||||||
|
} elseif (0 !== strpos($expression, 'descendant-or-self::')) {
|
||||||
|
$expression = 'self::'.$expression;
|
||||||
}
|
}
|
||||||
$expressions[] = $parenthesis.$expression;
|
$expressions[] = $parenthesis.$expression;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\DomCrawler;
|
namespace Symfony\Component\DomCrawler;
|
||||||
|
|
||||||
|
use Symfony\Component\DomCrawler\Field\ChoiceFormField;
|
||||||
use Symfony\Component\DomCrawler\Field\FormField;
|
use Symfony\Component\DomCrawler\Field\FormField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -460,7 +461,9 @@ class Form extends Link implements \ArrayAccess
|
|||||||
if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) {
|
if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) {
|
||||||
$this->set(new Field\ChoiceFormField($node));
|
$this->set(new Field\ChoiceFormField($node));
|
||||||
} elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) {
|
} elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) {
|
||||||
if ($this->has($node->getAttribute('name'))) {
|
// there may be other fields with the same name that are no choice
|
||||||
|
// fields already registered (see https://github.com/symfony/symfony/issues/11689)
|
||||||
|
if ($this->has($node->getAttribute('name')) && $this->get($node->getAttribute('name')) instanceof ChoiceFormField) {
|
||||||
$this->get($node->getAttribute('name'))->addChoice($node);
|
$this->get($node->getAttribute('name'))->addChoice($node);
|
||||||
} else {
|
} else {
|
||||||
$this->set(new Field\ChoiceFormField($node));
|
$this->set(new Field\ChoiceFormField($node));
|
||||||
|
@ -422,8 +422,8 @@ EOF
|
|||||||
$this->assertCount(1, $crawler->filterXPath('//body'));
|
$this->assertCount(1, $crawler->filterXPath('//body'));
|
||||||
$this->assertCount(1, $crawler->filterXPath('descendant-or-self::body'));
|
$this->assertCount(1, $crawler->filterXPath('descendant-or-self::body'));
|
||||||
$this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div');
|
$this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div');
|
||||||
$this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child');
|
$this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child');
|
||||||
$this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child');
|
$this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child');
|
||||||
$this->assertCount(5, $crawler->filterXPath('(//a | //div)//img'));
|
$this->assertCount(5, $crawler->filterXPath('(//a | //div)//img'));
|
||||||
$this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)'));
|
$this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)'));
|
||||||
$this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )'));
|
$this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )'));
|
||||||
@ -494,72 +494,104 @@ EOF
|
|||||||
$this->assertSame('Music', $crawler->text());
|
$this->assertSame('Music', $crawler->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFilterXPathWithFakeRoot()
|
||||||
|
{
|
||||||
|
$crawler = $this->createTestCrawler();
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('.'), '->filterXPath() returns an empty result if the XPath references the fake root node');
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('/_root'), '->filterXPath() returns an empty result if the XPath references the fake root node');
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('self::*'), '->filterXPath() returns an empty result if the XPath references the fake root node');
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('self::_root'), '->filterXPath() returns an empty result if the XPath references the fake root node');
|
||||||
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithAncestorAxis()
|
public function testFilterXPathWithAncestorAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
||||||
|
|
||||||
$this->assertCount(2, $crawler->filterXPath('ancestor::*'));
|
$this->assertCount(0, $crawler->filterXPath('ancestor::*'), 'The fake root node has no ancestor nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithAncestorOrSelfAxis()
|
public function testFilterXPathWithAncestorOrSelfAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
||||||
|
|
||||||
$this->assertCount(3, $crawler->filterXPath('ancestor-or-self::*'));
|
$this->assertCount(0, $crawler->filterXPath('ancestor-or-self::*'), 'The fake root node has no ancestor nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithAttributeAxis()
|
public function testFilterXPathWithAttributeAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
||||||
|
|
||||||
$this->assertCount(2, $crawler->filterXPath('attribute::*'));
|
$this->assertCount(0, $crawler->filterXPath('attribute::*'), 'The fake root node has no attribute nodes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFilterXPathWithAttributeAxisAfterElementAxis()
|
||||||
|
{
|
||||||
|
$this->assertCount(3, $this->createTestCrawler()->filterXPath('//form/button/attribute::*'), '->filterXPath() handles attribute axes properly when they are preceded by an element filtering axis');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithChildAxis()
|
public function testFilterXPathWithChildAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//body');
|
$crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]');
|
||||||
|
|
||||||
$this->assertCount(2, $crawler->filterXPath('child::input'));
|
$this->assertCount(1, $crawler->filterXPath('child::div'), 'A child selection finds only the current div');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithFollowingAxis()
|
public function testFilterXPathWithFollowingAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//a');
|
$crawler = $this->createTestCrawler()->filterXPath('//a');
|
||||||
|
|
||||||
$this->assertCount(3, $crawler->filterXPath('following::div'));
|
$this->assertCount(0, $crawler->filterXPath('following::div'), 'The fake root node has no following nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithFollowingSiblingAxis()
|
public function testFilterXPathWithFollowingSiblingAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//a');
|
$crawler = $this->createTestCrawler()->filterXPath('//a');
|
||||||
|
|
||||||
$this->assertCount(2, $crawler->filterXPath('following-sibling::div'));
|
$this->assertCount(0, $crawler->filterXPath('following-sibling::div'), 'The fake root node has no following nodes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFilterXPathWithNamespaceAxis()
|
||||||
|
{
|
||||||
|
$crawler = $this->createTestCrawler()->filterXPath('//button');
|
||||||
|
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('namespace::*'), 'The fake root node has no namespace nodes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFilterXPathWithNamespaceAxisAfterElementAxis()
|
||||||
|
{
|
||||||
|
$crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]/namespace::*');
|
||||||
|
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('namespace::*'), 'Namespace axes cannot be requested');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithParentAxis()
|
public function testFilterXPathWithParentAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//button');
|
$crawler = $this->createTestCrawler()->filterXPath('//button');
|
||||||
|
|
||||||
$this->assertEquals('foo', $crawler->filterXPath('parent::*')->attr('action'));
|
$this->assertCount(0, $crawler->filterXPath('parent::*'), 'The fake root node has no parent nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithPrecedingAxis()
|
public function testFilterXPathWithPrecedingAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
||||||
|
|
||||||
$this->assertCount(13, $crawler->filterXPath('preceding::*'));
|
$this->assertCount(0, $crawler->filterXPath('preceding::*'), 'The fake root node has no preceding nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithPrecedingSiblingAxis()
|
public function testFilterXPathWithPrecedingSiblingAxis()
|
||||||
{
|
{
|
||||||
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
$crawler = $this->createTestCrawler()->filterXPath('//form');
|
||||||
|
|
||||||
$this->assertCount(9, $crawler->filterXPath('preceding-sibling::*'));
|
$this->assertCount(0, $crawler->filterXPath('preceding-sibling::*'), 'The fake root node has no preceding nodes');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterXPathWithSelfAxes()
|
public function testFilterXPathWithSelfAxes()
|
||||||
{
|
{
|
||||||
$this->assertCount(1, $this->createTestCrawler()->filterXPath('self::*'));
|
$crawler = $this->createTestCrawler()->filterXPath('//a');
|
||||||
|
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('self::a'), 'The fake root node has no "real" element name');
|
||||||
|
$this->assertCount(0, $crawler->filterXPath('self::a/img'), 'The fake root node has no "real" element name');
|
||||||
|
$this->assertCount(9, $crawler->filterXPath('self::*/a'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -969,6 +1001,7 @@ HTML;
|
|||||||
</ul>
|
</ul>
|
||||||
<div id="parent">
|
<div id="parent">
|
||||||
<div id="child"></div>
|
<div id="child"></div>
|
||||||
|
<div id="child2" xmlns:foo="http://example.com"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="sibling"><img /></div>
|
<div id="sibling"><img /></div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -802,6 +802,28 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDifferentFieldTypesWithSameName()
|
||||||
|
{
|
||||||
|
$dom = new \DOMDocument();
|
||||||
|
$dom->loadHTML('
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<form action="/">
|
||||||
|
<input type="hidden" name="option" value="default">
|
||||||
|
<input type="radio" name="option" value="A">
|
||||||
|
<input type="radio" name="option" value="B">
|
||||||
|
<input type="hidden" name="settings[1]" value="0">
|
||||||
|
<input type="checkbox" name="settings[1]" value="1" id="setting-1">
|
||||||
|
<button>klickme</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
');
|
||||||
|
$form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com');
|
||||||
|
|
||||||
|
$this->assertInstanceOf('Symfony\Component\DomCrawler\Field\ChoiceFormField', $form->get('option'));
|
||||||
|
}
|
||||||
|
|
||||||
protected function getFormFieldMock($name, $value = null)
|
protected function getFormFieldMock($name, $value = null)
|
||||||
{
|
{
|
||||||
$field = $this
|
$field = $this
|
||||||
|
@ -64,7 +64,7 @@ class ValueToDuplicatesTransformer implements DataTransformerInterface
|
|||||||
$emptyKeys = array();
|
$emptyKeys = array();
|
||||||
|
|
||||||
foreach ($this->keys as $key) {
|
foreach ($this->keys as $key) {
|
||||||
if (!empty($array[$key])) {
|
if (isset($array[$key]) && '' !== $array[$key] && false !== $array[$key] && array() !== $array[$key]) {
|
||||||
if ($array[$key] !== $result) {
|
if ($array[$key] !== $result) {
|
||||||
throw new TransformationFailedException(
|
throw new TransformationFailedException(
|
||||||
'All values in the array should be the same'
|
'All values in the array should be the same'
|
||||||
|
@ -82,6 +82,29 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($this->transformer->reverseTransform($input));
|
$this->assertNull($this->transformer->reverseTransform($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReverseTransformEmptyArray()
|
||||||
|
{
|
||||||
|
$input = array(
|
||||||
|
'a' => array(),
|
||||||
|
'b' => array(),
|
||||||
|
'c' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertNull($this->transformer->reverseTransform($input));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testReverseTransformZeroString()
|
||||||
|
{
|
||||||
|
$input = array(
|
||||||
|
'a' => '0',
|
||||||
|
'b' => '0',
|
||||||
|
'c' => '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('0', $this->transformer->reverseTransform($input));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||||
*/
|
*/
|
||||||
|
@ -219,7 +219,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
|
||||||
switch ($n->localName) {
|
switch ($n->localName) {
|
||||||
case 'default':
|
case 'default':
|
||||||
if ($n->hasAttribute('xsi:nil') && 'true' == $n->getAttribute('xsi:nil')) {
|
if ($this->isElementValueNull($n)) {
|
||||||
$defaults[$n->getAttribute('key')] = null;
|
$defaults[$n->getAttribute('key')] = null;
|
||||||
} else {
|
} else {
|
||||||
$defaults[$n->getAttribute('key')] = trim($n->textContent);
|
$defaults[$n->getAttribute('key')] = trim($n->textContent);
|
||||||
@ -242,4 +242,15 @@ class XmlFileLoader extends FileLoader
|
|||||||
|
|
||||||
return array($defaults, $requirements, $options, $condition);
|
return array($defaults, $requirements, $options, $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isElementValueNull(\DOMElement $element)
|
||||||
|
{
|
||||||
|
$namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||||
|
|
||||||
|
if (!$element->hasAttributeNS($namespaceUri, 'nil')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml
Normal file
12
src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<routes xmlns="http://symfony.com/schema/routing"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
|
<route id="blog_show" path="/blog/{slug}">
|
||||||
|
<default key="foo" xsi:nil="true" />
|
||||||
|
<default key="bar" xsi:nil="1" />
|
||||||
|
<default key="foobar" xsi:nil="false">foo</default>
|
||||||
|
<default key="baz" xsi:nil="0">bar</default>
|
||||||
|
</route>
|
||||||
|
</routes>
|
@ -121,4 +121,18 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||||
$loader->load('withdoctype.xml');
|
$loader->load('withdoctype.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNullValues()
|
||||||
|
{
|
||||||
|
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||||
|
$routeCollection = $loader->load('null_values.xml');
|
||||||
|
$route = $routeCollection->get('blog_show');
|
||||||
|
|
||||||
|
$this->assertTrue($route->hasDefault('foo'));
|
||||||
|
$this->assertNull($route->getDefault('foo'));
|
||||||
|
$this->assertTrue($route->hasDefault('bar'));
|
||||||
|
$this->assertNull($route->getDefault('bar'));
|
||||||
|
$this->assertEquals('foo', $route->getDefault('foobar'));
|
||||||
|
$this->assertEquals('bar', $route->getDefault('baz'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ interface VoterInterface
|
|||||||
* ACCESS_GRANTED, ACCESS_DENIED, or ACCESS_ABSTAIN.
|
* ACCESS_GRANTED, ACCESS_DENIED, or ACCESS_ABSTAIN.
|
||||||
*
|
*
|
||||||
* @param TokenInterface $token A TokenInterface instance
|
* @param TokenInterface $token A TokenInterface instance
|
||||||
* @param object $object The object to secure
|
* @param object|null $object The object to secure
|
||||||
* @param array $attributes An array of attributes associated with the method being invoked
|
* @param array $attributes An array of attributes associated with the method being invoked
|
||||||
*
|
*
|
||||||
* @return int either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED
|
* @return int either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED
|
||||||
|
@ -17,8 +17,6 @@ use Symfony\Component\Validator\Constraints\Traverse;
|
|||||||
use Symfony\Component\Validator\Constraints\Valid;
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||||
use Symfony\Component\Validator\Exception\GroupDefinitionException;
|
use Symfony\Component\Validator\Exception\GroupDefinitionException;
|
||||||
use Symfony\Component\Validator\MetadataInterface as LegacyMetadataInterface;
|
|
||||||
use Symfony\Component\Validator\PropertyMetadataContainerInterface;
|
|
||||||
use Symfony\Component\Validator\ValidationVisitorInterface;
|
use Symfony\Component\Validator\ValidationVisitorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +27,7 @@ use Symfony\Component\Validator\ValidationVisitorInterface;
|
|||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class ClassMetadata extends ElementMetadata implements LegacyMetadataInterface, PropertyMetadataContainerInterface, ClassMetadataInterface
|
class ClassMetadata extends ElementMetadata implements ClassMetadataInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -499,7 +497,7 @@ class ClassMetadata extends ElementMetadata implements LegacyMetadataInterface,
|
|||||||
/**
|
/**
|
||||||
* Class nodes are never cascaded.
|
* Class nodes are never cascaded.
|
||||||
*
|
*
|
||||||
* @return bool Always returns false.
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCascadingStrategy()
|
public function getCascadingStrategy()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user