Test Setup Failed
Push — master ( 6d6991...a81a2e )
by Gabriel
02:14
created

HasElementsTraitTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 15
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAddElement() 0 12 1
1
<?php
2
3
namespace Nip\Form\Tests\Traits;
4
5
use Nip\Form\Form;
6
use Nip\Form\Tests\AbstractTest;
7
8
/**
9
 * Class HasElementsTraitTrait
10
 * @package Nip\Form\Tests\Traits
11
 */
12
class HasElementsTraitTrait extends AbstractTest
13
{
14
    public function testAddElement()
15
    {
16
        $form = new Form();
17
        $element = $form->getNewElement('hidden')
18
        ->setName('fieldOne');
19
20
        self::assertCount(0, $form->getElements());
0 ignored issues
show
Documentation introduced by
$form->getElements() is of type array<integer,object<Nip...ments\AbstractElement>>, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
22
        $form->addElement($element);
23
24
        self::assertCount(1, $form->getElements());
0 ignored issues
show
Documentation introduced by
$form->getElements() is of type array<integer,object<Nip...ments\AbstractElement>>, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25
    }
26
}
27