Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  [Yaml] throw a ParseException on invalid data type
  [TwigBridge] type-dependent path discovery
  Resources as string have the same problem
  Introduce failing test case when a SplFileInfo object is passed to the extract() method in the TwigExtractor.
  #15331 add infos about deprecated classes to UPGRADE-3.0
  [Asset] removed unused private property.
  [Security] removed useless else condition in SwitchUserListener class.
  [travis] Tests deps=low with PHP 5.6
  [Console] Fix console output with closed stdout
  • Loading branch information
fabpot committed Jul 26, 2015
2 parents 415e6f6 + cd8ccff commit 96e211d
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 15 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -13,7 +13,6 @@ matrix:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: 5.6
env: deps=low
- php: 5.6
Expand Down
11 changes: 11 additions & 0 deletions UPGRADE-3.0.md
Expand Up @@ -299,6 +299,17 @@ UPGRADE FROM 2.x to 3.0
```php
echo $form->getErrors(true, false);
```
* The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList` class has been removed in
favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`.

* The `Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList` class has been removed in
favor of `Symfony\Component\Form\ChoiceList\LazyChoiceList`.

* The `Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList` class has been removed in
favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`.

* The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in
favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`.

### FrameworkBundle

Expand Down
19 changes: 16 additions & 3 deletions src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
Expand Up @@ -73,15 +73,28 @@ public function getExtractData()

/**
* @expectedException \Twig_Error
* @expectedExceptionMessageRegExp /Unclosed "block" in "extractor(\/|\\)syntax_error\.twig" at line 1/
* @expectedExceptionMessageRegExp /Unclosed "block" in ".*extractor(\/|\\)syntax_error\.twig" at line 1/
* @dataProvider resourcesWithSyntaxErrorsProvider
*/
public function testExtractSyntaxError()
public function testExtractSyntaxError($resources)
{
$twig = new \Twig_Environment(new \Twig_Loader_Array(array()));
$twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));

$extractor = new TwigExtractor($twig);
$extractor->extract(__DIR__.'/../Fixtures', new MessageCatalogue('en'));
$extractor->extract($resources, new MessageCatalogue('en'));
}

/**
* @return array
*/
public function resourcesWithSyntaxErrorsProvider()
{
return array(
array(__DIR__.'/../Fixtures'),
array(__DIR__.'/../Fixtures/extractor/syntax_error.twig'),
array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')),
);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Twig\Translation;

use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Translation\Extractor\AbstractFileExtractor;
use Symfony\Component\Translation\Extractor\ExtractorInterface;
use Symfony\Component\Translation\MessageCatalogue;
Expand Down Expand Up @@ -60,7 +61,11 @@ public function extract($resource, MessageCatalogue $catalogue)
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (\Twig_Error $e) {
$e->setTemplateFile($file->getRelativePathname());
if ($file instanceof SplFileInfo) {
$e->setTemplateFile($file->getRelativePathname());
} elseif ($file instanceof \SplFileInfo) {
$e->setTemplateFile($file->getRealPath());
}

throw $e;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Asset/UrlPackage.php
Expand Up @@ -36,7 +36,6 @@
class UrlPackage extends Package
{
private $baseUrls = array();
private $sslUrls;
private $sslPackage;

/**
Expand All @@ -62,7 +61,7 @@ public function __construct($baseUrls = array(), VersionStrategyInterface $versi
$sslUrls = $this->getSslUrls($baseUrls);

if ($sslUrls && $baseUrls !== $sslUrls) {
$this->sslPackage = new UrlPackage($sslUrls, $versionStrategy);
$this->sslPackage = new self($sslUrls, $versionStrategy);
}
}

Expand Down
27 changes: 22 additions & 5 deletions src/Symfony/Component/Console/Output/ConsoleOutput.php
Expand Up @@ -46,12 +46,9 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
*/
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
{
$outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
$errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';

parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);

$this->stderr = new StreamOutput(fopen($errorStream, 'w'), $verbosity, $decorated, $this->getFormatter());
$this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
}

/**
Expand Down Expand Up @@ -129,4 +126,24 @@ private function isRunningOS400()
{
return 'OS400' === php_uname('s');
}

/**
* @return resource
*/
private function openOutputStream()
{
$outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';

return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
}

/**
* @return resource
*/
private function openErrorStream()
{
$errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';

return fopen($errorStream, 'w');
}
}
Expand Up @@ -115,9 +115,9 @@ private function attemptSwitchUser(Request $request)
if (false !== $originalToken) {
if ($token->getUsername() === $request->get($this->usernameParameter)) {
return $token;
} else {
throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername()));
}

throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername()));
}

if (false === $this->accessDecisionManager->decide($token, array($this->role))) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -234,7 +234,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
}

// 1-liner optionally followed by newline(s)
if ($this->lines[0] === trim($value)) {
if (is_string($value) && $this->lines[0] === trim($value)) {
try {
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
} catch (ParseException $e) {
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Expand Up @@ -551,6 +551,21 @@ public function testMappingInASequence()
);
}

/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage missing colon
*/
public function testScalarInSequence()
{
Yaml::parse(<<<EOF
foo:
- bar
"missing colon"
foo: bar
EOF
);
}

/**
* > It is an error for two equal keys to appear in the same mapping node.
* > In such a case the YAML processor may continue, ignoring the second
Expand Down

0 comments on commit 96e211d

Please sign in to comment.