From 64096b14d0e4004b2dd44b8e5e94d1763c4cb481 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Wed, 18 Dec 2024 19:15:18 +0100 Subject: [PATCH] adjust license (#206) --- .github/workflows/ecs-fix.yml | 44 +++ .github/workflows/ecs.yml | 117 ------- .gitignore | 5 +- CONTRIBUTING.md | 61 ---- LICENSE.md | 18 +- README.md | 4 +- UPGRADE.md | 4 + composer.json | 13 +- ecs.php | 285 ++++++++---------- phpstan.neon | 3 +- src/Controller/AuthController.php | 6 +- src/Controller/ResettingController.php | 2 +- src/CoreExtension/GroupMultiselect.php | 2 +- src/Document/Builder/BrickBuilder.php | 8 +- src/Manager/ClassManager.php | 9 +- src/Manager/RestrictionManager.php | 11 +- src/Manager/SsoIdentityManager.php | 15 +- src/Restriction/Dao.php | 14 +- .../OAuthIdentityAuthenticator.php | 4 +- ...questPropertiesForUserExtractorService.php | 4 +- src/Service/ResourceMappingService.php | 4 - src/Service/SsoIdentityStatusService.php | 5 +- src/Twig/Extension/OAuthExtension.php | 4 - .../PimcoreUniqueEntityValidator.php | 4 - 24 files changed, 231 insertions(+), 415 deletions(-) create mode 100644 .github/workflows/ecs-fix.yml delete mode 100644 .github/workflows/ecs.yml delete mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/ecs-fix.yml b/.github/workflows/ecs-fix.yml new file mode 100644 index 00000000..feb83833 --- /dev/null +++ b/.github/workflows/ecs-fix.yml @@ -0,0 +1,44 @@ +name: Coding standard refactor +on: + schedule: + - cron: '0 0 * * SUN' + workflow_dispatch: ~ + +jobs: + ecs-fix: + runs-on: ubuntu-latest + timeout-minutes: 5 + strategy: + fail-fast: false + matrix: + branch: [ 'master' ] + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + + - name: Composer install + run: composer install --no-interaction --no-scripts + + - name: Run ECS + run: | + vendor/bin/ecs check src --fix --config ecs.php + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + commit-message: '[CS] Refactor' + author: DACHCOM Bot + title: '[CS] Refactor' + body: | + This PR has been generated automatically to fix code-styles + labels: | + Enhancement + branch: coding-standard/refactor-${{ matrix.branch }} + delete-branch: true + base: ${{ matrix.branch }} \ No newline at end of file diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml deleted file mode 100644 index bdcf0931..00000000 --- a/.github/workflows/ecs.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Easy Coding Standards -on: - push: - branches: [ 'master' ] - pull_request: - branches: [ 'master' ] - -jobs: - ecs: - runs-on: ubuntu-latest - env: - TEST_BUNDLE_NAME: "MembersBundle" - TEST_BUNDLE_INSTALLER_CLASS: "MembersBundle\\Tool\\Install" - TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" - TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" - - PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "3.0" - - APP_ENV: test - PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" - PIMCORE_TEST_URL: "http://localhost" - - SYMFONY_DEPRECATIONS_HELPER: "weak" - PIMCORE_PHP_ERROR_REPORTING: 32767 - - WEBDRIVER_HOST: localhost - WEBDRIVER_URL: "http://localhost:8080/" - - services: - mysql: - image: mysql:8.0 - env: - MYSQL_ROOT_PASSWORD: root - ports: - - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - strategy: - matrix: - php: [ 8.3 ] - symfony: [ ^6.4 ] - pimcore: [ ~11.4.0 ] - include: - - pimcore: ~11.4.0 - template_tag: 2024.3 - steps: - - uses: actions/checkout@v4 - with: - path: lib/test-bundle - - - name: Generate Application Structure - run: | - git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git - mv skeleton/composer.json . - mv skeleton/bin . - mv skeleton/config . - mv skeleton/public . - mv skeleton/src . - mv skeleton/templates . - mv skeleton/var . - rm -r skeleton - - - name: Setup Pimcore Codeception Framework - env: - MATRIX_PIMCORE_VERSION: ${{ matrix.pimcore }} - MATRIX_PIMCORE_TEMPLATE_TAG: ${{ matrix.template_tag }} - run: | - git clone -b ${{ env.PIMCORE_CODECEPTION_VERSION }} --single-branch --depth 1 https://github.com/dachcom-digital/pimcore-codeception-framework.git - ls -al pimcore-codeception-framework - chmod +x ./pimcore-codeception-framework/src/_etc/scripts/setup.sh - ./pimcore-codeception-framework/src/_etc/scripts/setup.sh - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: intl - coverage: none - - - name: Check PHP Version - run: php -v - - - name: Setup MySql - run: | - sudo systemctl start mysql - mysql -uroot -proot -h127.0.0.1 -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;" - - - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache Composer Downloads - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Composer install - env: - TEST_PIMCORE_VERSION: ${{ matrix.pimcore }} - TEST_SYMFONY_VERSION: ${{ matrix.symfony }} - run: | - chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh - ./pimcore-codeception-framework/src/_etc/scripts/composer.sh - - - name: Assets Install - run: | - bin/console assets:install public --relative --symlink - - - name: Easy Coding Standard Check - continue-on-error: true - run: | - bin/console cache:warmup --env=test - vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src/ --config ${{ github.workspace }}/lib/test-bundle/ecs.php diff --git a/.gitignore b/.gitignore index d4770f35..54434b90 100644 --- a/.gitignore +++ b/.gitignore @@ -40,10 +40,9 @@ atlassian-ide-plugin.xml .project ehthumbs.db Thumbs.db -Vagrantfile -.vagrant php-cgi.core -.sass-cache +/vendor/ +/composer.lock # codeception (only stage *.dist.yaml config files) /codeception.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 609a06b3..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,61 +0,0 @@ -# Contributing to a Members - -## Bug Reports & Feature Requests -The Members team heavily uses (and loves!) GitHub for all of our software management. -We use GitHub issues exclusively to track all bugs and features. - -* [Open an issue](https://github.com/dachcom-digital/pimcore-members/issues) here on GitHub. -If you can, **please provide a fix and create a pull request (PR) instead**; this will automatically create an issue for you. -* Report security issues **only** to support@dachcom.ch -* Please be patient as not all items will be tested immediately - remember, Members is open source and free of charge. -* Occasionally we'll close issues if they appear stale or are too vague - please don't take this personally! -Please feel free to re-open issues we've closed if there's something we've missed and they still need to be addressed. - -## Contributing Pull Requests -PR's are even better than issues. -We gladly accept community pull requests. -There are a few necessary steps before we can accept a pull request: - -* [Open an issue](https://github.com/dachcom-digital/pimcore-members/issues) describing the problem that you are looking to solve in -your PR (if one is not already open), and your approach to solving it (no necessary for bug fixes - only feature contributions). -* [Fork us!](https://help.github.com/articles/fork-a-repo/) Code! Follow the coding standards PSR-1, PSR-2 and PSR-4. -* [Send a pull request](https://help.github.com/articles/using-pull-requests/) from your fork’s branch to our `master` branch. - -### Contributor License Agreement -The following terms are used throughout this agreement: - -* **You** - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any -entity that controls or is controlled by the legal entity, or is under common control with it. - -* **Project** - is an umbrella term that refers to any and all Members projects. - -* **Contribution** - any type of work that is submitted to a Project, including any modifications or additions to -existing work. - -* **Submitted** - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or -verbal communication with Members, contributors or maintainers. - -#### 1. Grant of Copyright License. -Subject to the terms and conditions of this agreement, You grant to the Projects’ maintainers, contributors, users and -to Members a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, -prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your contributions and such -derivative works. Except for this license, You reserve all rights, title, and interest in your contributions. - -#### 2. Grant of Patent License. -Subject to the terms and conditions of this agreement, You grant to the Projects’ maintainers, contributors, users and -to dachcom-digital/members a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your contributions, where -such license applies only to those patent claims licensable by you that are necessarily infringed by your contribution -or by combination of your contribution with the project to which this contribution was submitted. - -If any entity institutes patent litigation - including cross-claim or counterclaim in a lawsuit - against You alleging -that your contribution or any project it was submitted to constitutes or is responsible for direct or contributory -patent infringement, then any patent licenses granted to that entity under this agreement shall terminate as of the -date such litigation is filed. - -#### 3. Source of Contribution. -Your contribution is either your original creation, based upon previous work that, to the best of your knowledge, is -covered under an appropriate open source license and you have the right under that license to submit that work with -modifications, whether created in whole or in part by you, or you have clearly identified the source of the contribution -and any license or other restriction (like related patents, trademarks, and license agreements) of which you are -personally aware. diff --git a/LICENSE.md b/LICENSE.md index fc7f1a71..4c17059e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,9 +1,13 @@ # License -Copyright (C) 2023 DACHCOM.DIGITAL +Copyright (C) DACHCOM.DIGITAL -This software is available under the GNU General Public License version 3 (GPLv3). +This software is available under two different licenses: +* GNU General Public License version 3 (GPLv3) as Pimcore Community Edition +* DACHCOM Commercial License (DCL) -### GNU General Public License version 3 (GPLv3) +The default Members Bundle license, without a valid DACHCOM Commercial License agreement, is the Open-Source GPLv3 license. + +## GNU General Public License version 3 (GPLv3) If you decide to choose the GPLv3 license, you must comply with the following terms: This program is free software: you can redistribute it and/or modify @@ -13,10 +17,14 @@ the Free Software Foundation, either version 3 of the License, or This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -[GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.en.html) \ No newline at end of file +## DACHCOM Commercial License (DCL) +Alternatively, commercial and supported versions of the program - also known as +Commercial Distributions - must be used in accordance with the terms and conditions +contained in a separate written agreement between you and DACHCOM.DIGITAL AG. +For more information about the Members Bundle Commercial License (DCL) please contact dcdi@dachcom.ch. \ No newline at end of file diff --git a/README.md b/README.md index c95a8145..f04bf8ad 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Pimcore Members Bundle Add frontend user authentication and document restriction to pimcore. -[![Join the chat at https://gitter.im/pimcore/pimcore](https://img.shields.io/gitter/room/pimcore/pimcore.svg?style=flat-square)](https://gitter.im/pimcore/pimcore) [![Software License](https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat-square)](LICENSE.md) +[![Software License](https://img.shields.io/badge/license-DCL-white.svg?style=flat-square&color=%23ff5c5c)](LICENSE.md) [![Latest Release](https://img.shields.io/packagist/v/dachcom-digital/members.svg?style=flat-square)](https://packagist.org/packages/dachcom-digital/members) [![Tests](https://img.shields.io/github/actions/workflow/status/dachcom-digital/pimcore-members/.github/workflows/codeception.yml?branch=master&style=flat-square&logo=github&label=codeception)](https://github.com/dachcom-digital/pimcore-members/actions?query=workflow%3ACodeception+branch%3Amaster) [![PhpStan](https://img.shields.io/github/actions/workflow/status/dachcom-digital/pimcore-members/.github/workflows/php-stan.yml?branch=master&style=flat-square&logo=github&label=phpstan%20level%204)](https://github.com/dachcom-digital/pimcore-members/actions?query=workflow%3A"PHP+Stan"+branch%3Amaster) @@ -32,7 +32,7 @@ Please read the installation instructions before going deep with Members! ```json "require" : { - "dachcom-digital/members" : "~5.0.0" + "dachcom-digital/members" : "~5.1.0" } ``` diff --git a/UPGRADE.md b/UPGRADE.md index e9481117..582001fe 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,4 +1,8 @@ # Upgrade Notes + +## 5.1.0 +- [LICENSE] Dual-License with GPL and Dachcom Commercial License (DCL) added + ### 5.0.3 - **[BUGFIX]**: Do not initialize `memberStorageId` in UserManager::constructor to prevent early db connection diff --git a/composer.json b/composer.json index a654949d..ee0ece7f 100755 --- a/composer.json +++ b/composer.json @@ -1,7 +1,10 @@ { "name": "dachcom-digital/members", "type": "pimcore-bundle", - "license": "GPL-3.0-or-later", + "license": [ + "GPL-3.0-or-later", + "proprietary" + ], "description": "Pimcore User, Object, Asset and Document Authentication", "keywords": ["pimcore", "members", "authentication"], "homepage": "https://github.com/dachcom-digital/pimcore-members", @@ -33,15 +36,15 @@ "require": { "pimcore/pimcore": "^11.0", "doctrine/orm": "^2.7", - "symfony/form": "^6.2" + "symfony/form": "^6.4" }, "require-dev": { "codeception/codeception": "^5.0", "codeception/module-symfony": "^3.1", "codeception/module-webdriver": "^4.0", - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-symfony": "^1.0", - "symplify/easy-coding-standard": "^9.0" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-symfony": "^2.0", + "symplify/easy-coding-standard": "~12.2.0" }, "suggest": { "knpuniversity/oauth2-client-bundle": "^2.0" diff --git a/ecs.php b/ecs.php index b5e05a8e..169156ba 100644 --- a/ecs.php +++ b/ecs.php @@ -1,162 +1,133 @@ parameters(); - $parameters->set(Option::SETS, [SetList::CLEAN_CODE, SetList::PSR_12]); - - $services = $containerConfigurator->services(); - - $services->set(Fixer\Basic\BracesFixer::class) - ->call('configure', [ - [ - 'allow_single_line_closure' => true, - ] - ]); - - $services->set(Fixer\PhpTag\BlankLineAfterOpeningTagFixer::class); - - $services->set(Fixer\Operator\ConcatSpaceFixer::class) - ->call('configure', [ - [ - 'spacing' => 'one', - ] - ]); - - $services->set(Fixer\Operator\NewWithBracesFixer::class); - - $services->set(Fixer\Phpdoc\PhpdocAlignFixer::class) - ->call('configure', [ - [ - 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], - ] - ]); - - $services->set(Fixer\Operator\BinaryOperatorSpacesFixer::class) - ->call('configure', [ - [ - 'operators' => [ - '=' => 'single_space', - '=>' => 'align', - ] - ] - ]); - $services->set(Fixer\Operator\IncrementStyleFixer::class) - ->call('configure', [ - [ - 'style' => 'post', - ] - ]); - - $services->set(Fixer\Operator\UnaryOperatorSpacesFixer::class); - $services->set(Fixer\Whitespace\BlankLineBeforeStatementFixer::class); - $services->set(Fixer\CastNotation\CastSpacesFixer::class); - $services->set(Fixer\LanguageConstruct\DeclareEqualNormalizeFixer::class); - $services->set(Fixer\FunctionNotation\FunctionTypehintSpaceFixer::class); - $services->set(Fixer\Comment\SingleLineCommentStyleFixer::class) - ->call('configure', [ - [ - 'comment_types' => ['hash'], - ] - ]); - - $services->set(Fixer\ControlStructure\IncludeFixer::class); - $services->set(Fixer\CastNotation\LowercaseCastFixer::class); - $services->set(Fixer\ClassNotation\ClassAttributesSeparationFixer::class) - ->call('configure', [ - [ - 'elements' => [ - 'const' => 'none', - 'method' => 'one', - 'property' => 'none', - 'trait_import' => 'none' - ], - ] - ]); - - $services->set(Fixer\Casing\NativeFunctionCasingFixer::class); - $services->set(Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class); - $services->set(Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer::class); - $services->set(Fixer\Comment\NoEmptyCommentFixer::class); - $services->set(Fixer\Phpdoc\NoEmptyPhpdocFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSeparationFixer::class); - $services->set(Fixer\Semicolon\NoEmptyStatementFixer::class); - $services->set(Fixer\Whitespace\ArrayIndentationFixer::class); - $services->set(Fixer\Whitespace\NoExtraBlankLinesFixer::class) - ->call('configure', [ - [ - 'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'], - ] - ]); - - $services->set(Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer::class); - $services->set(Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer::class); - $services->set(Fixer\CastNotation\NoShortBoolCastFixer::class); - $services->set(Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer::class); - $services->set(Fixer\Whitespace\NoSpacesAroundOffsetFixer::class); - $services->set(Fixer\ControlStructure\NoTrailingCommaInListCallFixer::class); - $services->set(Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class); - $services->set(Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class); - $services->set(Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class); - $services->set(Fixer\ArrayNotation\NormalizeIndexBraceFixer::class); - $services->set(Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer::class); - $services->set(Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer::class); - $services->set(Fixer\Phpdoc\PhpdocIndentFixer::class); - $services->set(Fixer\Phpdoc\PhpdocInlineTagFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoAccessFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoPackageFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer::class); - $services->set(Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer::class); - $services->set(Fixer\Phpdoc\PhpdocScalarFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSummaryFixer::class); - $services->set(Fixer\Phpdoc\PhpdocToCommentFixer::class); - $services->set(Fixer\Phpdoc\PhpdocTrimFixer::class); - $services->set(Fixer\Phpdoc\PhpdocTypesFixer::class); - $services->set(Fixer\Phpdoc\PhpdocVarWithoutNameFixer::class); - $services->set(Fixer\FunctionNotation\ReturnTypeDeclarationFixer::class); - $services->set(Fixer\ClassNotation\SelfAccessorFixer::class); - $services->set(Fixer\CastNotation\ShortScalarCastFixer::class); - $services->set(Fixer\StringNotation\SingleQuoteFixer::class); - $services->set(Fixer\Semicolon\SpaceAfterSemicolonFixer::class); - $services->set(Fixer\Operator\StandardizeNotEqualsFixer::class); - $services->set(Fixer\Operator\TernaryOperatorSpacesFixer::class); - $services->set(Fixer\ArrayNotation\TrimArraySpacesFixer::class); - $services->set(Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer::class); - - $services->set(Fixer\ClassNotation\ClassDefinitionFixer::class) - ->call('configure', [ - [ - 'single_line' => true, - ] - ]); - - $services->set(Fixer\Casing\MagicConstantCasingFixer::class); - $services->set(Fixer\FunctionNotation\MethodArgumentSpaceFixer::class); - $services->set(Fixer\Alias\NoMixedEchoPrintFixer::class) - ->call('configure', [ - [ - 'use' => 'echo', - ] - ]); - - $services->set(Fixer\Import\NoLeadingImportSlashFixer::class); - $services->set(Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoAliasTagFixer::class); - $services->set(Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer::class); - $services->set(Fixer\ClassNotation\SingleClassElementPerStatementFixer::class); - - # new since PHP-CS-Fixer 2.6 - $services->set(Fixer\ClassNotation\NoUnneededFinalMethodFixer::class); - $services->set(Fixer\Semicolon\SemicolonAfterInstructionFixer::class); - - # new since 2.11 - $services->set(Fixer\Operator\StandardizeIncrementFixer::class); -}; \ No newline at end of file +$header = <<
withSets([SetList::CLEAN_CODE, SetList::PSR_12]) + ->withConfiguredRule(Fixer\Comment\HeaderCommentFixer::class, [ + 'header' => $header, + 'comment_type' => 'comment' + ]) + ->withConfiguredRule(Fixer\Basic\BracesFixer::class, [ + 'allow_single_line_closure' => true, + ]) + ->withConfiguredRule(Fixer\Operator\ConcatSpaceFixer::class, [ + 'spacing' => 'one', + ]) + ->withConfiguredRule(Fixer\Phpdoc\PhpdocAlignFixer::class, [ + 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], + ]) + ->withConfiguredRule(Fixer\Operator\BinaryOperatorSpacesFixer::class, [ + 'operators' => [ + '=' => 'single_space', + '=>' => 'align', + ] + ]) + ->withConfiguredRule(Fixer\Operator\IncrementStyleFixer::class, [ + 'style' => 'post', + ]) + ->withConfiguredRule(Fixer\ClassNotation\ClassAttributesSeparationFixer::class, [ + 'elements' => [ + 'const' => 'none', + 'method' => 'one', + 'property' => 'none', + 'trait_import' => 'none' + ], + ]) + ->withConfiguredRule(Fixer\ClassNotation\ClassDefinitionFixer::class, [ + 'single_line' => true, + ]) + ->withConfiguredRule(Fixer\Comment\SingleLineCommentStyleFixer::class, [ + 'comment_types' => ['hash'], + ]) + ->withConfiguredRule(Fixer\Alias\NoMixedEchoPrintFixer::class, [ + 'use' => 'echo', + ]) + ->withConfiguredRule(Fixer\Basic\NoTrailingCommaInSinglelineFixer::class, [ + 'elements' => ['array_destructuring'] + ]) + ->withConfiguredRule(Fixer\NamespaceNotation\BlankLinesBeforeNamespaceFixer::class, [ + 'min_line_breaks' => 2, + 'max_line_breaks' => 2 + ]) + ->withConfiguredRule(Fixer\Whitespace\TypeDeclarationSpacesFixer::class, [ + 'elements' => ['function'] + ]) + ->withConfiguredRule(Fixer\Whitespace\NoExtraBlankLinesFixer::class, [ + 'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'], + ]) + ->withRules([ + Fixer\PhpTag\BlankLineAfterOpeningTagFixer::class, + Fixer\Operator\NewWithParenthesesFixer::class, + Fixer\Operator\UnaryOperatorSpacesFixer::class, + Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer::class, + Fixer\Operator\StandardizeNotEqualsFixer::class, + Fixer\Operator\TernaryOperatorSpacesFixer::class, + Fixer\Operator\StandardizeIncrementFixer::class, + Fixer\Whitespace\BlankLineBeforeStatementFixer::class, + Fixer\Whitespace\ArrayIndentationFixer::class, + Fixer\Whitespace\NoSpacesAroundOffsetFixer::class, + Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class, + Fixer\CastNotation\CastSpacesFixer::class, + Fixer\CastNotation\LowercaseCastFixer::class, + Fixer\CastNotation\NoShortBoolCastFixer::class, + Fixer\CastNotation\ShortScalarCastFixer::class, + Fixer\LanguageConstruct\DeclareEqualNormalizeFixer::class, + Fixer\ControlStructure\IncludeFixer::class, + Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class, + Fixer\Casing\NativeFunctionCasingFixer::class, + Fixer\Casing\MagicConstantCasingFixer::class, + Fixer\Comment\NoEmptyCommentFixer::class, + Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer::class, + Fixer\Semicolon\NoEmptyStatementFixer::class, + Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer::class, + Fixer\Semicolon\SpaceAfterSemicolonFixer::class, + Fixer\Semicolon\SemicolonAfterInstructionFixer::class, + Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class, + Fixer\ArrayNotation\NormalizeIndexBraceFixer::class, + Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer::class, + Fixer\ArrayNotation\TrimArraySpacesFixer::class, + Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer::class, + Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer::class, + Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer::class, + Fixer\Phpdoc\PhpdocIndentFixer::class, + Fixer\Phpdoc\PhpdocInlineTagNormalizerFixer::class, + Fixer\Phpdoc\PhpdocNoAccessFixer::class, + Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class, + Fixer\Phpdoc\PhpdocNoPackageFixer::class, + Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer::class, + Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer::class, + Fixer\Phpdoc\PhpdocScalarFixer::class, + Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer::class, + Fixer\Phpdoc\PhpdocSummaryFixer::class, + Fixer\Phpdoc\PhpdocToCommentFixer::class, + Fixer\Phpdoc\PhpdocTrimFixer::class, + Fixer\Phpdoc\PhpdocTypesFixer::class, + Fixer\Phpdoc\NoEmptyPhpdocFixer::class, + Fixer\Phpdoc\PhpdocSeparationFixer::class, + Fixer\Phpdoc\PhpdocVarWithoutNameFixer::class, + Fixer\Phpdoc\PhpdocNoAliasTagFixer::class, + Fixer\FunctionNotation\ReturnTypeDeclarationFixer::class, + Fixer\FunctionNotation\MethodArgumentSpaceFixer::class, + Fixer\StringNotation\SingleQuoteFixer::class, + Fixer\Import\NoUnusedImportsFixer::class, + Fixer\Import\NoLeadingImportSlashFixer::class, + Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer::class, + Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class, + Fixer\ClassNotation\SelfAccessorFixer::class, + Fixer\ClassNotation\SingleClassElementPerStatementFixer::class, + Fixer\ClassNotation\NoUnneededFinalMethodFixer::class + ]); \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon index ee2d647e..136ce1f7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,7 +5,8 @@ parameters: - %currentWorkingDirectory%/vendor/pimcore/pimcore/stubs/dynamic-constants.php reportUnmatchedIgnoredErrors: false symfony: - container_xml_path: %currentWorkingDirectory%/var/cache/test/TestKernelTestDebugContainer.xml + containerXmlPath: %currentWorkingDirectory%/var/cache/test/TestKernelTestDebugContainer.xml + constantHassers: false excludePaths: # only works if optional bundles are available: - src/Adapter/User/AbstractCustomerUser.php diff --git a/src/Controller/AuthController.php b/src/Controller/AuthController.php index 382c2cd8..36115783 100644 --- a/src/Controller/AuthController.php +++ b/src/Controller/AuthController.php @@ -6,7 +6,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Bundle\SecurityBundle\Security; +use Symfony\Component\Security\Http\SecurityRequestAttributes; class AuthController extends AbstractController { @@ -16,8 +16,8 @@ public function __construct(protected FactoryInterface $formFactory) public function loginAction(Request $request): Response { - $authErrorKey = Security::AUTHENTICATION_ERROR; - $lastUsernameKey = Security::LAST_USERNAME; + $authErrorKey = SecurityRequestAttributes::AUTHENTICATION_ERROR; + $lastUsernameKey = SecurityRequestAttributes::LAST_USERNAME; $session = $request->getSession(); diff --git a/src/Controller/ResettingController.php b/src/Controller/ResettingController.php index 9161b57b..3d43831e 100644 --- a/src/Controller/ResettingController.php +++ b/src/Controller/ResettingController.php @@ -44,7 +44,7 @@ public function sendEmailAction(Request $request): Response { $username = $request->request->get('username'); - /** @var UserInterface $user */ + /** @var UserInterface|null $user */ $user = $this->userManager->findUserByUsernameOrEmail($username); /* Dispatch init event */ diff --git a/src/CoreExtension/GroupMultiselect.php b/src/CoreExtension/GroupMultiselect.php index d276c6c9..5781f5b2 100644 --- a/src/CoreExtension/GroupMultiselect.php +++ b/src/CoreExtension/GroupMultiselect.php @@ -252,7 +252,7 @@ protected function prepareDataForPersistence(array|Element\ElementInterface $dat return $return; } - if (is_array($data) && count($data) === 0) { + if (is_array($data)) { //give empty array if data was not null return []; } diff --git a/src/Document/Builder/BrickBuilder.php b/src/Document/Builder/BrickBuilder.php index 1a87dad0..8c7e9ca3 100644 --- a/src/Document/Builder/BrickBuilder.php +++ b/src/Document/Builder/BrickBuilder.php @@ -9,7 +9,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Bundle\SecurityBundle\Security; +use Symfony\Component\Security\Http\SecurityRequestAttributes; use Twig\Environment; class BrickBuilder @@ -122,13 +122,13 @@ public function getViewParams(): array //only show backend note $template = $this->getTemplate('area-not-available'); } elseif (!$this->tokenStorage->getToken()?->getUser() instanceof UserInterface) { - $authErrorKey = Security::AUTHENTICATION_ERROR; - $lastUsernameKey = Security::LAST_USERNAME; + $authErrorKey = SecurityRequestAttributes::AUTHENTICATION_ERROR; + $lastUsernameKey = SecurityRequestAttributes::LAST_USERNAME; // get the error if any (works with forward and redirect -- see below) if ($this->request->attributes->has($authErrorKey)) { $error = $this->request->attributes->get($authErrorKey); - } elseif (null !== $this->request->getSession() && $this->request->getSession()->has($authErrorKey)) { + } elseif ($this->request->getSession()->has($authErrorKey)) { $error = $this->request->getSession()->get($authErrorKey); $this->request->getSession()->remove($authErrorKey); } else { diff --git a/src/Manager/ClassManager.php b/src/Manager/ClassManager.php index ab887aa2..a3ca5e4a 100644 --- a/src/Manager/ClassManager.php +++ b/src/Manager/ClassManager.php @@ -15,10 +15,9 @@ public function __construct(protected Configuration $configuration) public function getGroupListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getGroupClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } @@ -27,10 +26,9 @@ public function getGroupListing(): Listing public function getUserListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getUserClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } @@ -39,10 +37,9 @@ public function getUserListing(): Listing public function getSsoIdentityListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getSsoIdentityClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } diff --git a/src/Manager/RestrictionManager.php b/src/Manager/RestrictionManager.php index 88884aef..e1cdb6f8 100644 --- a/src/Manager/RestrictionManager.php +++ b/src/Manager/RestrictionManager.php @@ -48,12 +48,7 @@ public function getElementRestrictedGroups(ElementInterface $element): array return $groups; } - $groups = []; - if (is_array($restriction->getRelatedGroups())) { - $groups = $restriction->getRelatedGroups(); - } - - return $groups; + return $restriction->getRelatedGroups(); } public function getElementRestrictionStatus(ElementInterface $element): ElementRestriction @@ -88,9 +83,7 @@ public function getElementRestrictionStatus(ElementInterface $element): ElementR return $elementRestriction; } - if (is_array($restriction->getRelatedGroups())) { - $elementRestriction->setRestrictionGroups($restriction->getRelatedGroups()); - } + $elementRestriction->setRestrictionGroups($restriction->getRelatedGroups()); //check if user is not logged in. if (!$user instanceof UserInterface) { diff --git a/src/Manager/SsoIdentityManager.php b/src/Manager/SsoIdentityManager.php index 785adc7d..31dbe5b6 100644 --- a/src/Manager/SsoIdentityManager.php +++ b/src/Manager/SsoIdentityManager.php @@ -86,7 +86,6 @@ public function createSsoIdentity(UserInterface $user, string $provider, string $key = File::getValidFilename(sprintf('%s-%s', $provider, $identifier)); $path = sprintf('%s/%s', $user->getRealFullPath(), $key); - /** @var SsoIdentityInterface $ssoIdentity */ $ssoIdentity = DataObject::getByPath($path); if (!$ssoIdentity instanceof SsoIdentityInterface) { @@ -94,16 +93,15 @@ public function createSsoIdentity(UserInterface $user, string $provider, string $ssoIdentity = new $ssoIdentityClass(); } - if (!$ssoIdentity instanceof DataObject\Concrete) { - throw new \RuntimeException('Sso Identity needs to be an instance of Concrete'); - } - $ssoIdentity->setProvider($provider); $ssoIdentity->setIdentifier($identifier); $ssoIdentity->setProfileData($profileData); - $ssoIdentity->setPublished(true); - $ssoIdentity->setKey($key); - $ssoIdentity->setParent($user); + + if ($ssoIdentity instanceof DataObject\Concrete) { + $ssoIdentity->setPublished(true); + $ssoIdentity->setKey($key); + $ssoIdentity->setParent($user); + } return $ssoIdentity; } @@ -158,7 +156,6 @@ protected function findSsoIdentity(string $provider, string $identifier): ?SsoId protected function findUserBySsoIdentity(SsoIdentityInterface $ssoIdentity): ?UserInterface { - /** @var DataObject\Concrete $userClass */ $userClass = $this->classManager->getUserClass(); $qb = $this->connection->createQueryBuilder(); diff --git a/src/Restriction/Dao.php b/src/Restriction/Dao.php index 5e2dae1f..ea048ecf 100644 --- a/src/Restriction/Dao.php +++ b/src/Restriction/Dao.php @@ -80,20 +80,12 @@ public function save() return true; } - /** - * @param array $data - * - * @return mixed - * @throws Exception - */ - private function addRelationData($data) + private function addRelationData(array $data): array { $relations = $this->db->fetchAllAssociative('SELECT * FROM ' . $this->tableRelationName . ' WHERE restrictionId = ?', [$data['id']]); - if ($relations !== false) { - foreach ($relations as $relation) { - $data['relatedGroups'][] = $relation['groupId']; - } + foreach ($relations as $relation) { + $data['relatedGroups'][] = $relation['groupId']; } return $data; diff --git a/src/Security/Authenticator/OAuthIdentityAuthenticator.php b/src/Security/Authenticator/OAuthIdentityAuthenticator.php index 8db0c615..8e512e0a 100644 --- a/src/Security/Authenticator/OAuthIdentityAuthenticator.php +++ b/src/Security/Authenticator/OAuthIdentityAuthenticator.php @@ -18,11 +18,11 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; -use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Passport; use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; +use Symfony\Component\Security\Http\SecurityRequestAttributes; class OAuthIdentityAuthenticator extends OAuth2Authenticator implements AuthenticationEntrypointInterface { @@ -111,7 +111,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio $parameterLocale = $parameter['locale'] ?? null; $sessionBag->remove('oauth_state_data'); - $session->set(Security::AUTHENTICATION_ERROR, $exception); + $session->set(SecurityRequestAttributes::AUTHENTICATION_ERROR, $exception); if ($parameterLocale !== null) { $request->setLocale($parameterLocale); diff --git a/src/Service/RequestPropertiesForUserExtractorService.php b/src/Service/RequestPropertiesForUserExtractorService.php index e3e5001d..e3fe559e 100644 --- a/src/Service/RequestPropertiesForUserExtractorService.php +++ b/src/Service/RequestPropertiesForUserExtractorService.php @@ -29,11 +29,11 @@ public function extractFromParameterBag(array $parameter): array { $userProperties = []; - if (isset($parameter['locale']) && $parameter['locale'] !== null) { + if (isset($parameter['locale'])) { $userProperties['_user_locale'] = $parameter['locale']; } - if (isset($parameter['site_id']) && $parameter['site_id'] !== null) { + if (isset($parameter['site_id'])) { $site = Site::getById($parameter['site_id']); if ($site instanceof Site) { $userProperties['_site_domain'] = $site->getMainDomain(); diff --git a/src/Service/ResourceMappingService.php b/src/Service/ResourceMappingService.php index a883deb5..2ec92ed9 100644 --- a/src/Service/ResourceMappingService.php +++ b/src/Service/ResourceMappingService.php @@ -64,10 +64,6 @@ public function addDefaults(UserInterface $user, ResourceOwnerInterface $resourc $ownerDetails = $resourceOwner->toArray(); $disallowedProperties = ['lastLogin', 'password', 'confirmationToken', 'passwordRequestedAt', 'groups', 'ssoIdentities']; - if (!is_array($ownerDetails)) { - return; - } - foreach ($ownerDetails as $property => $value) { if (in_array(strtolower($property), $disallowedProperties)) { continue; diff --git a/src/Service/SsoIdentityStatusService.php b/src/Service/SsoIdentityStatusService.php index 22ec37ce..cd9171b2 100644 --- a/src/Service/SsoIdentityStatusService.php +++ b/src/Service/SsoIdentityStatusService.php @@ -55,10 +55,7 @@ protected function determinateDeletionByDefaults(UserInterface $user): bool // don't touch a user if he has other identities $userSsoIdentities = $this->ssoIdentityManager->getSsoIdentities($user); - if (is_array($userSsoIdentities) && count($userSsoIdentities) > 0) { - return false; - } - return true; + return count($userSsoIdentities) <= 0; } } diff --git a/src/Twig/Extension/OAuthExtension.php b/src/Twig/Extension/OAuthExtension.php index 6c409869..3df42855 100644 --- a/src/Twig/Extension/OAuthExtension.php +++ b/src/Twig/Extension/OAuthExtension.php @@ -50,10 +50,6 @@ public function getSocialLinks(string $route = 'members_user_security_oauth_logi $ssoIdentityProviders = $this->getSsoIdentityProvider(); $resourceOwners = $this->oauthRegistry->getEnabledClientKeys(); - if (!is_array($resourceOwners)) { - return []; - } - $data = []; foreach ($resourceOwners as $resourceOwner) { diff --git a/src/Validator/Constraints/PimcoreUniqueEntityValidator.php b/src/Validator/Constraints/PimcoreUniqueEntityValidator.php index 513613d0..11a18fb3 100644 --- a/src/Validator/Constraints/PimcoreUniqueEntityValidator.php +++ b/src/Validator/Constraints/PimcoreUniqueEntityValidator.php @@ -20,10 +20,6 @@ public function validate($entity, Constraint $constraint): void throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\PimcoreUniqueEntity'); } - if (!is_array($constraint->fields)) { - throw new UnexpectedTypeException($constraint->fields, 'array'); - } - $fields = $constraint->fields; if (count($fields) === 0) {