Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Tests/ export-ignore
tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ build/
vendor/
composer.lock
phpunit.xml
/.idea
/ECNFeatureToggleBundle.iml
/.idea/
/.phpunit.result.cache
.php-cs-fixer.cache
27 changes: 27 additions & 0 deletions .php-cs-fixer.src.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/src')
;

return (new PhpCsFixer\Config())
->setRules([
// Symfony Coding Standard (includes PSR2 and PSR12) but disable some settings to not violate the current Otelo Coding Standard
'@Symfony' => true,
'@Symfony:risky' => true,
// So declare_strict_type can be on the same line as the opening tag
'blank_line_after_opening_tag' => false,
'linebreak_after_opening_tag' => false,
// Would otherwise remove @inheritdoc tags from classes does not inherit.
'phpdoc_no_useless_inheritdoc' => false,
// Would otherwise remove @param, @return and @var tags that don't provide any useful information.
'no_superfluous_phpdoc_tags' => false,
// In @PHP80Migration:risky containing 'declare_strict_types' is not needed on interfaces,
// so you can remove them there @see https://github.com/Automattic/phpcs-neutron-standard/issues/20
'@PHP81Migration' => true,
'@DoctrineAnnotation' => true,
// Risky formatting. Use --allow-risky=true in the command to use them.
'@PHP80Migration:risky' => true,
])
->setFinder($finder)
;
30 changes: 30 additions & 0 deletions .php-cs-fixer.tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__.'/tests')
;

return (new PhpCsFixer\Config())
->setRules([
// Symfony Coding Standard (includes PSR2 and PSR12) but disable some settings to not violate the current Otelo Coding Standard
'@Symfony' => true,
'@Symfony:risky' => true,
// So declare_strict_type can be on the same line as the opening tag
'blank_line_after_opening_tag' => false,
'linebreak_after_opening_tag' => false,
// Would otherwise remove @inheritdoc tags from classes does not inherit.
'phpdoc_no_useless_inheritdoc' => false,
// Would otherwise remove @param, @return and @var tags that don't provide any useful information.
'no_superfluous_phpdoc_tags' => false,
// In @PHP80Migration:risky containing 'declare_strict_types' is not needed on interfaces,
// so you can remove them there @see https://github.com/Automattic/phpcs-neutron-standard/issues/20
'@PHP81Migration' => true,
'@DoctrineAnnotation' => true,
// Risky formatting. Use --allow-risky=true in the command to use them.
'@PHP80Migration:risky' => true,
'@PHPUnit100Migration:risky' => true,
// avoid that tests get void as return value (for setup is fine -> add manually)
'void_return' => false,
])
->setFinder($finder)
;
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Change Log

## 3.1.0 - 2023-05-12

### Added

- added support for PHP >=8
- added refactoring tools (php-cs-fixer, rector)

## 3.0.0 - 2022-02-01

### Added

- added support for PHP 8 and 8.1
- added support for Symfony 5.4 and 6
- added use of attributes

### Changed

- ControllerFilterEvent to ControllerEvent

### Removed

- removed support for PHP 7 and lower
- removed support for Symfony 3 and 4
- removed annotations

## 2.0.0 - 2019-12-25

Expand Down
2 changes: 1 addition & 1 deletion EcnFeatureToggleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Ecn\FeatureToggleBundle;

use Ecn\FeatureToggleBundle\DependencyInjection\Compiler\VoterCompilerPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author Pierre Groth <pierre@elbcoast.net>
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

In order to install ECNFeatureToggleBundle, you need at least

- PHP 7.2 or greater
- Symfony 3.4, Symfony 4.2 or greater
- PHP 8.0 or greater
- Symfony 5.4 or greater

## Installation

