Skip to content

Commit

Permalink
Merge branch '2.3' into 2.5
Browse files Browse the repository at this point in the history
* 2.3:
  added missing files
  [TwigBundle] added a test
  Indicate which file was being parsed if an exception is thrown while running translation:debug
  [ClassLoader] Cast $useIncludePath property to boolean
  [HttpFoundation] Minor spelling fix in PHPDocs
  improve error message for multiple documents
  [Session] remove invalid workaround in session regenerate
  [Kernel] ensure session is saved before sending response
  [Routing] serialize the compiled route to speed things up
  [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns
  [DependencyInjection] use inheritdoc for loaders
  [Config] fix filelocator with empty name
  [Form] fix form handling with unconventional request methods like OPTIONS
  CSRF warning docs on Request::enableHttpMethodParameterOverride()

Conflicts:
	src/Symfony/Component/Routing/Route.php
  • Loading branch information
fabpot committed Nov 3, 2014
2 parents b2ddfa8 + a08fda5 commit 14c417a
Show file tree
Hide file tree
Showing 40 changed files with 465 additions and 293 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% syntax error
13 changes: 13 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,17 @@ public function getExtractData()
array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')),
);
}

/**
* @expectedException \Twig_Error
* @expectedExceptionMessage Unclosed "block" in "extractor/syntax_error.twig" at line 1
*/
public function testExtractSyntaxError()
{
$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'));
}
}
8 changes: 7 additions & 1 deletion src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public function extract($directory, MessageCatalogue $catalogue)
$finder = new Finder();
$files = $finder->files()->name('*.twig')->sortByName()->in($directory);
foreach ($files as $file) {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (\Twig_Error $e) {
$e->setTemplateFile($file->getRelativePathname());

throw $e;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<argument type="service" id="service_container" />
</service>

<service id="session.save_listener" class="Symfony\Component\HttpKernel\EventListener\SaveSessionListener">
<tag name="kernel.event_subscriber" />
</service>

<!-- for BC -->
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
</services>
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function addPrefix($prefix, $paths)
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
$this->useIncludePath = (bool) $useIncludePath;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/UniversalClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class UniversalClassLoader
*/
public function useIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
$this->useIncludePath = (bool) $useIncludePath;
}

/**
Expand Down
20 changes: 8 additions & 12 deletions src/Symfony/Component/Config/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,14 @@ public function __construct($paths = array())
}

/**
* Returns a full path for a given file name.
*
* @param mixed $name The file name to locate
* @param string $currentPath The current path
* @param bool $first Whether to return the first occurrence or an array of filenames
*
* @return string|array The full path to the file|An array of file paths
*
* @throws \InvalidArgumentException When file is not found
* {@inheritdoc}
*/
public function locate($name, $currentPath = null, $first = true)
{
if ('' == $name) {
throw new \InvalidArgumentException('An empty file name is not valid to be located.');
}

if ($this->isAbsolutePath($name)) {
if (!file_exists($name)) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
Expand Down Expand Up @@ -84,10 +80,10 @@ public function locate($name, $currentPath = null, $first = true)
*/
private function isAbsolutePath($file)
{
if ($file[0] == '/' || $file[0] == '\\'
if ($file[0] === '/' || $file[0] === '\\'
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
&& $file[1] === ':'
&& ($file[2] === '\\' || $file[2] === '/')
)
|| null !== parse_url($file, PHP_URL_SCHEME)
) {
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Config/FileLocatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface FileLocatorInterface
/**
* Returns a full path for a given file name.
*
* @param mixed $name The file name to locate
* @param string $currentPath The current path
* @param bool $first Whether to return the first occurrence or an array of filenames
* @param string $name The file name to locate
* @param string|null $currentPath The current path
* @param bool $first Whether to return the first occurrence or an array of filenames
*
* @return string|array The full path to the file|An array of file paths
* @return string|array The full path to the file or an array of file paths
*
* @throws \InvalidArgumentException When file is not found
*/
Expand Down
9 changes: 1 addition & 8 deletions src/Symfony/Component/Config/Loader/DelegatingLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ public function __construct(LoaderResolverInterface $resolver)
}

/**
* Loads a resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return mixed
*
* @throws FileLoaderLoadException if no loader is found.
* {@inheritdoc}
*/
public function load($resource, $type = null)
{
Expand Down
24 changes: 20 additions & 4 deletions src/Symfony/Component/Config/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
*/
abstract class FileLoader extends Loader
{
/**
* @var array
*/
protected static $loading = array();

/**
* @var FileLocatorInterface
*/
protected $locator;

private $currentDir;
Expand All @@ -38,11 +44,21 @@ public function __construct(FileLocatorInterface $locator)
$this->locator = $locator;
}

/**
* Sets the current directory.
*
* @param string $dir
*/
public function setCurrentDir($dir)
{
$this->currentDir = $dir;
}

/**
* Returns the file locator used by this loader.
*
* @return FileLocatorInterface
*/
public function getLocator()
{
return $this->locator;
Expand All @@ -51,10 +67,10 @@ public function getLocator()
/**
* Imports a resource.
*
* @param mixed $resource A Resource
* @param string $type The resource type
* @param bool $ignoreErrors Whether to ignore import errors or not
* @param string $sourceResource The original resource importing the new resource
* @param mixed $resource A Resource
* @param string|null $type The resource type or null if unknown
* @param bool $ignoreErrors Whether to ignore import errors or not
* @param string|null $sourceResource The original resource importing the new resource
*
* @return mixed
*
Expand Down
18 changes: 7 additions & 11 deletions src/Symfony/Component/Config/Loader/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ abstract class Loader implements LoaderInterface
protected $resolver;

/**
* Gets the loader resolver.
*
* @return LoaderResolverInterface A LoaderResolverInterface instance
* {@inheritdoc}
*/
public function getResolver()
{
return $this->resolver;
}

/**
* Sets the loader resolver.
*
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
* {@inheritdoc}
*/
public function setResolver(LoaderResolverInterface $resolver)
{
Expand All @@ -45,8 +41,8 @@ public function setResolver(LoaderResolverInterface $resolver)
/**
* Imports a resource.
*
* @param mixed $resource A Resource
* @param string $type The resource type
* @param mixed $resource A resource
* @param string|null $type The resource type or null if unknown
*
* @return mixed
*/
Expand All @@ -58,12 +54,12 @@ public function import($resource, $type = null)
/**
* Finds a loader able to load an imported resource.
*
* @param mixed $resource A Resource
* @param string $type The resource type
* @param mixed $resource A resource
* @param string|null $type The resource type or null if unknown
*
* @return LoaderInterface A LoaderInterface instance
*
* @throws FileLoaderLoadException if no loader is found
* @throws FileLoaderLoadException If no loader is found
*/
public function resolve($resource, $type = null)
{
Expand Down
14 changes: 8 additions & 6 deletions src/Symfony/Component/Config/Loader/LoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ interface LoaderInterface
/**
* Loads a resource.
*
* @param mixed $resource The resource
* @param string $type The resource type
* @param mixed $resource The resource
* @param string|null $type The resource type or null if unknown
*
* @throws \Exception If something went wrong
*/
public function load($resource, $type = null);

/**
* Returns true if this class supports the given resource.
* Returns whether this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
* @param mixed $resource A resource
* @param string|null $type The resource type or null if unknown
*
* @return bool true if this class supports the given resource, false otherwise
* @return bool True if this class supports the given resource, false otherwise
*/
public function supports($resource, $type = null);

Expand Down
7 changes: 1 addition & 6 deletions src/Symfony/Component/Config/Loader/LoaderResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public function __construct(array $loaders = array())
}

/**
* Returns a loader able to load the resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return LoaderInterface|false A LoaderInterface instance
* {@inheritdoc}
*/
public function resolve($resource, $type = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ interface LoaderResolverInterface
/**
* Returns a loader able to load the resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
* @param mixed $resource A resource
* @param string|null $type The resource type or null if unknown
*
* @return LoaderInterface A LoaderInterface instance
* @return LoaderInterface|false The loader or false if none is able to load the resource
*/
public function resolve($resource, $type = null);
}
23 changes: 10 additions & 13 deletions src/Symfony/Component/Config/Resource/DirectoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class DirectoryResource implements ResourceInterface, \Serializable
/**
* Constructor.
*
* @param string $resource The file path to the resource
* @param string $pattern A pattern to restrict monitored files
* @param string $resource The file path to the resource
* @param string|null $pattern A pattern to restrict monitored files
*/
public function __construct($resource, $pattern = null)
{
Expand All @@ -34,36 +34,33 @@ public function __construct($resource, $pattern = null)
}

/**
* Returns a string representation of the Resource.
*
* @return string A string representation of the Resource
* {@inheritdoc}
*/
public function __toString()
{
return (string) $this->resource;
}

/**
* Returns the resource tied to this Resource.
*
* @return mixed The resource
* {@inheritdoc}
*/
public function getResource()
{
return $this->resource;
}

/**
* Returns the pattern to restrict monitored files
*
* @return string|null
*/
public function getPattern()
{
return $this->pattern;
}

/**
* Returns true if the resource has not been updated since the given timestamp.
*
* @param int $timestamp The last time the resource was loaded
*
* @return bool true if the resource has not been updated, false otherwise
* {@inheritdoc}
*/
public function isFresh($timestamp)
{
Expand Down
19 changes: 7 additions & 12 deletions src/Symfony/Component/Config/Resource/FileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
class FileResource implements ResourceInterface, \Serializable
{
/**
* @var string|false
*/
private $resource;

/**
Expand All @@ -33,35 +36,27 @@ public function __construct($resource)
}

/**
* Returns a string representation of the Resource.
*
* @return string A string representation of the Resource
* {@inheritdoc}
*/
public function __toString()
{
return (string) $this->resource;
}

/**
* Returns the resource tied to this Resource.
*
* @return mixed The resource
* {@inheritdoc}
*/
public function getResource()
{
return $this->resource;
}

/**
* Returns true if the resource has not been updated since the given timestamp.
*
* @param int $timestamp The last time the resource was loaded
*
* @return bool true if the resource has not been updated, false otherwise
* {@inheritdoc}
*/
public function isFresh($timestamp)
{
if (!file_exists($this->resource)) {
if (false === $this->resource || !file_exists($this->resource)) {
return false;
}

Expand Down
Loading

0 comments on commit 14c417a

Please sign in to comment.