| Conditions | 1 |
| Paths | 1 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function testAccessors() |
||
| 31 | { |
||
| 32 | $trait = $this->buildMock(); |
||
| 33 | |||
| 34 | $trait->setClass('foo') |
||
|
|
|||
| 35 | ->setId('bar'); |
||
| 36 | $this->assertEquals('foo', $this->reflectionCall($trait, 'getClass')); |
||
| 37 | $this->assertEquals('bar', $this->reflectionCall($trait, 'getId')); |
||
| 38 | |||
| 39 | $trait->setClass('') |
||
| 40 | ->setId(''); |
||
| 41 | $this->assertEquals( |
||
| 42 | '', |
||
| 43 | $this->reflectionCall($trait, 'getClass', ['__foo']) |
||
| 44 | ); |
||
| 45 | $this->assertEquals( |
||
| 46 | '', |
||
| 47 | $this->reflectionCall($trait, 'getId', ['__bar']) |
||
| 48 | ); |
||
| 49 | |||
| 50 | $trait->setClass('foo') |
||
| 51 | ->setId('bar'); |
||
| 52 | $this->assertEquals( |
||
| 53 | 'foo__foo', |
||
| 54 | $this->reflectionCall($trait, 'getClass', ['__foo']) |
||
| 55 | ); |
||
| 56 | $this->assertEquals( |
||
| 57 | 'bar__bar', |
||
| 58 | $this->reflectionCall($trait, 'getId', ['__bar']) |
||
| 59 | ); |
||
| 60 | } |
||
| 61 | } |
||
| 62 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: