Skip to content

[4.3] style: update coding style #6690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2022
Merged

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 14, 2022

Description
See #6678

  • run composer cs-fix.

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added the 4.3 label Oct 14, 2022
@kenjis kenjis changed the title style: update coding style [4.3] style: update coding style Oct 14, 2022
@kenjis kenjis force-pushed the update-coding-style branch from 3c8232d to 4a9946a Compare October 14, 2022 23:54
@kenjis
Copy link
Member Author

kenjis commented Oct 14, 2022

I got the following error, but the fixed code still can be fixed if I run php-cs-fixer again.
Is this a bug?

   1) CodeIgniter4/system/Database/BaseBuilder.php (no_useless_concat_operator, concat_space, statement_indentation, unary_operator_spaces, not_operator_with_successor_space)
      ---------- begin diff ----------
--- /home/runner/work/CodeIgniter4/CodeIgniter4/system/Database/BaseBuilder.php
+++ /home/runner/work/CodeIgniter4/CodeIgniter4/system/Database/BaseBuilder.php
@@ -1938,17 +1938,16 @@
         if ($sql === '') {
             $updateFields = $this->QBOptions['updateFields'] ?? $this->updateFields($keys)->QBOptions['updateFields'] ?? [];
 
-            $sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $keys) . ")\n" . '{:_table_:}'
-                . "ON DUPLICATE KEY UPDATE\n" . implode(
-                    ",\n",
-                    array_map(
-                        static fn ($key, $value) => $table . '.' . $key . ($value instanceof RawSql ?
-                            ' = ' . $value :
-                            ' = VALUES(' . $value . ')'),
-                        array_keys($updateFields),
-                        $updateFields
-                    )
-                );
+            $sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $keys) . ")\n{:_table_:}" . "ON DUPLICATE KEY UPDATE\n" . implode(
+                ",\n",
+                array_map(
+                    static fn ($key, $value) => $table . '.' . $key . ($value instanceof RawSql ?
+                        ' = ' . $value :
+                        ' = VALUES(' . $value . ')'),
+                    array_keys($updateFields),
+                    $updateFields
+                )
+            );
 
             $this->QBOptions['sql'] = $sql;
         }

      ----------- end diff -----------

@kenjis
Copy link
Member Author

kenjis commented Oct 15, 2022

There was 1 failure:

1) CodeIgniter\Database\Live\UpsertTest::testUpsertWithMultipleSet
Failed asserting that a row in the table [user] matches the attributes 
{
    "email": "[email protected]",
    "name": "Jarvis",
    "country": "2022-10-14"
}

Found similar results: [
    {
        "id": "5",
        "name": "Jarvis",
        "email": "[email protected]",
        "country": "2022-10-15",
        "created_at": null,
        "updated_at": null,
        "deleted_at": null
    }
] and 2 others.

/home/runner/work/CodeIgniter4/CodeIgniter4/system/Test/DatabaseTestTrait.php:280
/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Database/Live/UpsertTest.php:641
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

--

@sclubricants
Copy link
Member

I don't think so. Its just rearranging things I think.

I updated CS fixer but its not giving me the results that it does on here.

@kenjis kenjis force-pushed the update-coding-style branch from 4a9946a to 30d23ae Compare October 15, 2022 02:31
@sclubricants
Copy link
Member

Merge!

@sclubricants
Copy link
Member

How can we avoid all these warnings?

Took 1.37s from 0.50s limit to run CodeIgniter\\Models\\SaveModelTest::testSaveNewEntityWithDate

Is there some way to set a time limit on a test?

@kenjis kenjis merged commit a046931 into codeigniter4:4.3 Oct 15, 2022
@kenjis kenjis deleted the update-coding-style branch October 15, 2022 03:52
@kenjis
Copy link
Member Author

kenjis commented Oct 15, 2022

How can we avoid all these warnings?

Make the test faster.

Is there some way to set a time limit on a test?

See https://github.com/NexusPHP/tachycardia/blob/1.x/docs/custom_time_limits.md

@sclubricants
Copy link
Member

I'd rather set a reasonable time limit and have less of these warnings. It would be nice to see warnings that really need to take a look at and not hundreds of nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants