From 95484c1769d1d7c7857b5a6f1e7b8517073d2ac0 Mon Sep 17 00:00:00 2001 From: zbpopova9292 <91263908+zbpopova9292@users.noreply.github.com> Date: Tue, 22 Mar 2022 11:04:59 +0200 Subject: [PATCH] Support for php8.0 (#7) * Add support for PHP 8 * Drop support for PHP 7.0 * Temporarily remove `paysera/lib-php-cs-fixer-config` Co-authored-by: Desislava Georgieva --- .php_cs | 141 ------------------ .travis.yml | 7 +- CHANGELOG.md | 19 +++ composer.json | 25 ++-- phpunit.xml.dist | 15 +- src/DependencyInjection/Configuration.php | 7 +- .../PayseraApiExtension.php | 2 +- .../DoctrinePathAttributeResolver.php | 2 +- .../DependencyInjection/Configuration.php | 8 +- .../Functional/FunctionalAnnotationsTest.php | 2 +- ...ctionalCustomPropertyPathConverterTest.php | 2 +- .../FunctionalFindDenormalizersTest.php | 2 +- tests/Functional/FunctionalRestBundleTest.php | 2 +- tests/Functional/FunctionalTestCase.php | 2 +- .../Unit/Normalizer/DenormalizerTestCase.php | 2 +- 15 files changed, 60 insertions(+), 178 deletions(-) delete mode 100644 .php_cs diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 93d0c9d..0000000 --- a/.php_cs +++ /dev/null @@ -1,141 +0,0 @@ -setDefaultFinder(['src', 'tests'], []) - ->setRiskyRules() - ->enableMigrationMode([ - 'encoding' => true, - 'full_opening_tag' => true, - 'blank_line_after_namespace' => true, - 'elseif' => true, - 'function_declaration' => true, - 'indentation_type' => true, - 'line_ending' => true, - 'lowercase_constants' => true, - 'lowercase_keywords' => true, - 'no_break_comment' => true, - 'no_closing_tag' => true, - 'no_spaces_after_function_name' => true, - 'no_spaces_inside_parenthesis' => true, - 'no_trailing_whitespace' => true, - 'no_trailing_whitespace_in_comment' => true, - 'single_blank_line_at_eof' => true, - 'single_import_per_statement' => true, - 'single_line_after_imports' => true, - 'switch_case_semicolon_to_colon' => true, - 'switch_case_space' => true, - 'visibility_required' => true, - 'binary_operator_spaces' => true, - 'class_attributes_separation' => true, - 'class_definition' => true, - 'declare_equal_normalize' => true, - 'function_typehint_space' => true, - 'include' => true, - 'lowercase_cast' => true, - 'magic_constant_casing' => true, - 'method_argument_space' => true, - 'native_function_casing' => true, - 'new_with_braces' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_mixed_echo_print' => true, - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_short_bool_cast' => true, - 'no_spaces_around_offset' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unneeded_curly_braces' => true, - 'no_unneeded_final_method' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'normalize_index_brace' => true, - 'object_operator_without_whitespace' => true, - 'php_unit_fqcn_annotation' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_indent' => true, - 'phpdoc_no_access' => true, - 'phpdoc_no_empty_return' => true, - 'phpdoc_no_package' => true, - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_return_self_reference' => true, - 'phpdoc_scalar' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_trim' => true, - 'phpdoc_types' => true, - 'phpdoc_var_without_name' => true, - 'protected_to_private' => true, - 'return_type_declaration' => true, - 'semicolon_after_instruction' => true, - 'short_scalar_cast' => true, - 'single_blank_line_before_namespace' => true, - 'single_class_element_per_statement' => true, - 'single_line_comment_style' => true, - 'single_quote' => true, - 'space_after_semicolon' => true, - 'standardize_increment' => true, - 'standardize_not_equals' => true, - 'ternary_operator_spaces' => true, - 'trailing_comma_in_multiline_array' => true, - 'trim_array_spaces' => true, - 'unary_operator_spaces' => true, - 'whitespace_after_comma_in_array' => true, - 'increment_style' => true, - 'concat_space' => true, - 'no_extra_blank_lines' => true, - 'Paysera/php_basic_braces' => true, - 'no_useless_else' => true, - 'phpdoc_add_missing_param_annotation' => true, - 'array_syntax' => true, - 'general_phpdoc_annotation_remove' => true, - 'header_comment' => true, - 'heredoc_to_nowdoc' => true, - 'linebreak_after_opening_tag' => true, - 'no_useless_return' => true, - 'strict_comparison' => true, - 'strict_param' => true, - 'ordered_class_elements' => true, - 'Paysera/php_basic_comment_comment_styles' => true, - 'Paysera/php_basic_comment_fluid_interface' => true, - 'Paysera/php_basic_feature_comparing_to_null' => true, - 'Paysera/php_basic_feature_condition_results' => true, - 'Paysera/php_basic_code_style_doc_block_whitespace' => true, - 'dir_constant' => true, - 'ereg_to_preg' => true, - 'function_to_constant' => true, - 'modernize_types_casting' => true, - 'no_alias_functions' => true, - 'no_homoglyph_names' => true, - 'non_printable_character' => true, - 'php_unit_construct' => true, - 'psr4' => true, - 'silenced_deprecation_error' => true, - 'is_null' => true, - 'no_unreachable_default_argument_value' => true, - 'Paysera/php_basic_feature_checking_explicitly' => true, - 'Paysera/psr_1_class_constant_upper_case' => true, - 'Paysera/psr_1_class_name_studly_caps' => true, - 'Paysera/psr_1_function_name_camel_case' => true, - 'Paysera/php_basic_code_style_full_names' => true, - 'Paysera/php_basic_code_style_interface_naming' => true, - 'Paysera/php_basic_code_style_namespaces_and_use_statements' => true, - 'Paysera/php_basic_feature_calling_parent_constructor' => true, - 'Paysera/php_basic_feature_logical_operators' => true, - 'Paysera/php_basic_feature_unnecessary_variables' => true, - 'Paysera/php_basic_feature_comparing_to_boolean' => true, - 'Paysera/php_basic_code_style_default_values_in_constructor' => true, - 'Paysera/php_basic_feature_type_hinting' => true, - - 'Paysera/php_basic_feature_type_hinting_arguments' => false, - 'Paysera/php_basic_code_style_splitting_in_several_lines' => false, - 'Paysera/php_basic_code_style_chained_method_calls' => false, - 'no_whitespace_before_comma_in_array' => false, - ]) -; diff --git a/.travis.yml b/.travis.yml index 66c2236..fc98db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,15 +8,12 @@ env: matrix: include: - - php: "7.0" - php: "7.1" - php: "7.2" - php: "7.3" - php: "7.4" - env: WITH_CS="true" + - php: "8.0" - - php: "7.0" - env: LOWER_CONSTRAINTS="true" - php: "7.1" env: LOWER_CONSTRAINTS="true" - php: "7.2" @@ -26,6 +23,7 @@ matrix: - php: "7.4" env: LOWER_CONSTRAINTS="true" + cache: directories: - $HOME/.composer/cache @@ -40,4 +38,3 @@ before_script: script: - bin/phpunit - - if [[ "$WITH_CS" == "true" ]]; then bin/paysera-php-cs-fixer fix --config=.php_cs -v --dry-run --stop-on-violation --path-mode=intersection "${COMMIT_SCA_FILES[@]}"; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 58b40fe..e8394f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.0] +### Added +- support for PHP 8 +- `doctrine/persistence` added + +### Changed +- `paysera/lib-normalization-bundle` bumped to `^1.1.0` +- `paysera/lib-normalization` bumped to `^1.2.0` +- `paysera/lib-dependency-injection` bumped to `^1.3.0` +- `doctrine/doctrine-bundle` bumped to `^1.4|^2.0` +- `doctrine/orm` bumped to `^2.5.14|^2.6` + +### Removed +- support for PHP 7.0 +- `paysera/lib-php-cs-fixer-config` +- `doctrine/common` + + + ## [1.2.0] ### Changed - `paysera_api.listener.locale` listener priority changed. diff --git a/composer.json b/composer.json index 491faf1..947e3ff 100644 --- a/composer.json +++ b/composer.json @@ -15,34 +15,31 @@ } }, "require": { - "php": ">=7.0", + "php": "^7.1 || ^8.0", "ext-json": "*", "symfony/framework-bundle": "^3.4.34|^4.3", "symfony/security-bundle": "^3.4.34|^4.3", "symfony/validator": "^3.4.34|^4.3", - "doctrine/common": "^2.1", - "paysera/lib-normalization-bundle": "^1.0", - "paysera/lib-normalization": "^1.1", - "paysera/lib-object-wrapper": "^0.1.0|^0.2.0", + "paysera/lib-normalization-bundle": "^1.1.0", + "paysera/lib-normalization": "^1.2.0", + "paysera/lib-object-wrapper": "^0.1.0|^0.2.0|^0.3.0", "paysera/lib-pagination": "^1.0", - "paysera/lib-dependency-injection": "^1.1.0", - "psr/log": "^1.0" + "paysera/lib-dependency-injection": "^1.3.0", + "psr/log": "^1.0", + "doctrine/persistence": "^1.3.8 || ^2.0.1" }, "require-dev": { - "phpunit/phpunit": "^6.5", + "phpunit/phpunit": "^6.5 || ^9.0", "mockery/mockery": "^1.2.4", - "paysera/lib-php-cs-fixer-config": "^2.2.2", "symfony/yaml": "^3.4.34|^4.3", - "doctrine/doctrine-bundle": "^1.4", - "doctrine/orm": "^2.5.14" + "doctrine/doctrine-bundle": "^1.4|^2.0", + "doctrine/orm": "^2.5.14|^2.6" }, "config": { "bin-dir": "bin" }, "scripts": { "phpunit": "phpunit", - "fix-cs": "paysera-php-cs-fixer fix", - "test-cs": "paysera-php-cs-fixer fix --dry-run -v", - "test": ["@phpunit", "@test-cs"] + "test": ["@phpunit"] } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5c83fca..bde7395 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,6 @@ convertWarningsToExceptions = "true" processIsolation = "false" stopOnFailure = "false" - syntaxCheck = "false" bootstrap = "vendor/autoload.php" > @@ -19,9 +18,13 @@ - - - ./src - - + + + ./ + + + ./tests + ./vendor + + diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index acae376..99b4c98 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -12,8 +12,11 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('paysera_api'); + $treeBuilder = new TreeBuilder('paysera_api'); + $rootNode = method_exists($treeBuilder, 'getRootNode') + ? $treeBuilder->getRootNode() + : $treeBuilder->root('paysera_api') + ; $children = $rootNode->children(); $children->arrayNode('locales')->defaultValue([])->prototype('scalar'); diff --git a/src/DependencyInjection/PayseraApiExtension.php b/src/DependencyInjection/PayseraApiExtension.php index 53cbcee..1eee814 100644 --- a/src/DependencyInjection/PayseraApiExtension.php +++ b/src/DependencyInjection/PayseraApiExtension.php @@ -3,7 +3,7 @@ namespace Paysera\Bundle\ApiBundle\DependencyInjection; -use Doctrine\Common\Persistence\ObjectRepository; +use Doctrine\Persistence\ObjectRepository; use Paysera\Bundle\ApiBundle\Service\PathAttributeResolver\DoctrinePathAttributeResolver; use RuntimeException; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Service/PathAttributeResolver/DoctrinePathAttributeResolver.php b/src/Service/PathAttributeResolver/DoctrinePathAttributeResolver.php index 808a609..5081f4b 100644 --- a/src/Service/PathAttributeResolver/DoctrinePathAttributeResolver.php +++ b/src/Service/PathAttributeResolver/DoctrinePathAttributeResolver.php @@ -3,7 +3,7 @@ namespace Paysera\Bundle\ApiBundle\Service\PathAttributeResolver; -use Doctrine\Common\Persistence\ObjectRepository; +use Doctrine\Persistence\ObjectRepository; class DoctrinePathAttributeResolver implements PathAttributeResolverInterface { diff --git a/tests/Functional/Fixtures/FixtureTestBundle/DependencyInjection/Configuration.php b/tests/Functional/Fixtures/FixtureTestBundle/DependencyInjection/Configuration.php index 8f71c95..31ced6a 100644 --- a/tests/Functional/Fixtures/FixtureTestBundle/DependencyInjection/Configuration.php +++ b/tests/Functional/Fixtures/FixtureTestBundle/DependencyInjection/Configuration.php @@ -18,8 +18,12 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $treeBuilder->root('paysera_fixture_test'); + $treeBuilder = new TreeBuilder('paysera_fixture_test'); + + if (!method_exists($treeBuilder, 'getRootNode')) { + $treeBuilder->root('paysera_fixture_test'); + } + return $treeBuilder; } } diff --git a/tests/Functional/FunctionalAnnotationsTest.php b/tests/Functional/FunctionalAnnotationsTest.php index 19c8c06..36fa024 100644 --- a/tests/Functional/FunctionalAnnotationsTest.php +++ b/tests/Functional/FunctionalAnnotationsTest.php @@ -8,7 +8,7 @@ class FunctionalAnnotationsTest extends FunctionalTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpContainer('basic'); diff --git a/tests/Functional/FunctionalCustomPropertyPathConverterTest.php b/tests/Functional/FunctionalCustomPropertyPathConverterTest.php index f2d4abd..6cfd6eb 100644 --- a/tests/Functional/FunctionalCustomPropertyPathConverterTest.php +++ b/tests/Functional/FunctionalCustomPropertyPathConverterTest.php @@ -8,7 +8,7 @@ class FunctionalCustomPropertyPathConverterTest extends FunctionalTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpContainer('custom_converter'); diff --git a/tests/Functional/FunctionalFindDenormalizersTest.php b/tests/Functional/FunctionalFindDenormalizersTest.php index e728cb8..56ed6ec 100644 --- a/tests/Functional/FunctionalFindDenormalizersTest.php +++ b/tests/Functional/FunctionalFindDenormalizersTest.php @@ -8,7 +8,7 @@ class FunctionalFindDenormalizersTest extends FunctionalTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpContainer('basic'); diff --git a/tests/Functional/FunctionalRestBundleTest.php b/tests/Functional/FunctionalRestBundleTest.php index 6bcb3ac..86bfe27 100644 --- a/tests/Functional/FunctionalRestBundleTest.php +++ b/tests/Functional/FunctionalRestBundleTest.php @@ -14,7 +14,7 @@ class FunctionalRestBundleTest extends FunctionalTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpContainer('basic'); diff --git a/tests/Functional/FunctionalTestCase.php b/tests/Functional/FunctionalTestCase.php index d045172..d11436f 100644 --- a/tests/Functional/FunctionalTestCase.php +++ b/tests/Functional/FunctionalTestCase.php @@ -33,7 +33,7 @@ protected function setUpContainer($testCase, $commonFile = 'common.yml') return $this->kernel->getContainer(); } - protected function tearDown() + protected function tearDown(): void { $container = $this->kernel->getContainer(); $this->kernel->shutdown(); diff --git a/tests/Unit/Normalizer/DenormalizerTestCase.php b/tests/Unit/Normalizer/DenormalizerTestCase.php index 82af962..a112d00 100644 --- a/tests/Unit/Normalizer/DenormalizerTestCase.php +++ b/tests/Unit/Normalizer/DenormalizerTestCase.php @@ -17,7 +17,7 @@ class DenormalizerTestCase extends MockeryTestCase */ protected $context; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->context = Mockery::mock(DenormalizationContext::class);