Expand All @@ -21,6 +21,11 @@ In order to install ECNFeatureToggleBundle, you need at least
$ composer require ecn/featuretoggle-bundle
```

Functionality of twig is only optional. Require it to your composer if you need it to use it.
```bash
$ composer require twig/twig
```


### Step 2: Activate the bundle

Expand Down Expand Up @@ -105,12 +110,12 @@ if ($this->get('feature')->has('MyNewFeature')) {

## Voters

In order to decide if a feature is available or not, voters are being used. Currently there are five voters included.
In order to decide if a feature is available or not, voters are being used. Currently, there are five voters included.


### AlwaysTrueVoter

This is the default voter and it will always pass. So if you have a feature defined, it will always be displayed.
This is the default voter, and it will always pass. So if you have a feature defined, it will always be displayed.

The full configuration for using this voter looks like this:

Expand Down Expand Up @@ -143,7 +148,7 @@ This voter passes on a given ratio between 0 and 1, which makes it suitable for
The higher the ratio, the more likely the voter will pass. A value of 1 will make it pass every time, 0 will make it
never pass.

Additionally, the result of the first check can be bound to the users session. This is useful if you need a feature
Additionally, the result of the first check can be bound to the users' session. This is useful if you need a feature
to be persistent across multiple requests. To enable this, just set `sticky` to `true`.

If you want to use this voter, this is the full configuration:
Expand Down
51 changes: 34 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,56 @@
}
],
"require": {
"php": "^7.2",
"symfony/framework-bundle": "~3.4.31|~4.2.7|^4.3.4",
"doctrine/annotations": "~1.6",
"doctrine/common": "2.10.0"
"php": "^8.1",
"symfony/framework-bundle": "^5.4 || ^6.0",
"doctrine/common": "^3.4.3"
},
"require-dev": {
"phpunit/phpunit": "^8.2|^7.5",
"squizlabs/php_codesniffer": "^3.3",
"escapestudios/symfony2-coding-standard": "^3.4.1",
"vimeo/psalm": "~3.4"
"phpunit/phpunit": "^10.1.3",
"squizlabs/php_codesniffer": "^3.7.2",
"escapestudios/symfony2-coding-standard": "^3.13.0",
"vimeo/psalm": "^5.12.0",
"jetbrains/phpstorm-attributes": "^1.0",
"friendsofphp/php-cs-fixer": "^3.17.0",
"rector/rector": "^0.16.0",
"roave/security-advisories": "dev-master",
"twig/twig": "3.6.0"
},
"conflict": {
"phpunit/phpunit": "<5.4.3"
"phpunit/phpunit": "<9.0"
},
"suggest": {
"twig/twig": "^3.6.0"
},
"autoload": {
"psr-4": {
"Ecn\\FeatureToggleBundle\\": ""
},
"exclude-from-classmap": [
"Tests/"
]
"Ecn\\FeatureToggleBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Ecn\\FeatureToggleBundle\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-no-twig": "vendor/bin/phpunit --testsuite without_twig",
"psalm": "vendor/bin/psalm",
"psalm-no-twig": "vendor/bin/psalm --config=psalm.without_twig.xml",
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover build/coverage.xml"
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover build/coverage.xml",
"rector": "vendor/bin/rector process --dry-run",
"cs-fixer-src": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.src.php --verbose --diff --allow-risky=yes --dry-run",
"cs-fixer-tests": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.tests.php --verbose --diff --allow-risky=yes --dry-run"
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "2.1-dev"
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
}
}
}
2 changes: 1 addition & 1 deletion Resources/config/services.xml → config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<defaults public="false" />
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<ruleset name="EcnFeatureToggleBundle">
<description>PSR2 Coding Standard on EcnFeatureToggleBundle</description>
<description>Modified PSR12 Coding Standard on EcnFeatureToggleBundle</description>

<file>./</file>
<exclude-pattern>*/Tests/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<arg name="report" value="full"/>
<arg value="np"/>
Expand Down
48 changes: 25 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php" colors="true">

<testsuites>
<testsuite name="all">
<directory>./Tests</directory>
</testsuite>
<testsuite name="without_twig">
<directory>./Tests</directory>
<exclude>./Tests/Twig</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheResult="false"
>
<coverage/>
<testsuites>
<testsuite name="all">
<directory>./tests</directory>
</testsuite>
<testsuite name="without_twig">
<directory>./tests</directory>
<exclude>./tests/Twig</exclude>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./config</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</source>
</phpunit>
10 changes: 5 additions & 5 deletions psalm.without_twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<psalm
name="EcnFeatureToggleBundle"
useDocblockTypes="true"
totallyTyped="false"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="./" />
<directory name="./src" />
<ignoreFiles>
<directory name="Tests" />
<directory name="tests" />
<directory name="vendor" />
<directory name="Twig" />
<directory name="./src/Twig" />
</ignoreFiles>
</projectFiles>

Expand All @@ -23,7 +24,6 @@
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
Expand Down
8 changes: 4 additions & 4 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<psalm
name="EcnFeatureToggleBundle"
useDocblockTypes="true"
totallyTyped="false"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="./" />
<directory name="./src" />
<ignoreFiles>
<directory name="Tests" />
<directory name="tests" />
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
Expand All @@ -22,7 +23,6 @@
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
Expand Down
Loading