diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ddbdaea --- /dev/null +++ b/.editorconfig @@ -0,0 +1,64 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.feature] +indent_style = space +indent_size = 2 + +[*.js] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[*.php] +indent_style = space +indent_size = 4 + +[*.sh] +indent_style = tab +indent_size = 4 + +[*.xml] +indent_style = space +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[.github/workflows/*.{yaml,yml}] +indent_style = space +indent_size = 2 + +[.php_cs{,.dist}] +indent_style = space +indent_size = 4 + +[composer.json] +indent_style = space +indent_size = 4 + +[phpunit.xml{,.dist}] +indent_style = space +indent_size = 4 diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..c982195 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at vincentchalamon+abuse@gmail.com We will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8cadc09..7f66e19 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,4 @@ + | Q | A | ------------- | --- | Bug fix? | yes/no @@ -7,5 +8,3 @@ | Tests pass? | yes | Fixed tickets | #1234, #5678 | License | MIT - -*Please update this template with something that matches your PR* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6e8fe0..6ba9233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI on: schedule: - - cron: 0 2 * * 1-5 + # Every sunday at 02:00 + - cron: 0 2 * * 0 pull_request: push: branches: @@ -10,59 +11,92 @@ on: jobs: tests: - name: Tests PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} (${{ matrix.dependency }}) + name: Tests PHP ${{ matrix.php }} ${{ matrix.dependency }} (Symfony ${{ matrix.symfony }}) runs-on: ubuntu-latest - container: - image: php:${{ matrix.php }} strategy: - # https://gitpro.ttaallkk.topmunity/t5/GitHub-Actions/GitHub-Actions-Matrix-options-dont-work-as-documented/m-p/29558 matrix: php: - '7.2' - '7.3' - '7.4' + - 'rc' symfony: - '3.4.*' - '4.4.*' - '5.1.*' dependency: - - '--prefer-stable' - - '--prefer-stable --prefer-lowest' + - '' + - 'lowest' + include: + - php: '7.4' + dependency: '' + symfony: '5.1.*' + bootable: true + exclude: + - symfony: '3.4.*' + dependency: 'lowest' + - symfony: '4.4.*' + dependency: 'lowest' fail-fast: false steps: - name: Checkout uses: actions/checkout@v1 - - name: Install system packages - run: | - apt-get update - apt-get install -y --no-install-recommends \ - unzip + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: composer:v2, flex + tools: php-cs-fixer - - name: Disable PHP memory limit - run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Install Composer - run: curl -sS -o - https://raw.githubusercontent.com/composer/getcomposer.org/ba13e3fc70f1c66250d1ea7ea4911d593aa1dba5/web/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- - name: Configure Symfony - run: | - composer global require symfony/flex - composer config extra.symfony.require "${{ matrix.symfony }}" + run: composer config extra.symfony.require "${{ matrix.symfony }}" - name: Update project dependencies - run: composer update --no-progress --no-suggest --ansi ${{ matrix.dependency }} + if: matrix.dependency == '' + run: composer update --no-progress --ansi --prefer-stable + + - name: Update project dependencies lowest + if: matrix.dependency == 'lowest' + run: composer update --no-progress --ansi --prefer-lowest --prefer-stable + + - name: Disable deprecations notices for lowest dependencies + if: matrix.dependency == 'lowest' + run: echo "SYMFONY_DEPRECATIONS_HELPER=weak" >> $GITHUB_ENV + + - name: Bundle is bootable + if: matrix.bootable + env: + SKELETON_VERSION: ${{matrix.symfony}} + run: | + composer create-project "symfony/skeleton:${SKELETON_VERSION}" flex + cd flex + composer config extra.symfony.allow-contrib true + composer req --ignore-platform-reqs tilleuls/migration-bundle + + - name: Run php-cs-fixer tests + if: matrix.php != 'rc' + run: php-cs-fixer fix --diff --dry-run + + - name: Run PHPUnit tests + run: vendor/bin/simple-phpunit - name: Run Behat tests run: | mkdir -p features/app/cache/test/doctrine/orm/Proxies features/app/logs vendor/bin/behat - - name: Run PHPUnit tests - run: vendor/bin/phpunit - - name: Run PHPStan tests + if: matrix.dependency == '' run: vendor/bin/phpstan - - - name: Run php-cs-fixer tests - run: vendor/bin/php-cs-fixer fix --dry-run --diff diff --git a/.php_cs.dist b/.php_cs.dist index 56f8e48..1e9a4b3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -13,7 +13,7 @@ HEADER; $finder = PhpCsFixer\Finder::create() ->in(__DIR__) - ->exclude('features/app'); + ->exclude(['features', 'flex']); return PhpCsFixer\Config::create() ->setRiskyAllowed(true) diff --git a/composer.json b/composer.json index fcfc2aa..5de20e0 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.2", + "php": "^7.2", "doctrine/annotations": "^1.2", "doctrine/dbal": "^2.5", "doctrine/doctrine-bundle": "^1.7.2 || ^2.0", @@ -32,14 +32,14 @@ "require-dev": { "behat/behat": "^3.1", "doctrine/data-fixtures": "^1.2", - "friends-of-behat/symfony-extension": "^2.0.10@beta", - "friendsofphp/php-cs-fixer": "^2.15.5", + "doctrine/doctrine-cache-bundle": "^1.4", + "friends-of-behat/symfony-extension": "^2.1.0", "ocramius/proxy-manager": "^2.0.4", "phpspec/prophecy": "^1.10", "phpstan/phpstan": "^0.12.17", - "phpunit/phpunit": "^8.0", "symfony/browser-kit": "^3.4 || ^4.4 || ^5.0", "symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0", + "symfony/phpunit-bridge": "^5.0", "zendframework/zend-code": "^3.4" }, "autoload": { @@ -49,9 +49,18 @@ }, "autoload-dev": { "psr-4": { - "CoopTilleuls\\MigrationBundle\\Tests\\": "features/app" + "CoopTilleuls\\MigrationBundle\\Tests\\": "features/app", + "PHPUnit\\": "vendor/bin/.phpunit/phpunit-8.3-0/src" } }, + "scripts": { + "post-install-cmd": [ + "vendor/bin/simple-phpunit --version" + ], + "post-update-cmd": [ + "vendor/bin/simple-phpunit --version" + ] + }, "extra": { "branch-alias": { "dev-master": "1.2.x-dev" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4edd18e..21ea004 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,11 @@ - + + + + + + diff --git a/src/DependencyInjection/MigrationCompilerPass.php b/src/DependencyInjection/MigrationCompilerPass.php index b2d6dab..87e1b7f 100644 --- a/src/DependencyInjection/MigrationCompilerPass.php +++ b/src/DependencyInjection/MigrationCompilerPass.php @@ -15,6 +15,7 @@ use CoopTilleuls\MigrationBundle\Loader\AbstractLoader; use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -52,7 +53,8 @@ public function process(ContainerBuilder $container): void } // Generate aliases - $alias = Inflector::tableize(preg_replace('/^(.*)Loader$/i', '$1', $reflection->getShortName())); + $alias = (class_exists(InflectorFactory::class) ? InflectorFactory::create()->build() : new Inflector()) + ->tableize(preg_replace('/^(.*)Loader$/i', '$1', $reflection->getShortName())); $aliases = [$class, $alias, str_replace('_', '-', $alias)]; if (true === $this->allowAlias && isset($attributes[0]['alias'])) { $aliases[] = $attributes[0]['alias']; diff --git a/src/EventListener/TransformerEventListener.php b/src/EventListener/TransformerEventListener.php index ac0d67d..be6b2a3 100644 --- a/src/EventListener/TransformerEventListener.php +++ b/src/EventListener/TransformerEventListener.php @@ -55,9 +55,6 @@ public function preFlush(): void $this->legacyConnection->disable(); } - /** - * @param \Doctrine\Common\Persistence\Event\LifecycleEventArgs|\Doctrine\ORM\Event\LifecycleEventArgs $event - */ public function prePersist($event): void { if ($this->hasTransformer($event->getObject())) { @@ -65,9 +62,6 @@ public function prePersist($event): void } } - /** - * @param \Doctrine\Common\Persistence\Event\LifecycleEventArgs|\Doctrine\ORM\Event\LifecycleEventArgs $event - */ public function preUpdate($event): void { if ($this->hasTransformer($event->getObject())) { @@ -75,9 +69,6 @@ public function preUpdate($event): void } } - /** - * @param \Doctrine\Common\Persistence\Event\LifecycleEventArgs|\Doctrine\ORM\Event\LifecycleEventArgs $event - */ public function preRemove($event): void { if ($this->hasTransformer($event->getObject())) {