From 1e9114f6f0796edc17ceeb35f3a550d1e7c1a701 Mon Sep 17 00:00:00 2001 From: Anvit Srivastav Date: Wed, 9 Oct 2024 17:46:21 -0700 Subject: [PATCH] Update PHP CS Fixer rules Add exceptions for some of the new rules in PHP CS Fixer 3.64.0 --- .php-cs-fixer.dist.php | 19 ++++++++ .../informationobject/templates/_actions.php | 4 +- lib/QubitFlatfileImport.class.php | 2 +- lib/QubitXmlImport.class.php | 4 +- lib/model/QubitJob.php | 2 +- lib/task/migrate/QubitMigrate104.class.php | 2 +- .../migrations/arMigration0109.class.php | 44 +++++++++---------- .../accession/templates/indexSuccess.php | 2 +- .../informationobject/templates/_actions.php | 4 +- .../accession/templates/indexSuccess.php | 2 +- plugins/sfSkosPlugin/test/unit/importTest.php | 2 +- .../lib/sfThumbnail.class.php | 4 +- .../lib/sfWebBrowser.class.php | 2 +- test/functional/qubit/advancedSearchTest.php | 42 +++++++++--------- 14 files changed, 77 insertions(+), 58 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index cca061142e..7311622c46 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,6 +5,7 @@ $finder = PhpCsFixer\Finder::create() ->exclude('.coverage') ->exclude('cache') + ->notPath('docker/') ->notPath('#/model/om/#') ->notPath('#/model/map/#') ->in(__DIR__) @@ -20,9 +21,27 @@ // which includes ensure_fully_multiline, causes // inconsistencies in templates. return (new PhpCsFixer\Config()) + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRules([ '@PhpCsFixer' => true, 'method_argument_space' => ['on_multiline' => 'ignore'], + 'fully_qualified_strict_types' => false, + 'statement_indentation' => false, + 'single_line_empty_body' => false, + 'string_implicit_backslashes' => false, + 'no_extra_blank_lines' => ['tokens' => ['extra']], + 'single_line_comment_spacing' => false, + 'no_multiple_statements_per_line' => false, + 'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield']], + 'multiline_whitespace_before_semicolons' => false, + 'single_space_around_construct' => false, + 'phpdoc_separation' => false, + 'phpdoc_align' => false, + 'phpdoc_trim' => false, + 'no_superfluous_phpdoc_tags' => false, + 'nullable_type_declaration_for_default_null_value' => false, + 'no_useless_concat_operator' => false, + 'blank_line_before_statement' => false, ]) ->setFinder($finder) ; diff --git a/apps/qubit/modules/informationobject/templates/_actions.php b/apps/qubit/modules/informationobject/templates/_actions.php index 62dcea1a94..befe2d4c26 100644 --- a/apps/qubit/modules/informationobject/templates/_actions.php +++ b/apps/qubit/modules/informationobject/templates/_actions.php @@ -63,9 +63,9 @@
  • -
  • 'slug/default', 'module' => 'right', 'action' => 'edit']); ?>
  • +
  • 'slug/default', 'module' => 'right', 'action' => 'edit']); ?>
  • hasChildren()) { ?> -
  • 'slug/default', 'module' => 'right', 'action' => 'manage']); ?>
  • +
  • 'slug/default', 'module' => 'right', 'action' => 'manage']); ?>
  • diff --git a/lib/QubitFlatfileImport.class.php b/lib/QubitFlatfileImport.class.php index 13388828f2..dbdd0f7166 100644 --- a/lib/QubitFlatfileImport.class.php +++ b/lib/QubitFlatfileImport.class.php @@ -2149,7 +2149,7 @@ private function getExistingNotes($objectId, $typeId, $culture) AND n.type_id=? AND i.culture=?'; - $statement = self::sqlQuery($query, [$objectId, $typeId, $culture]); + $statement = self::sqlQuery($query, [$objectId, $typeId, $culture]); foreach ($statement->fetchAll(PDO::FETCH_OBJ) as $row) { $existingNotes[] = $row->content; diff --git a/lib/QubitXmlImport.class.php b/lib/QubitXmlImport.class.php index 099ee6adee..e89ce5ba53 100644 --- a/lib/QubitXmlImport.class.php +++ b/lib/QubitXmlImport.class.php @@ -1115,9 +1115,9 @@ private function handlePreSaveLogic($resource) * * @param QubitInformationObject $io The information object to check * + * @return bool The information object passes the limit option or not * @throws sfException When the limit option is not accepted * - * @return bool The information object passes the limit option or not */ private function passesLimitOptionForIo($io) { @@ -1148,9 +1148,9 @@ private function passesLimitOptionForIo($io) * * @param QubitActor $actor The actor object to check * + * @return bool The actor passes the limit option or not * @throws sfException When the limit option is not accepted * - * @return bool The actor passes the limit option or not */ private function passesLimitOptionForActor($actor) { diff --git a/lib/model/QubitJob.php b/lib/model/QubitJob.php index f6e1e14f38..15e89941df 100644 --- a/lib/model/QubitJob.php +++ b/lib/model/QubitJob.php @@ -203,9 +203,9 @@ public function getNotes() /** * Generate a unique token property to associate unauthenticated users with jobs. * + * @return QubitProperty generated user token property * @throws sfException if a unique token can't be generated * - * @return QubitProperty generated user token property */ public function generateUserTokenProperty() { diff --git a/lib/task/migrate/QubitMigrate104.class.php b/lib/task/migrate/QubitMigrate104.class.php index f93573a85f..4ccc1cbb0c 100644 --- a/lib/task/migrate/QubitMigrate104.class.php +++ b/lib/task/migrate/QubitMigrate104.class.php @@ -232,7 +232,7 @@ protected function alterQubitMenus() 'parent_id' => 'QubitMenu_mainmenu', 'source_culture' => 'en', 'name' => 'admin', - 'label' => ['de' => 'Administrator', 'en' => 'admin', 'es' => 'administrador', 'fa' => 'مدير', 'fr' => 'administrer', 'it' => 'amministra', 'sl' => 'administrator'], + 'label' => ['de' => 'Administrator', 'en' => 'admin', 'es' => 'administrador', 'fa' => 'مدير', 'fr' => 'administrer', 'it' => 'amministra', 'sl' => 'administrator'], 'path' => 'user/list', ]; $this->data['QubitMenu']['QubitMenu_mainmenu_addedit_informationobject'] = [ diff --git a/lib/task/migrate/migrations/arMigration0109.class.php b/lib/task/migrate/migrations/arMigration0109.class.php index b70e93be1e..693aeaa429 100644 --- a/lib/task/migrate/migrations/arMigration0109.class.php +++ b/lib/task/migrate/migrations/arMigration0109.class.php @@ -60,29 +60,29 @@ public function up($configuration) // Add the "Thematic Areas" terms foreach ( [ - ['en' => 'Aboriginal Peoples', 'fr' => 'Peuples autochtones'], - ['en' => 'Agriculture', 'fr' => 'Agriculture'], - ['en' => 'Arts and Culture', 'fr' => 'Arts et culture'], - ['en' => 'Communication', 'fr' => 'Communication'], - ['en' => 'Education', 'fr' => 'Éducation'], - ['en' => 'Environment', 'fr' => 'Environnement'], - ['en' => 'Family / Domestic Life', 'fr' => 'Vie privée'], - ['en' => 'Genealogical', 'fr' => 'Généalogique'], - ['en' => 'Geography', 'fr' => 'Géographie'], + ['en' => 'Aboriginal Peoples', 'fr' => 'Peuples autochtones'], + ['en' => 'Agriculture', 'fr' => 'Agriculture'], + ['en' => 'Arts and Culture', 'fr' => 'Arts et culture'], + ['en' => 'Communication', 'fr' => 'Communication'], + ['en' => 'Education', 'fr' => 'Éducation'], + ['en' => 'Environment', 'fr' => 'Environnement'], + ['en' => 'Family / Domestic Life', 'fr' => 'Vie privée'], + ['en' => 'Genealogical', 'fr' => 'Généalogique'], + ['en' => 'Geography', 'fr' => 'Géographie'], ['en' => 'Industry, Manufacturing and Commerce', 'fr' => 'Industries, fabrication, et commerce'], - ['en' => 'Labour', 'fr' => 'Travail'], - ['en' => 'Law and Justice', 'fr' => 'Droit et justice'], - ['en' => 'Medicine and Health', 'fr' => 'Médecine et santé'], - ['en' => 'Military', 'fr' => 'Forces armées'], - ['en' => 'Natural Resources', 'fr' => 'Richesses naturelles'], - ['en' => 'Politics and Government', 'fr' => 'Politique et gouvernement'], - ['en' => 'Populations', 'fr' => 'Populations'], - ['en' => 'Recreation / Leisure / Sports', 'fr' => 'Loisirs et sports'], - ['en' => 'Religion', 'fr' => 'Religion'], - ['en' => 'Science and Technology', 'fr' => 'Sciences et technologie'], - ['en' => 'Social Organizations and Activities', 'fr' => 'Vie sociale'], - ['en' => 'Transportation', 'fr' => 'Transport'], - ['en' => 'Travel and Exploration', 'fr' => 'Voyages et exploration'], + ['en' => 'Labour', 'fr' => 'Travail'], + ['en' => 'Law and Justice', 'fr' => 'Droit et justice'], + ['en' => 'Medicine and Health', 'fr' => 'Médecine et santé'], + ['en' => 'Military', 'fr' => 'Forces armées'], + ['en' => 'Natural Resources', 'fr' => 'Richesses naturelles'], + ['en' => 'Politics and Government', 'fr' => 'Politique et gouvernement'], + ['en' => 'Populations', 'fr' => 'Populations'], + ['en' => 'Recreation / Leisure / Sports', 'fr' => 'Loisirs et sports'], + ['en' => 'Religion', 'fr' => 'Religion'], + ['en' => 'Science and Technology', 'fr' => 'Sciences et technologie'], + ['en' => 'Social Organizations and Activities', 'fr' => 'Vie sociale'], + ['en' => 'Transportation', 'fr' => 'Transport'], + ['en' => 'Travel and Exploration', 'fr' => 'Voyages et exploration'], ] as $termNames ) { diff --git a/plugins/arDominionB5Plugin/modules/accession/templates/indexSuccess.php b/plugins/arDominionB5Plugin/modules/accession/templates/indexSuccess.php index 7556887b40..058f19ddd9 100644 --- a/plugins/arDominionB5Plugin/modules/accession/templates/indexSuccess.php +++ b/plugins/arDominionB5Plugin/modules/accession/templates/indexSuccess.php @@ -237,7 +237,7 @@ diff --git a/plugins/arDominionB5Plugin/modules/informationobject/templates/_actions.php b/plugins/arDominionB5Plugin/modules/informationobject/templates/_actions.php index 9c01a34cdb..429fd05157 100644 --- a/plugins/arDominionB5Plugin/modules/informationobject/templates/_actions.php +++ b/plugins/arDominionB5Plugin/modules/informationobject/templates/_actions.php @@ -62,9 +62,9 @@
  • -
  • 'slug/default', 'module' => 'right', 'action' => 'edit'], ['class' => 'dropdown-item']); ?>
  • +
  • 'slug/default', 'module' => 'right', 'action' => 'edit'], ['class' => 'dropdown-item']); ?>
  • hasChildren()) { ?> -
  • 'slug/default', 'module' => 'right', 'action' => 'manage'], ['class' => 'dropdown-item']); ?>
  • +
  • 'slug/default', 'module' => 'right', 'action' => 'manage'], ['class' => 'dropdown-item']); ?>
  • diff --git a/plugins/qtAccessionPlugin/modules/accession/templates/indexSuccess.php b/plugins/qtAccessionPlugin/modules/accession/templates/indexSuccess.php index 8d6cd5ff79..e298682442 100644 --- a/plugins/qtAccessionPlugin/modules/accession/templates/indexSuccess.php +++ b/plugins/qtAccessionPlugin/modules/accession/templates/indexSuccess.php @@ -221,7 +221,7 @@ diff --git a/plugins/sfSkosPlugin/test/unit/importTest.php b/plugins/sfSkosPlugin/test/unit/importTest.php index d99a97886d..5f53660911 100644 --- a/plugins/sfSkosPlugin/test/unit/importTest.php +++ b/plugins/sfSkosPlugin/test/unit/importTest.php @@ -1024,5 +1024,5 @@ function getPrivateMethod($object, $name) $result = $methodGetRootConcepts->invoke($importer); - $t->is(count($result), $totalConcepts, "Number of concepts found in ${item[name]} equals to {$totalConcepts}"); + $t->is(count($result), $totalConcepts, "Number of concepts found in {$item[name]} equals to {$totalConcepts}"); } diff --git a/plugins/sfThumbnailPlugin/lib/sfThumbnail.class.php b/plugins/sfThumbnailPlugin/lib/sfThumbnail.class.php index 20be0f9adf..3b927676ce 100644 --- a/plugins/sfThumbnailPlugin/lib/sfThumbnail.class.php +++ b/plugins/sfThumbnailPlugin/lib/sfThumbnail.class.php @@ -74,9 +74,9 @@ public function __destruct() * @param string filename (with absolute path) of the image to load. If the filename is a http(s) URL, then an attempt to download the file will be made. * @param mixed $image * + * @return bool True if the image was properly loaded * @throws Exception If the image cannot be loaded, or if its mime type is not supported * - * @return bool True if the image was properly loaded */ public function loadFile($image) { @@ -122,9 +122,9 @@ public function loadFile($image) * @param mixed $image * @param mixed $mime * + * @return bool True if the image was properly loaded * @throws Exception If image mime type is not supported * - * @return bool True if the image was properly loaded */ public function loadData($image, $mime) { diff --git a/plugins/sfWebBrowserPlugin/lib/sfWebBrowser.class.php b/plugins/sfWebBrowserPlugin/lib/sfWebBrowser.class.php index bad50d1c0f..27411e051d 100644 --- a/plugins/sfWebBrowserPlugin/lib/sfWebBrowser.class.php +++ b/plugins/sfWebBrowserPlugin/lib/sfWebBrowser.class.php @@ -617,9 +617,9 @@ public function getResponseDomCssSelector() /** * Get a SimpleXML version of the response. * + * @return SimpleXMLElement The reponse contents * @throws sfWebBrowserInvalidResponseException when response is not in a valid format * - * @return SimpleXMLElement The reponse contents */ public function getResponseXML() { diff --git a/test/functional/qubit/advancedSearchTest.php b/test/functional/qubit/advancedSearchTest.php index 8935f45ed8..6d2205413b 100644 --- a/test/functional/qubit/advancedSearchTest.php +++ b/test/functional/qubit/advancedSearchTest.php @@ -18,29 +18,29 @@ // Information objects // Properties: title, startDate, endDate, shoudlMatchSearch, filter $cases = [ - ['Foobar1-'.$rand, '0500-02-03', '1100-04-04', false, ['t1', 't2']], // Case 1 - ['Foobar2-'.$rand, '1125-08-02', '1229-11-17', true, ['t1', 't2']], // Case 2 - ['Foobar3-'.$rand, '1712-01-02', '1992-04-22', false, ['t1', 't2']], // Case 3 - ['Foobar4-'.$rand, '0500-02-03', '1125-08-02', true, ['t1', 't2']], // Case 4 - ['Foobar5-'.$rand, '0500-02-03', '1992-04-22', true, ['t1', 't2']], // Case 5 - ['Foobar6-'.$rand, '1229-11-17', '1992-04-22', true, ['t1', 't2']], // Case 6 - ['Foobar7-'.$rand, '0500-02-03', '1100-04-04', false, ['t1']], // Case 7 - ['Foobar8-'.$rand, '0500-02-03', '1125-08-02', true, ['t1']], // Case 8 - ['Foobar9-'.$rand, '1125-08-02', '1229-11-17', true, ['t1']], // Case 9 + ['Foobar1-'.$rand, '0500-02-03', '1100-04-04', false, ['t1', 't2']], // Case 1 + ['Foobar2-'.$rand, '1125-08-02', '1229-11-17', true, ['t1', 't2']], // Case 2 + ['Foobar3-'.$rand, '1712-01-02', '1992-04-22', false, ['t1', 't2']], // Case 3 + ['Foobar4-'.$rand, '0500-02-03', '1125-08-02', true, ['t1', 't2']], // Case 4 + ['Foobar5-'.$rand, '0500-02-03', '1992-04-22', true, ['t1', 't2']], // Case 5 + ['Foobar6-'.$rand, '1229-11-17', '1992-04-22', true, ['t1', 't2']], // Case 6 + ['Foobar7-'.$rand, '0500-02-03', '1100-04-04', false, ['t1']], // Case 7 + ['Foobar8-'.$rand, '0500-02-03', '1125-08-02', true, ['t1']], // Case 8 + ['Foobar9-'.$rand, '1125-08-02', '1229-11-17', true, ['t1']], // Case 9 ['Foobar10-'.$rand, '1125-08-02', '1229-11-17', true, ['t2']], // Case 10 - ['Foobar11-'.$rand, '1229-11-17', '1992-04-22', true, ['t2']], // Case 11 + ['Foobar11-'.$rand, '1229-11-17', '1992-04-22', true, ['t2']], // Case 11 ['Foobar12-'.$rand, '1712-01-02', '1992-04-22', false, ['t2']], // Case 12 - ['Foobar13-'.$rand, '2015-00-00', '2020-00-00', true, ['t3', 't4']], // Case 13 - ['Foobar14-'.$rand, '2010-01-01', '2010-12-31', false, ['t3', 't4']], // Case 14 - ['Foobar15-'.$rand, '2010-01-01', '2015-02-28', true, ['t3', 't4']], // Case 15 - ['Foobar16-'.$rand, '2015-03-03', '2020-00-00', true, ['t3', 't4']], // Case 16 - ['Foobar17-'.$rand, '2020-00-00', '2025-00-00', false, ['t3', 't4']], // Case 17 - ['Foobar18-'.$rand, '2010-01-01', '2015-02-26', false, ['t3']], // Case 18 - ['Foobar19-'.$rand, '2020-00-00', '2025-00-00', true, ['t3']], // Case 19 - ['Foobar20-'.$rand, '2010-01-01', '2020-00-00', true, ['t3']], // Case 20 - ['Foobar21-'.$rand, '2015-03-03', '2020-00-00', true, ['t4']], // Case 21 - ['Foobar22-'.$rand, '2020-00-00', '2025-00-00', false, ['t4']], // Case 22 - ['Foobar23-'.$rand, '2010-01-01', '2010-12-31', true, ['t4']], // Case 23 + ['Foobar13-'.$rand, '2015-00-00', '2020-00-00', true, ['t3', 't4']], // Case 13 + ['Foobar14-'.$rand, '2010-01-01', '2010-12-31', false, ['t3', 't4']], // Case 14 + ['Foobar15-'.$rand, '2010-01-01', '2015-02-28', true, ['t3', 't4']], // Case 15 + ['Foobar16-'.$rand, '2015-03-03', '2020-00-00', true, ['t3', 't4']], // Case 16 + ['Foobar17-'.$rand, '2020-00-00', '2025-00-00', false, ['t3', 't4']], // Case 17 + ['Foobar18-'.$rand, '2010-01-01', '2015-02-26', false, ['t3']], // Case 18 + ['Foobar19-'.$rand, '2020-00-00', '2025-00-00', true, ['t3']], // Case 19 + ['Foobar20-'.$rand, '2010-01-01', '2020-00-00', true, ['t3']], // Case 20 + ['Foobar21-'.$rand, '2015-03-03', '2020-00-00', true, ['t4']], // Case 21 + ['Foobar22-'.$rand, '2020-00-00', '2025-00-00', false, ['t4']], // Case 22 + ['Foobar23-'.$rand, '2010-01-01', '2010-12-31', true, ['t4']], // Case 23 ]; // Create information objects