4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\CodeCleaner;
14 use PhpParser\NodeTraverser;
15 use Psy\CodeCleaner\CallTimePassByReferencePass;
17 class CallTimePassByReferencePassTest extends CodeCleanerTestCase
19 public function setUp()
21 $this->pass = new CallTimePassByReferencePass();
22 $this->traverser = new NodeTraverser();
23 $this->traverser->addVisitor($this->pass);
27 * @dataProvider invalidStatements
28 * @expectedException \Psy\Exception\FatalErrorException
30 public function testProcessStatementFails($code)
32 if (version_compare(PHP_VERSION, '5.4', '<')) {
33 $this->markTestSkipped();
36 $stmts = $this->parse($code);
37 $this->traverser->traverse($stmts);
40 public function invalidStatements()
44 array('$object->method($first, &$arg)'),
45 array('$closure($first, &$arg, $last)'),
51 * @dataProvider validStatements
53 public function testProcessStatementPasses($code)
55 $stmts = $this->parse($code);
56 $this->traverser->traverse($stmts);
59 public function validStatements()
62 array('array(&$var)'),
64 array('f(array(&$b))'),
67 if (version_compare(PHP_VERSION, '5.4', '<')) {
68 $data = array_merge($data, $this->invalidStatements());