AnonymousFunctionWithThisRuleTest.php 796 B

12345678910111213141516171819202122232425262728
  1. <?php declare(strict_types = 1);
  2. namespace Composer\PHPStanRulesTests;
  3. use Composer\PHPStanRules\AnonymousFunctionWithThisRule;
  4. use PHPStan\Testing\RuleTestCase;
  5. /**
  6. * @phpstan-extends RuleTestCase<AnonymousFunctionWithThisRule>
  7. */
  8. final class AnonymousFunctionWithThisRuleTest extends RuleTestCase
  9. {
  10. /**
  11. * @inheritDoc
  12. */
  13. protected function getRule(): \PHPStan\Rules\Rule
  14. {
  15. return new AnonymousFunctionWithThisRule();
  16. }
  17. public function testWithThis(): void
  18. {
  19. $this->analyse([__DIR__ . '/data/method-with-this.php'], [
  20. ['Using $this inside anonymous function is prohibited because of PHP 5.3 support.', 13],
  21. ['Using $this inside anonymous function is prohibited because of PHP 5.3 support.', 17],
  22. ]);
  23. }
  24. }