Permalink
Browse files

Environment::bypassFinals(): respect final as literals

  • Loading branch information...
milo committed Jul 20, 2018
1 parent 8044478 commit fc8df7955907a0b89b9ab1f3cd020cc9a1a2dafa
Showing with 10 additions and 1 deletion.
  1. +1 βˆ’1 src/Framework/Environment.php
  2. +2 βˆ’0 tests/Framework/FileMutator.phpt
  3. +7 βˆ’0 tests/Framework/fixtures/final.class.php
@@ -173,7 +173,7 @@ public static function bypassFinals(): void
{
FileMutator::addMutator(function (string $code): string {
if (strpos($code, 'final') !== false) {
$tokens = token_get_all($code);
$tokens = token_get_all($code, TOKEN_PARSE);
$code = '';
foreach ($tokens as $token) {
$code .= is_array($token)
@@ -14,3 +14,5 @@ require __DIR__ . '/fixtures/final.class.php';
$rc = new ReflectionClass('FinalClass');
Assert::false($rc->isFinal());
Assert::false($rc->getMethod('finalMethod')->isFinal());
Assert::same(123, FinalClass::FINAL);
Assert::same(456, (new FinalClass)->final());
@@ -2,7 +2,14 @@
final class FinalClass
{
const FINAL = 123;
final function finalMethod()
{
}
function final()
{
return 456;
}
}

0 comments on commit fc8df79

Please sign in to comment.