Skip to content

Conversation

@paulbalandan
Copy link
Member

Description

$ vendor/bin/php-cs-fixer describe php_unit_data_provider_return_type
Description of php_unit_data_provider_return_type rule.
The return type of PHPUnit data provider must be `iterable`.
Data provider must return `iterable`, either an array of arrays or an object that implements the `Traversable` interface.

Fixer applying this rule is risky.
Risky when relying on signature of the data provider.

Fixing examples:
 * Example #1.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,8 +1,8 @@
    <?php
    class FooTest extends TestCase {
        /**
         * @dataProvider provideSomethingCases
         */
        public function testSomething($expected, $actual) {}
   -    public function provideSomethingCases(): array {}
   +    public function provideSomethingCases(): iterable {}
    }

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

 * Example #2.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,8 +1,8 @@
    <?php
    class FooTest extends TestCase {
        /**
         * @dataProvider provideSomethingCases
         */
        public function testSomething($expected, $actual) {}
   -    public function provideSomethingCases() {}
   +    public function provideSomethingCases(): iterable {}
    }

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

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
Copy link
Member

kenjis commented Jul 18, 2023

"Coding Standards / PHP 7.4 Lint with PHP CS Fixer (pull_request)" fails.

@paulbalandan paulbalandan force-pushed the data-provider-return-type branch from f536986 to ac87a1e Compare July 18, 2023 09:46
@kenjis kenjis merged commit f1f4a53 into codeigniter4:develop Jul 21, 2023
@paulbalandan paulbalandan deleted the data-provider-return-type branch July 21, 2023 00:21
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.

2 participants