Merge branch '2.8' into 3.0

* 2.8:
  [WebProfilerBundle] Don't inherit CSS text-transform property for the toolbar.
  Remove duplicate cursor property
  Increase the inlining YAML level for config:debug
  [Serializer] Minor: fix CS and PHPDoc
  [Form] fix tests
  [Serializer] Ensure that groups are strings
  [Debug] Tell that the extension is for PHP 5 only
  Static code analysis
  Update AnnotationDirectoryLoader.php
  added a test
  Escape the delimiter in Glob::toRegex
  [FrameworkBundle] Fix template location for PHP templates
  [FrameworkBundle] Add path verification to the template parsing test cases
This commit is contained in:
Fabien Potencier 2016-01-27 06:14:46 +01:00
commit 893fecbe69
33 changed files with 101 additions and 57 deletions

View File

@ -153,7 +153,7 @@ abstract class AbstractDoctrineExtension extends Extension
*/
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container)
{
$bundleDir = dirname($bundle->getFilename());
$bundleDir = dirname($bundle->getFileName());
if (!$bundleConfig['type']) {
$bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container);

View File

@ -60,7 +60,7 @@ class DoctrineValidationPass implements CompilerPassInterface
foreach ($container->getParameter('kernel.bundles') as $bundle) {
$reflection = new \ReflectionClass($bundle);
if (is_file($file = dirname($reflection->getFilename()).'/'.$validationPath)) {
if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
$files[] = realpath($file);
$container->addResource(new FileResource($file));
}

View File

@ -85,7 +85,7 @@ EOF
$io->title(sprintf('Current configuration for "%s"', $name));
}
$io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
$io->writeln(Yaml::dump(array($extension->getAlias() => $config), 10));
}
private function compileContainer()

View File

@ -117,7 +117,7 @@ build: 56
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAcCAYAAACtQ6WLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAR1JREFUeNpiPHnyZCMDA8MNID5gZmb2nAEJMH7//v3N169fX969e/cYkL8WqGAHXPLv37//QYzfv39/fvPmzbUnT56sAXInmJub/2H5/x8sx8DCwsIrISFhDmQyPX78+CmQXs70798/BmQsKipqBNTgdvz4cWkmkE5kDATMioqKZkCFdiwg1eiAi4tLGqhQF24nMmBmZuYEigth1QkEbEBxTlySYPvJkwSJ00AnjYylgU6gxB8g/oFVEphkvgLF32KNMmCCewYUv4qhEyj47+HDhyeBzIMYOoEp8CxQw56wsLAncJ1//vz5/P79+2svX74EJc2V4BT58+fPd8CE/QKYHMGJOiIiAp6oWW7evDkNSF8DZYfIyEiU7AAQYACJ2vxVdJW4eQAAAABJRU5ErkJggg==) right top no-repeat;
}
.sf-button .btn-bg {
padding: 0px 14px;
padding: 0 14px;
color: #636363;
line-height: 28px;
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAcCAYAAACgXdXMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAClJREFUeNpiPnny5EKGf//+/Wf6//8/A4QAcrGzKCZwGc9sa2urBBBgAIbDUoYVp9lmAAAAAElFTkSuQmCC) repeat-x top left;

View File

@ -55,7 +55,7 @@ class TemplateNameParser extends BaseTemplateNameParser
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
}
if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
return parent::parse($name);
}

View File

@ -43,30 +43,33 @@ class TemplateNameParserTest extends TestCase
}
/**
* @dataProvider getLogicalNameToTemplateProvider
* @dataProvider parseProvider
*/
public function testParse($name, $ref)
public function testParse($name, $logicalName, $path, $ref)
{
$template = $this->parser->parse($name);
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
$this->assertEquals($template->getLogicalName(), $name);
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
$this->assertSame($logicalName, $template->getLogicalName());
$this->assertSame($path, $template->getPath());
}
public function getLogicalNameToTemplateProvider()
public function parseProvider()
{
return array(
array('FooBundle:Post:index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')),
array('FooBundle:Post:index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')),
array('FooBundle:Post:index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')),
array('SensioFooBundle:Post:index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')),
array('SensioCmsFooBundle:Post:index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')),
array(':Post:index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
array('::index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
array('FooBundle:Post:foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
array('/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
array('name.twig', new BaseTemplateReference('name.twig', 'twig')),
array('name', new BaseTemplateReference('name')),
array('FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')),
array('FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')),
array('FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')),
array('SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')),
array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')),
array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')),
array('name', 'name', 'name', new BaseTemplateReference('name')),
array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')),
);
}

View File

