Skip to content

Commit

Permalink
Support PHP 8.0 false Literal Type (#1270)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Jun 6, 2023
2 parents ddc1683 + d01940d commit d65665a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/Mockery/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ public function mockery_returnValueForMethod($name)
case 'int': return 0;
case 'float': return 0.0;
case 'bool': return false;
case 'false': return false;

case 'array':
case 'iterable':
Expand Down
17 changes: 17 additions & 0 deletions tests/PHP82/Php82LanguageFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ public function testCanMockUndefinedClasses()

$this->assertSame('bar', $class->foo);
}
public function testCanMockReservedWordFalse()
{
$mock = mock(HasReservedWordFalse::class);

$mock->expects('testFalseMethod')->once();

self::assertFalse($mock->testFalseMethod());
self::assertInstanceOf(HasReservedWordFalse::class, $mock);
}
}

class HasReservedWordFalse
{
public function testFalseMethod(): false
{
return false;
}
}

class HasNullReturnType
Expand Down

0 comments on commit d65665a

Please sign in to comment.