Skip to content

Commit

Permalink
Merge pull request #369 from FriendsOfSymfony/fix-root-dir-deprecation
Browse files Browse the repository at this point in the history
Fix root dir deprecation and fix PHP 7.4 deprecation
  • Loading branch information
tobias-93 committed Dec 2, 2019
2 parents 4c6eb91 + cb5c7ac commit 52503b7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ matrix:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4snapshot
- php: 7.1
env: SYMFONY_VERSION='3.4.*'
- php: 7.1
Expand Down
15 changes: 5 additions & 10 deletions Command/DumpCommand.php
Expand Up @@ -28,11 +28,6 @@ class DumpCommand extends Command
{
protected static $defaultName = 'fos:js-routing:dump';

/**
* @var string
*/
private $targetPath;

/**
* @var ExposedRoutesExtractorInterface
*/
Expand All @@ -46,18 +41,18 @@ class DumpCommand extends Command
/**
* @var string
*/
private $rootDir;
private $projectDir;

/**
* @var string
*/
private $requestContextBaseUrl;

public function __construct(ExposedRoutesExtractorInterface $extractor, SerializerInterface $serializer, $rootDir, $requestContextBaseUrl = null)
public function __construct(ExposedRoutesExtractorInterface $extractor, SerializerInterface $serializer, $projectDir, $requestContextBaseUrl = null)
{
$this->extractor = $extractor;
$this->serializer = $serializer;
$this->rootDir = $rootDir;
$this->projectDir = $projectDir;
$this->requestContextBaseUrl = $requestContextBaseUrl;

parent::__construct();
Expand Down Expand Up @@ -145,8 +140,8 @@ private function doDump(InputInterface $input, OutputInterface $output)
$serializer = $this->serializer;
$targetPath = $input->getOption('target') ?:
sprintf(
'%s/../web/js/fos_js_routes%s.%s',
$this->rootDir,
'%s/web/js/fos_js_routes%s.%s',
$this->projectDir,
empty($domain) ? '' : ('_' . implode('_', $domain)),
$input->getOption('format')
);
Expand Down
4 changes: 2 additions & 2 deletions Extractor/ExposedRoutesExtractor.php
Expand Up @@ -253,10 +253,10 @@ protected function buildPattern($domainPatterns)

foreach ($domainPatterns as $domain => $items) {

$patterns[] = '(?P<' . $domain . '>' . implode($items, '|') . ')';
$patterns[] = '(?P<' . $domain . '>' . implode('|', $items) . ')';
}

return implode($patterns, '|');
return implode('|', $patterns);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Expand Up @@ -18,7 +18,7 @@
<service id="fos_js_routing.dump_command" class="FOS\JsRoutingBundle\Command\DumpCommand">
<argument type="service" id="fos_js_routing.extractor" />
<argument type="service" id="fos_js_routing.serializer" />
<argument>%kernel.root_dir%</argument>
<argument>%kernel.project_dir%</argument>
<argument>%fos_js_routing.request_context_base_url%</argument>
<tag name="console.command" />
</service>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/DumpCommandTest.php
Expand Up @@ -98,7 +98,7 @@ public function testExecuteFormatOption()
public function testExecuteUnableToCreateDirectory()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Unable to create directory /root/dir/../web/js');
$this->expectExceptionMessage('Unable to create directory /root/dir/web/js');
$command = new DumpCommand($this->extractor, $this->serializer, '/root/dir');

$tester = new CommandTester($command);
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -17,13 +17,13 @@
],
"require": {
"php": "^7.1",
"symfony/framework-bundle": "~3.0|^4.0|^5.0",
"symfony/serializer": "~3.0|^4.0|^5.0",
"symfony/console": "~3.0|^4.0|^5.0",
"symfony/framework-bundle": "~3.3|^4.0|^5.0",
"symfony/serializer": "~3.3|^4.0|^5.0",
"symfony/console": "~3.3|^4.0|^5.0",
"willdurand/jsonp-callback-validator": "~1.0"
},
"require-dev": {
"symfony/expression-language": "~3.0|^4.0|^5.0",
"symfony/expression-language": "~3.3|^4.0|^5.0",
"symfony/phpunit-bridge": "^3.3|^4.0"
},
"autoload": {
Expand Down

0 comments on commit 52503b7

Please sign in to comment.