Skip to content

Commit

Permalink
Added backslash to PHP internal functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nilportugues committed Nov 2, 2015
1 parent b4801cd commit e6f9764
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"symfony/psr-http-message-bridge": "~0.2"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"symfony/symfony": "2.*",
"fabpot/php-cs-fixer": "~1.9",
"nilportugues/php_backslasher": "~0.2",
"mmoreram/php-formatter": "dev-master"
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public function load(array $configs, ContainerBuilder $container)
*/
private function setMappings(ContainerBuilder $container, $config)
{
if (true === file_exists($config['mappings'])) {
if (true === \file_exists($config['mappings'])) {
$finder = new Finder();
$finder->files()->in($config['mappings']);
$loadedMappings = [];

foreach ($finder as $file) {
/* @var \Symfony\Component\Finder\SplFileInfo $file */
$mapping = file_get_contents($file->getPathname());
$mapping = \file_get_contents($file->getPathname());
$mapping = Yaml::parse($mapping);
$loadedMappings[] = $mapping['mapping'];
}
Expand Down
3 changes: 2 additions & 1 deletion src/Serializer/HalJsonResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ trait HalJsonResponseTrait
{
/**
* @param \Psr\Http\Message\ResponseInterface $response
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function addHeaders(\Psr\Http\Message\ResponseInterface $response)
{
return $response;
}

/**
* @param string $json
*
Expand Down
9 changes: 5 additions & 4 deletions src/Serializer/HalJsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace NilPortugues\Symfony2\HalJsonBundle\Serializer;

use NilPortugues\Api\HalJson\HalJsonTransformer;
Expand Down Expand Up @@ -94,18 +95,18 @@ private function getUrlPattern(Router $router, $routeNameFromMappingFile)
}
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf('Route \'%s\' has not been defined as a Symfony route.', $routeNameFromMappingFile)
\sprintf('Route \'%s\' has not been defined as a Symfony route.', $routeNameFromMappingFile)
);
}

preg_match_all('/{(.*?)}/', $route->getPath(), $matches);
\preg_match_all('/{(.*?)}/', $route->getPath(), $matches);

$pattern = [];
if (!empty($matches)) {
$pattern = array_combine($matches[1], $matches[0]);
$pattern = \array_combine($matches[1], $matches[0]);
}

return urldecode($router->generate($routeNameFromMappingFile, $pattern, true));
return \urldecode($router->generate($routeNameFromMappingFile, $pattern, true));
}

return (string) $routeNameFromMappingFile;
Expand Down

0 comments on commit e6f9764

Please sign in to comment.