Skip to content

Commit

Permalink
Merge branch '2.3' into 2.7
Browse files Browse the repository at this point in the history
* 2.3:
  Static code analysis
  Update AnnotationDirectoryLoader.php
  [FrameworkBundle] Fix template location for PHP templates
  [FrameworkBundle] Add path verification to the template parsing test cases
  • Loading branch information
fabpot committed Jan 27, 2016
2 parents 96eb903 + 89e8619 commit 1876b4f
Show file tree
Hide file tree
Showing 32 changed files with 78 additions and 70 deletions.
Expand Up @@ -153,7 +153,7 @@ protected function setMappingDriverConfig(array $mappingConfig, $mappingName)
*/
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);
Expand Down
Expand Up @@ -60,7 +60,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi

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));
}
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -55,7 +55,7 @@ public function parse($name)
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);
}

Expand Down
Expand Up @@ -43,30 +43,33 @@ protected function tearDown()
}

/**
* @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')),
);
}

Expand Down
Expand Up @@ -116,7 +116,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;
Expand Down
Expand Up @@ -63,8 +63,7 @@
<script>//<![CDATA[
function toggleMenuPanels(state, doSave) {
var menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'),
displayState, elem, className;
var menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'), displayState;
if (null === savedState) {
savedState = 'block';
Expand Down
Expand Up @@ -134,7 +134,7 @@ pre, code {
}
#menu-profiler li a span.label {
display: block;
padding: 20px 0px 16px 65px;
padding: 20px 0 16px 65px;
min-height: 16px;
overflow: hidden;
}
Expand Down Expand Up @@ -285,7 +285,6 @@ ul.alt li.scream, ul.alt li.scream strong {
color: gray;
}
ul.sf-call-stack li {
text-size: small;
padding: 0 0 0 20px;
}
td.main, td.menu {
Expand Down Expand Up @@ -385,13 +384,12 @@ td.main, td.menu {
line-height: 1.5em;
}
.sf-profiler-timeline .legends span {
border-left-width: 10px;
border-left-style: solid;
border-left: 10px solid;
padding: 0 10px 0 5px;
}
.sf-profiler-timeline canvas {
border: 1px solid #999;
border-width: 1px 0;
border: 1px #999;
border-style: solid none;
}
.collapsed-menu-parents #resume,
.collapsed-menu-parents #collector-content {
Expand Down
Expand Up @@ -104,9 +104,9 @@
}

.sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status {
padding: 0px 5px;
padding: 0 5px;
border-radius: 5px;
margin-bottom: 0px;
margin-bottom: 0;
vertical-align: top;
}

Expand Down Expand Up @@ -140,13 +140,11 @@
display: none;
position: absolute;
background-color: #fff;
border: 1px solid #bbb;
padding: 9px 0;
margin-left: -1px;

bottom: 38px;
border-bottom-width: 0;
border-bottom: 1px solid #bbb;
border: 1px solid #bbb;
border-radius: 4px 4px 0 0;
}

Expand Down Expand Up @@ -205,7 +203,7 @@
}

.sf-toolbar-block .sf-toolbar-icon > a,
.sf-toolbar-block .sf-toolbar-icon > a:link
.sf-toolbar-block .sf-toolbar-icon > a:link,
.sf-toolbar-block .sf-toolbar-icon > a:hover {
color: black !important;
}
Expand Down
Expand Up @@ -62,8 +62,6 @@ public function testReturns404onTokenNotFound()
if ('found' == $token) {
return new Profile($token);
}

return;
}))
;

Expand Down
Expand Up @@ -74,7 +74,7 @@ public function testHtmlShakespear($css, $count)
$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()
Expand Down
Expand Up @@ -59,13 +59,27 @@ public function testAddASubscriberService()
->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);

$dispatcher = new ContainerAwareEventDispatcher($container);
$dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');

$dispatcher->dispatch('onEvent', $event);
$dispatcher->dispatch('onEventWithPriority', $event);
$dispatcher->dispatch('onEventNested', $event);
}

public function testPreventDuplicateListenerService()
Expand Down Expand Up @@ -239,11 +253,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)
{
}
}
Expand Up @@ -94,7 +94,7 @@ public function searchInDirectory($dir)
$command->setErrorHandler(
$this->ignoreUnreadableDirs
// If directory is unreadable and finder is set to ignore it, `stderr` is ignored.
? function ($stderr) { return; }
? function ($stderr) { }
: function ($stderr) { throw new AccessDeniedException($stderr); }
);

Expand Down
Expand Up @@ -64,7 +64,7 @@ public function testValidationGroupsCanBeSetToCallback()
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')));
Expand Down
Expand Up @@ -482,6 +482,6 @@ public function testCount()
unset($map[0]);
$map[] = 3;

$this->assertSame(2, count($map));
$this->assertCount(2, $map);
}
}
2 changes: 0 additions & 2 deletions src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -1828,8 +1828,6 @@ protected function preparePathInfo()
return '/';
}

$pathInfo = '/';

// Remove the query string from REQUEST_URI
if ($pos = strpos($requestUri, '?')) {
$requestUri = substr($requestUri, 0, $pos);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Expand Up @@ -277,7 +277,7 @@ protected function invalidate(Request $request, $catch = false)
// 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) {
Expand Down Expand Up @@ -503,7 +503,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n
$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']);
}
Expand Down
Expand Up @@ -77,7 +77,7 @@ protected function fetch($db, $query, array $args = array())
$return = array();

if ($db instanceof \SQLite3) {
$stmt = $this->prepareStatement($db, $query, true);
$stmt = $this->prepareStatement($db, $query);
foreach ($args as $arg => $val) {
$stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
}
Expand Down
Expand Up @@ -121,8 +121,6 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir

return $data;
}

return;
}

/**
Expand Down
Expand Up @@ -133,16 +133,13 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir

return $data;
}

return;
}

/**
* {@inheritdoc}
*/
protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir)
{
return;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Intl/Data/Util/LocaleScanner.php
Expand Up @@ -67,7 +67,7 @@ public function scanLocales($sourceDir)
*/
public function scanAliases($sourceDir)
{
$locales = $this->scanLocales($sourceDir, '.txt');
$locales = $this->scanLocales($sourceDir);
$aliases = array();

// Delete locales that are no aliases
Expand Down
Expand Up @@ -638,8 +638,7 @@ protected function getDefaultPattern()
if (self::NONE !== $this->timetype) {
$patternParts[] = $this->defaultTimeFormats[$this->timetype];
}
$pattern = implode(', ', $patternParts);

return $pattern;
return implode(', ', $patternParts);
}
}
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Intl\Tests\Data\Bundle\Reader;

use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader;
use Symfony\Component\Intl\Intl;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter;
use Symfony\Component\Intl\Intl;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter;
use Symfony\Component\Intl\Intl;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down
Expand Up @@ -64,13 +64,13 @@ public function testScanLocales()
{
$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));
}
}

0 comments on commit 1876b4f

Please sign in to comment.