@ -45,6 +45,7 @@
position: fixed;
right: 0;
text-align: left;
text-transform: none;
z-index: 99999;
}
.sf-toolbarreset abbr {
@ -58,7 +59,6 @@
.sf-toolbarreset .hide-button {
background: #444;
cursor: pointer;
display: block;
position: absolute;
top: 0;

View File

@ -62,8 +62,6 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
if ('found' == $token) {
return new Profile($token);
}
return;
}))
;

View File

@ -74,7 +74,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$document = simplexml_import_dom($document);
$bodies = $document->xpath('//body');
$elements = $bodies[0]->xpath($translator->cssToXPath($css));
$this->assertEquals($count, count($elements));
$this->assertCount($count, $elements);
}
public function getXpathLiteralTestData()

View File

@ -1,7 +1,9 @@
Symfony Debug Extension
=======================
Symfony Debug Extension for PHP 5
=================================
This extension publishes several functions to help building powerful debugging tools.
It is compatible with PHP 5.3, 5.4, 5.5 and 5.6; with ZTS and non-ZTS modes.
It is not required thus not provided for PHP 7.
symfony_zval_info()
-------------------
@ -122,7 +124,6 @@ array(3) {
Usage
-----
The extension is compatible with ZTS mode, and should be supported by PHP5.3, 5.4, 5.5 and 5.6.
To enable the extension from source, run:
```

View File

@ -58,6 +58,18 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
->with($event)
;
$service
->expects($this->once())
->method('onEventWithPriority')
->with($event)
;
$service
->expects($this->once())
->method('onEventNested')
->with($event)
;
$container = new Container();
$container->set('service.subscriber', $service);
@ -65,6 +77,8 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');
$dispatcher->dispatch('onEvent', $event);
$dispatcher->dispatch('onEventWithPriority', $event);
$dispatcher->dispatch('onEventNested', $event);
}
public function testPreventDuplicateListenerService()
@ -173,11 +187,21 @@ class SubscriberService implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
'onEvent' => array('onEvent'),
'onEvent' => 'onEvent',
'onEventWithPriority' => array('onEventWithPriority', 10),
'onEventNested' => array(array('onEventNested')),
);
}
public function onEvent(Event $e)
{
}
public function onEventWithPriority(Event $e)
{
}
public function onEventNested(Event $e)
{
}
}

View File

@ -66,7 +66,7 @@ class Glob
$firstByte = true;
}
if ('.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
$regex .= "\\$car";
} elseif ('*' === $car) {
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');

View File

@ -17,6 +17,7 @@ class GlobTest extends \PHPUnit_Framework_TestCase
{
public function testGlobToRegexDelimiters()
{
$this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#'));
$this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*'));
$this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, ''));
$this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/'));

View File

@ -176,6 +176,8 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
$form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory);
$form = $form->setData($object)->getForm();
$this->expectValidateAt(0, 'data', $object, 'Default');
$this->validator->validate($form, new Form());
$this->assertNoViolation();

View File

@ -64,7 +64,7 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase
public function testValidationGroupsCanBeSetToClosure()
{
$form = $this->createForm(array(
'validation_groups' => function (FormInterface $form) { return; },
'validation_groups' => function (FormInterface $form) { },
));
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));

View File

@ -482,6 +482,6 @@ class OrderedHashMapTest extends \PHPUnit_Framework_TestCase
unset($map[0]);
$map[] = 3;
$this->assertSame(2, count($map));
$this->assertCount(2, $map);
}
}

View File

@ -1821,8 +1821,6 @@ class Request
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($requestUri, '?')) {
$requestUri = substr($requestUri, 0, $pos);

View File

@ -255,7 +255,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
// invalidate only when the response is successful
if ($response->isSuccessful() || $response->isRedirect()) {
try {
$this->store->invalidate($request, $catch);
$this->store->invalidate($request);
// As per the RFC, invalidate Location and Content-Location URLs if present
foreach (array('Location', 'Content-Location') as $header) {
@ -481,7 +481,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
$this->processResponseBody($request, $response);
if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) {
$response->setPrivate(true);
$response->setPrivate();
} elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) {
$response->setTtl($this->options['default_ttl']);
}

View File

@ -121,8 +121,6 @@ class CurrencyDataGenerator extends AbstractDataGenerator
return $data;
}
return;
}
/**

View File

@ -133,8 +133,6 @@ class LanguageDataGenerator extends AbstractDataGenerator
return $data;
}
return;
}
/**
@ -142,7 +140,6 @@ class LanguageDataGenerator extends AbstractDataGenerator
*/
protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir)
{
return;
}
/**

View File

@ -67,7 +67,7 @@ class LocaleScanner
*/
public function scanAliases($sourceDir)
{
$locales = $this->scanLocales($sourceDir, '.txt');
$locales = $this->scanLocales($sourceDir);
$aliases = array();
// Delete locales that are no aliases

View File

@ -620,8 +620,7 @@ class IntlDateFormatter
if (self::NONE !== $this->timetype) {
$patternParts[] = $this->defaultTimeFormats[$this->timetype];
}
$pattern = implode(', ', $patternParts);
return $pattern;
return implode(', ', $patternParts);
}
}

View File

@ -64,13 +64,13 @@ class LocaleScannerTest extends \PHPUnit_Framework_TestCase
{
$sortedLocales = array('de', 'de_alias', 'en', 'en_alias', 'fr', 'fr_alias');
$this->assertSame($sortedLocales, $this->scanner->scanLocales($this->directory, '.txt'));
$this->assertSame($sortedLocales, $this->scanner->scanLocales($this->directory));
}
public function testScanAliases()
{
$sortedAliases = array('de_alias' => 'de', 'en_alias' => 'en', 'fr_alias' => 'fr');
$this->assertSame($sortedAliases, $this->scanner->scanAliases($this->directory, '.txt'));
$this->assertSame($sortedAliases, $this->scanner->scanAliases($this->directory));
}
}

View File

@ -66,12 +66,16 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
*/
public function supports($resource, $type = null)
{
if (!is_string($resource)) {
return false;
}
try {
$path = $this->locator->locate($resource);
} catch (\Exception $e) {
return false;
}
return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type);
return is_dir($path) && (!$type || 'annotation' === $type);
}
}

View File

@ -629,9 +629,8 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
$method = 'set'.$key;
$context->$method($value);
}
$generator = new UrlGenerator($routes, $context, $logger);
return $generator;
return new UrlGenerator($routes, $context, $logger);
}
protected function getRoutes($name, Route $route)

View File

@ -172,9 +172,8 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
{
$service = $this->getService(null, array('name' => 'foo', 'path' => '/foo', 'domain' => 'foodomain.foo'));
$request = new Request();
$response = new Response();
$service->loginFail($request, $response);
$service->loginFail($request);
$cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME);
$this->assertTrue($cookie->isCleared());

View File

@ -27,10 +27,12 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
* @var LoaderInterface
*/
private $loader;
/**
* @var Cache
*/
private $cache;
/**
* @var array
*/

View File

@ -65,6 +65,7 @@ class YamlFileLoader extends FileLoader
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
$attributesMetadata = $classMetadata->getAttributesMetadata();
foreach ($yaml['attributes'] as $attribute => $data) {
if (isset($attributesMetadata[$attribute])) {
$attributeMetadata = $attributesMetadata[$attribute];
@ -74,7 +75,15 @@ class YamlFileLoader extends FileLoader
}
if (isset($data['groups'])) {
if (!is_array($data['groups'])) {
throw new MappingException('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
}
foreach ($data['groups'] as $group) {
if (!is_string($group)) {
throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
}
$attributeMetadata->addGroup($group);
}
}

View File

@ -22,6 +22,7 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
* @var array|null
*/
private $attributes;
/**
* @var bool
*/

View File

@ -33,26 +33,32 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
* @var int
*/
protected $circularReferenceLimit = 1;
/**
* @var callable
*/
protected $circularReferenceHandler;
/**
* @var ClassMetadataFactoryInterface|null
*/
protected $classMetadataFactory;
/**
* @var NameConverterInterface|null
*/
protected $nameConverter;
/**
* @var array
*/
protected $callbacks = array();
/**
* @var array
*/
protected $ignoredAttributes = array();
/**
* @var array
*/

View File

@ -41,18 +41,22 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
* @var Encoder\ChainEncoder
*/
protected $encoder;
/**
* @var Encoder\ChainDecoder
*/
protected $decoder;
/**
* @var array
*/
protected $normalizers = array();
/**
* @var array
*/
protected $normalizerCache = array();
/**
* @var array
*/
@ -247,8 +251,10 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
}
foreach ($this->normalizers as $normalizer) {
if ($normalizer instanceof DenormalizerInterface
&& $normalizer->supportsDenormalization($data, $class, $format)) {
if (
$normalizer instanceof DenormalizerInterface &&
$normalizer->supportsDenormalization($data, $class, $format)
) {
return $normalizer->denormalize($data, $class, $format, $context);
}
}

View File

@ -343,7 +343,6 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
array(
array(
'bar' => function ($bar) {
return;
},
),
'baz',

View File

@ -25,9 +25,7 @@ class PhpFileDumper extends FileDumper
*/
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
return $output;
return "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
}
/**