diff --git a/.circleci/config.yml b/.circleci/config.yml index c4feb48379..eac7fa38be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -313,7 +313,7 @@ jobs: lint: docker: - - image: cimg/php:8.1.27-node + - image: cimg/php:8.3-node steps: - checkout - run: diff --git a/README.md b/README.md index c20e8dfee5..3e04bcceba 100644 --- a/README.md +++ b/README.md @@ -243,15 +243,17 @@ PHPCodesniffer and the parallel linting tools should be installed automatically The following composer scripts are aliases for running these tools. * Check for code style errors across all project files. Must have zero errors: - `./bin/composer phpcs-errors`: -* Check for code style errors and warnings across all project files. - `./bin/composer phpcs-strict` +`./bin/composer phpcs-errors` +* Check for code style errors and warnings across all project file +`./bin/composer phpcs-strict` * Check for code style errors in current branch. Must have zero errors: `./bin/composer phpcs-changes` * Check for code style errors and warnings in current branch. `./bin/composer phpcs-changes-strict` * Check for PHP lint errors `./bin/composer php-lint` +* Check for PHP 8.3 compatibility + `./bin/composer php-compatibility` ## Checking code with PHPStan diff --git a/composer.json b/composer.json index b62da6a19f..c180dcc0f8 100644 --- a/composer.json +++ b/composer.json @@ -170,8 +170,10 @@ "drupal/coder": "^8.3", "mglaman/phpstan-drupal": "*", "php-parallel-lint/php-parallel-lint": "^1.4", + "phpcompatibility/php-compatibility": "^9.3", "phpstan/phpstan": "*", - "phpstan/phpstan-deprecation-rules": "*" + "phpstan/phpstan-deprecation-rules": "*", + "rector/rector": "^2.0" }, "scripts": { "changed-files": [ @@ -194,6 +196,9 @@ ], "phpstan": [ "vendor/bin/phpstan --memory-limit=1G" + ], + "php-compatibility": [ + "vendor/bin/phpcs -pn --runtime-set testVersion 8.3- web/modules/custom web/themes/custom -d memory_limit=2G --standard=.phpcs.xml.dist" ] } } diff --git a/composer.lock b/composer.lock index 3059fc325a..fd4fb724d9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "890b214b364740bcff34f40f82c6b50b", + "content-hash": "8f5ea57e015cebf68b6fb36a9d214f05", "packages": [ { "name": "asm89/stack-cors", @@ -8222,16 +8222,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "2.3.3", + "version": "2.3.5", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "91a4b42e41976a0b2f839720c3e20a12a84f6852" + "reference": "d836f2d7308a192441ccd1546545890b378af913" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/91a4b42e41976a0b2f839720c3e20a12a84f6852", - "reference": "91a4b42e41976a0b2f839720c3e20a12a84f6852", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/d836f2d7308a192441ccd1546545890b378af913", + "reference": "d836f2d7308a192441ccd1546545890b378af913", "shasum": "" }, "require": { @@ -8320,9 +8320,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.3.3" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.3.5" }, - "time": "2024-11-22T06:11:37+00:00" + "time": "2024-12-27T05:17:46+00:00" }, { "name": "phpowermove/docblock", @@ -12268,6 +12268,68 @@ }, "time": "2024-03-27T12:14:49+00:00" }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "1.33.0", @@ -12420,6 +12482,65 @@ }, "time": "2024-11-28T21:56:36+00:00" }, + { + "name": "rector/rector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "df5de7b80deced1ea7f719a0b4d02e4aee87dd21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/df5de7b80deced1ea7f719a0b4d02e4aee87dd21", + "reference": "df5de7b80deced1ea7f719a0b4d02e4aee87dd21", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.0.4" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-12-26T23:06:19+00:00" + }, { "name": "sirbrillig/phpcs-variable-analysis", "version": "v2.11.22", diff --git a/rector.php b/rector.php new file mode 100644 index 0000000000..6158933cfd --- /dev/null +++ b/rector.php @@ -0,0 +1,18 @@ +paths([ + __DIR__ . '/web/modules/custom/', + __DIR__ . '/web/themes/custom/', + ]); + + // Other configurations, such as rule sets + $rectorConfig->sets([ + SetList::PHP_83, + ]); +}; diff --git a/web/modules/custom/usa_orphaned_entities/src/Form/OrphanedEntitiesSettings.php b/web/modules/custom/usa_orphaned_entities/src/Form/OrphanedEntitiesSettings.php index b65e7cb2d2..8d46775316 100644 --- a/web/modules/custom/usa_orphaned_entities/src/Form/OrphanedEntitiesSettings.php +++ b/web/modules/custom/usa_orphaned_entities/src/Form/OrphanedEntitiesSettings.php @@ -36,6 +36,7 @@ public function getFormId(): string { /** * {@inheritdoc} */ + #[\Override] public function buildForm(array $form, FormStateInterface $form_state): array { $form['#attached']['library'][] = 'usa_orphaned_entities/orphaned'; $form = parent::buildForm($form, $form_state); @@ -94,6 +95,7 @@ public function buildForm(array $form, FormStateInterface $form_state): array { /** * {@inheritdoc} */ + #[\Override] public function validateForm(array &$form, FormStateInterface $form_state) { // foreach ($form['#entity_reference'] as $index => $entity_reference) { @@ -113,6 +115,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function submitForm(array &$form, FormStateInterface $form_state): void { $config = $this->config('orphaned_entities.settings'); foreach ($form['#entity_reference'] as $index => $entity_reference) { diff --git a/web/modules/custom/usa_twig_vars/src/TaxonomyDatalayerBuilder.php b/web/modules/custom/usa_twig_vars/src/TaxonomyDatalayerBuilder.php index 264cb50d86..135edacd6a 100644 --- a/web/modules/custom/usa_twig_vars/src/TaxonomyDatalayerBuilder.php +++ b/web/modules/custom/usa_twig_vars/src/TaxonomyDatalayerBuilder.php @@ -18,17 +18,17 @@ class TaxonomyDatalayerBuilder { public const HOME_TITLE_ES = "Página principal"; public const HOME_URL_ES = "/es/"; - private const ABOUT_GOVT_EN = "About the U.S. and its government"; - private const ABOUT_URL_EN = "/about-the-us"; + private const string ABOUT_GOVT_EN = "About the U.S. and its government"; + private const string ABOUT_URL_EN = "/about-the-us"; - private const ABOUT_GOVT_ES = "Acerca de EE. UU. y su Gobierno"; - private const ABOUT_URL_ES = "/es/acerca-de-estados-unidos"; + private const string ABOUT_GOVT_ES = "Acerca de EE. UU. y su Gobierno"; + private const string ABOUT_URL_ES = "/es/acerca-de-estados-unidos"; - private const AGENCY_INDEX_URL_EN = '/agency-index'; - private const AGENCY_INDEX_URL_ES = '/es/indice-agencias'; + private const string AGENCY_INDEX_URL_EN = '/agency-index'; + private const string AGENCY_INDEX_URL_ES = '/es/indice-agencias'; - private const STATE_INDEX_URL_EN = '/state-governments'; - private const STATE_INDEX_URL_ES = '/es/gobiernos-estatales'; + private const string STATE_INDEX_URL_EN = '/state-governments'; + private const string STATE_INDEX_URL_ES = '/es/gobiernos-estatales'; /** * Language code for entity. diff --git a/web/modules/custom/usagov_benefit_finder/src/Form/BenefitFinderSettingsForm.php b/web/modules/custom/usagov_benefit_finder/src/Form/BenefitFinderSettingsForm.php index 14280934ec..3bd4af1852 100644 --- a/web/modules/custom/usagov_benefit_finder/src/Form/BenefitFinderSettingsForm.php +++ b/web/modules/custom/usagov_benefit_finder/src/Form/BenefitFinderSettingsForm.php @@ -17,6 +17,7 @@ public function getFormId() { /** * {@inheritdoc} */ + #[\Override] public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); @@ -35,6 +36,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('usagov_benefit_finder.settings') ->set('automate_json_data_file_generating', $form_state->getValue('automate_json_data_file_generating')) diff --git a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddAcronymsForm.php b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddAcronymsForm.php index c74827dec5..dad38164ff 100644 --- a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddAcronymsForm.php +++ b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddAcronymsForm.php @@ -59,6 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function validateForm(array &$form, FormStateInterface $form_state) { $all_files = $this->getRequest()->files->get('files', []); $file = $all_files['acronym_file']; diff --git a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddSynonymsForm.php b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddSynonymsForm.php index d7c7b260a7..bdd87849c9 100644 --- a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddSynonymsForm.php +++ b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddSynonymsForm.php @@ -59,6 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function validateForm(array &$form, FormStateInterface $form_state) { $all_files = $this->getRequest()->files->get('files', []); $file = $all_files['synonym_file']; diff --git a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddTogglesForm.php b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddTogglesForm.php index f632367ff6..26512c6cdb 100644 --- a/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddTogglesForm.php +++ b/web/modules/custom/usagov_directories/src/Form/DirectoryRecordsAddTogglesForm.php @@ -60,6 +60,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function validateForm(array &$form, FormStateInterface $form_state) { $all_files = $this->getRequest()->files->get('files', []); $file = $all_files['toggle_map_file']; diff --git a/web/modules/custom/usagov_login/src/Form/LoginSettingsForm.php b/web/modules/custom/usagov_login/src/Form/LoginSettingsForm.php index dc4e6a2636..64405c054e 100755 --- a/web/modules/custom/usagov_login/src/Form/LoginSettingsForm.php +++ b/web/modules/custom/usagov_login/src/Form/LoginSettingsForm.php @@ -36,6 +36,7 @@ public function __construct(ConfigFactoryInterface $config_factory, StateInterfa /** * {@inheritdoc} */ + #[\Override] public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), @@ -60,6 +61,7 @@ protected function getEditableConfigNames() { /** * {@inheritdoc} */ + #[\Override] public function buildForm(array $form, FormStateInterface $form_state) { $form['sso_login_path'] = [ '#type' => 'textfield', @@ -89,6 +91,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ + #[\Override] public function submitForm(array &$form, FormStateInterface $form_state) { $this->state->set('usagov_login_local_form', $form_state->getValue('display_local')); diff --git a/web/modules/custom/usagov_menus/src/Plugin/Block/SidebarFirstBlock.php b/web/modules/custom/usagov_menus/src/Plugin/Block/SidebarFirstBlock.php index 1670ca7d5a..e6e8037fac 100644 --- a/web/modules/custom/usagov_menus/src/Plugin/Block/SidebarFirstBlock.php +++ b/web/modules/custom/usagov_menus/src/Plugin/Block/SidebarFirstBlock.php @@ -31,10 +31,10 @@ )] class SidebarFirstBlock extends AbstractMenuBlock { - private const AGENCIES_NID_EN = 629; - private const AGENCIES_NID_ES = 1696; - private const STATES_NID_EN = 1885; - private const STATES_NID_ES = 1870; + private const int AGENCIES_NID_EN = 629; + private const int AGENCIES_NID_ES = 1696; + private const int STATES_NID_EN = 1885; + private const int STATES_NID_ES = 1870; /** * {@inheritdoc}