CallTimePassByReferencePassTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2018 Justin Hileman
  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 Psy\Test\CodeCleaner;
  11. use Psy\CodeCleaner\CallTimePassByReferencePass;
  12. class CallTimePassByReferencePassTest extends CodeCleanerTestCase
  13. {
  14. public function setUp()
  15. {
  16. $this->setPass(new CallTimePassByReferencePass());
  17. }
  18. /**
  19. * @dataProvider invalidStatements
  20. * @expectedException \Psy\Exception\FatalErrorException
  21. */
  22. public function testProcessStatementFails($code)
  23. {
  24. $this->parseAndTraverse($code);
  25. }
  26. public function invalidStatements()
  27. {
  28. return [
  29. ['f(&$arg)'],
  30. ['$object->method($first, &$arg)'],
  31. ['$closure($first, &$arg, $last)'],
  32. ['A::b(&$arg)'],
  33. ];
  34. }
  35. /**
  36. * @dataProvider validStatements
  37. */
  38. public function testProcessStatementPasses($code)
  39. {
  40. $this->parseAndTraverse($code);
  41. $this->assertTrue(true);
  42. }
  43. public function validStatements()
  44. {
  45. return [
  46. ['array(&$var)'],
  47. ['$a = &$b'],
  48. ['f(array(&$b))'],
  49. ];
  50. }
  51. }