Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Commit

Permalink
feature #8 Fix Symfony 4 compatibility (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | 
| License       | MIT

#SymfonyConHackday2017

Commits
-------

14f9728 Fix Symfony 4 compatibility
  • Loading branch information
sstok authored Nov 18, 2017
2 parents 34b49be + 14f9728 commit 3ed23e9
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/composer.lock
*.phar
/vendor/
.php_cs.cache
53 changes: 36 additions & 17 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,43 @@ This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
// use SYMFONY_LEVEL:
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
// and extra fixers:
->fixers([
'ordered_use',
//'strict',
'strict_param',
'short_array_syntax',
'phpdoc_order',
'header_comment',
'-psr0',
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP70Migration' => false,
'@PHP71Migration' => false,
'array_syntax' => array('syntax' => 'short'),
'combine_consecutive_unsets' => true,
// 'declare_strict_types' => true,
'header_comment' => ['header' => $header],
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'no_extra_consecutive_blank_lines' => ['continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => false,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => false,
'phpdoc_annotation_without_dot' => true,
'phpdoc_no_empty_return' => false, // PHP 7 compatibility
'phpdoc_order' => true,
// This breaks for variable @var blocks
'phpdoc_to_comment' => false,
'phpdoc_var_without_name' => false,
'semicolon_after_instruction' => true,
'single_import_per_statement' => false,
'strict_comparison' => true,
'strict_param' => true,
'yoda_style' => false, # to broad
])
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->exclude('Fixtures')
->in([__DIR__.'/src', __DIR__.'/tests'])
)
;

26 changes: 0 additions & 26 deletions .styleci.yml

This file was deleted.

18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ branches:

matrix:
include:
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
- php: hhvm-3.15
sudo: required
dist: trusty
group: edge
# - php: 5.5
# env: SKIP_OEL=true
- php: 5.6
- php: 7.0
env: DEPENDENCIES='dev'
- php: 7.1
env: DEPENDENCIES='dev'
- php: 7.1
env: DEPENDENCIES='low'
fast_finish: true
Expand All @@ -30,10 +27,19 @@ before_install:
# Matrix lines for OEL PHP versions are skipped for pull requests
- PHP=$TRAVIS_PHP_VERSION
- if [[ $SKIP_OEL && $TRAVIS_PULL_REQUEST != false ]]; then echo "Version ${PHP} is skipped for this pull request" && exit 0; fi
- if [[ ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- composer selfupdate --stable
- |
# Temp fix `matthiasnoback/symfony-dependency-injection-test` doesn't support Symfony 4 yet
if [[ $DEPENDENCIES == 'dev' ]] && [[ $PHP == '7.1' ]]; then
composer require --no-update "symfony/dependency-injection:v4.0.0-BETA1 as 3.4"
fi;
install:
- |
if [[ $DEPENDENCIES == 'dev' ]] && [[ $PHP == 7* ]]; then
export SYMFONY_PHPUNIT_VERSION=6.2
fi
- export SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
- export SYMFONY_DEPRECATIONS_HELPER=strong
- if [ "$DEPENDENCIES" == "dev" ]; then composer config minimum-stability dev; fi;
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
}
],
"require": {
"php": ">=5.5",
"symfony/twig-bundle": "^2.8 || ^3.0",
"symfony/http-kernel": "^2.8 || ^3.0",
"symfony/dependency-injection": "^2.8 || ^3.0",
"php": "^5.5 || ^7.0",
"twig/twig": "^1.35 || ^2.4.4",
"symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.0 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.0 || ^4.0",
"doctrine/annotations": "^1.2.7"
},
"require-dev": {
"symfony/phpunit-bridge": "^3.2",
"matthiasnoback/symfony-dependency-injection-test": "^0.7.6"
"symfony/phpunit-bridge": "^3.3.13 || ^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0.1 || ^2.2.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions src/DependencyInjection/BreadcrumbsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ final class BreadcrumbsExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$container->register('rollerworks_breadcrumbs.loader', BreadcrumbsLoader::class)
->setArguments([[], [], new Reference('service_container'), new Reference('request_stack')]);
->setArguments([[], [], new Reference('service_container'), new Reference('request_stack')])
->setPublic(true);

$container->register('rollerworks_breadcrumbs.twig_extension', TwigBreadcrumbsExtension::class)
->setArguments([new Reference('rollerworks_breadcrumbs.loader')])
Expand All @@ -33,7 +34,7 @@ public function load(array $configs, ContainerBuilder $container)

public function getConfiguration(array $config, ContainerBuilder $container)
{
// no-op
return null;
}

public function getAlias()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function process(ContainerBuilder $container)
$this->processBreadcrumbProvider(
$parameters,
$serviceId,
$container->findDefinition($serviceId),
$container->findDefinition($serviceId)->setPublic(true),
$annotationReader
)
);
Expand Down
14 changes: 2 additions & 12 deletions src/Twig/BreadcrumbsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@
namespace Rollerworks\Bundle\BreadcrumbsBundle\Twig;

use Rollerworks\Bundle\BreadcrumbsBundle\BreadcrumbsLoader;
use Twig\Extension\AbstractExtension;

class BreadcrumbsExtension extends \Twig_Extension
class BreadcrumbsExtension extends AbstractExtension
{
/**
* @var BreadcrumbsLoader
*/
private $breadcrumbsLoader;

/**
* BreadcrumbExtension constructor.
*/
public function __construct(BreadcrumbsLoader $breadcrumbsLoader)
{
$this->breadcrumbsLoader = $breadcrumbsLoader;
Expand All @@ -36,11 +31,6 @@ public function getFunctions()
];
}

/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'rollerworks_breadcrumbs';
Expand Down
3 changes: 2 additions & 1 deletion tests/Annotation/BreadcrumbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

namespace Rollerworks\Bundle\BreadcrumbsBundle\Tests\Annotation;

use PHPUnit\Framework\TestCase;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\Breadcrumb;

final class BreadcrumbTest extends \PHPUnit_Framework_TestCase
final class BreadcrumbTest extends TestCase
{
/**
* @test
Expand Down
3 changes: 2 additions & 1 deletion tests/Annotation/BreadcrumbsProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

namespace Rollerworks\Bundle\BreadcrumbsBundle\Tests\Annotation;

use PHPUnit\Framework\TestCase;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\BreadcrumbsProvider;

final class BreadcrumbsProviderTest extends \PHPUnit_Framework_TestCase
final class BreadcrumbsProviderTest extends TestCase
{
/**
* @test
Expand Down
3 changes: 2 additions & 1 deletion tests/BreadcrumbsLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

namespace Rollerworks\Bundle\BreadcrumbsBundle\Tests;

use PHPUnit\Framework\TestCase;
use Rollerworks\Bundle\BreadcrumbsBundle\BreadcrumbsLoader;
use Rollerworks\Bundle\BreadcrumbsBundle\Tests\Fixtures\CustomerBreadcrumbsProvider;
use Rollerworks\Bundle\BreadcrumbsBundle\Tests\Fixtures\HomepageBreadcrumbsProvider;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

final class BreadcrumbsLoaderTest extends \PHPUnit_Framework_TestCase
final class BreadcrumbsLoaderTest extends TestCase
{
/**
* @var BreadcrumbsLoader
Expand Down

0 comments on commit 3ed23e9

Please sign in to comment.