|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Cubiche package. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) Cubiche |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace Cubiche\Core\Visitor\Tests\Units; |
|
11
|
|
|
|
|
12
|
|
|
use Cubiche\Core\Visitor\Tests\Fixtures\Calculator; |
|
13
|
|
|
use Cubiche\Core\Visitor\Tests\Fixtures\Evaluator; |
|
14
|
|
|
use Cubiche\Core\Visitor\Tests\Fixtures\Sum; |
|
15
|
|
|
use Cubiche\Core\Visitor\Tests\Fixtures\Value; |
|
16
|
|
|
use Cubiche\Core\Visitor\Tests\Fixtures\Variable; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Linked Visitor Tests Class. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class LinkedVisitorTests extends LinkedVisitorTestCase |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function visitNextDataProvider() |
|
29
|
|
|
{ |
|
30
|
|
|
return array( |
|
31
|
|
|
array( |
|
32
|
|
|
new Evaluator($calculator = $this->newMockInstance(Calculator::class)), |
|
|
|
|
|
|
33
|
|
|
$calculator, |
|
34
|
|
|
new Sum(new Value(1), new Value(2)), |
|
35
|
|
|
'visitSum', |
|
36
|
|
|
3, |
|
37
|
|
|
), |
|
38
|
|
|
array( |
|
39
|
|
|
new Evaluator($calculator = $this->newMockInstance(Calculator::class), array('x' => 5)), |
|
|
|
|
|
|
40
|
|
|
$calculator, |
|
41
|
|
|
new Sum(new Value(1), new Variable('x')), |
|
42
|
|
|
'visitSum', |
|
43
|
|
|
6, |
|
44
|
|
|
), |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritdoc} |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function visitDataProvider() |
|
52
|
|
|
{ |
|
53
|
|
|
return array( |
|
54
|
|
|
array( |
|
55
|
|
|
$this->newMockInstance(Evaluator::class, null, null, array(new Calculator(), array('x' => 5))), |
|
56
|
|
|
new Variable('x'), |
|
57
|
|
|
'visitVariable', |
|
58
|
|
|
5, |
|
59
|
|
|
), |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function canHandlerVisiteeDataProvider() |
|
67
|
|
|
{ |
|
68
|
|
|
$data = parent::canHandlerVisiteeDataProvider(); |
|
69
|
|
|
|
|
70
|
|
|
return \array_merge($data, array( |
|
|
|
|
|
|
71
|
|
|
array(new Calculator(), new Sum(new Value(1), new Value(2)), true), |
|
72
|
|
|
array(new Calculator(), new Variable('x'), false), |
|
73
|
|
|
array(new Evaluator(new Calculator()), new Sum(new Value(1), new Value(2)), true), |
|
74
|
|
|
array(new Evaluator(new Calculator(), array('x' => 5)), new Sum(new Variable('x'), new Value(2)), true), |
|
75
|
|
|
)); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
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: