This repository has been archived by the owner on Jul 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from jmalloc/feature/php7-scalar-hints
Add support for PHP 7 scalar type hints. Relates to #94.
- Loading branch information
Showing
6 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return new Eloquent\Phony\Mock\Builder\MockBuilder( | ||
'Eloquent\Phony\Test\TestInterfaceWithScalarTypeHint', | ||
array('customMethod' => function (int $int) {}), | ||
'MockGeneratorScalarTypeHint' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
class MockGeneratorScalarTypeHint | ||
implements \Eloquent\Phony\Mock\MockInterface, | ||
\Eloquent\Phony\Test\TestInterfaceWithScalarTypeHint | ||
{ | ||
public function method( | ||
int $a0, | ||
float $a1, | ||
string $a2, | ||
bool $a3 | ||
) { | ||
$argumentCount = \func_num_args(); | ||
$arguments = array(); | ||
|
||
if ($argumentCount > 0) { | ||
$arguments[] = $a0; | ||
} | ||
if ($argumentCount > 1) { | ||
$arguments[] = $a1; | ||
} | ||
if ($argumentCount > 2) { | ||
$arguments[] = $a2; | ||
} | ||
if ($argumentCount > 3) { | ||
$arguments[] = $a3; | ||
} | ||
|
||
for ($i = 4; $i < $argumentCount; ++$i) { | ||
$arguments[] = \func_get_arg($i); | ||
} | ||
|
||
return $this->_proxy->spy(__FUNCTION__)->invokeWith( | ||
new \Eloquent\Phony\Call\Argument\Arguments($arguments) | ||
); | ||
} | ||
|
||
public function customMethod( | ||
int $a0 | ||
) { | ||
$argumentCount = \func_num_args(); | ||
$arguments = array(); | ||
|
||
if ($argumentCount > 0) { | ||
$arguments[] = $a0; | ||
} | ||
|
||
for ($i = 1; $i < $argumentCount; ++$i) { | ||
$arguments[] = \func_get_arg($i); | ||
} | ||
|
||
return $this->_proxy->spy(__FUNCTION__)->invokeWith( | ||
new \Eloquent\Phony\Call\Argument\Arguments($arguments) | ||
); | ||
} | ||
|
||
private static $_uncallableMethods = array( | ||
'method' => true, | ||
); | ||
private static $_traitMethods = array(); | ||
private static $_customMethods = array(); | ||
private static $_staticProxy; | ||
private $_proxy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$message = 'Requires scalar type hints.'; | ||
|
||
return $detector->isSupported('parameter.hint.scalar'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Phony package. | ||
* | ||
* Copyright © 2015 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Phony\Test; | ||
|
||
interface TestInterfaceWithScalarTypeHint | ||
{ | ||
public function method( | ||
int $a, | ||
float $b, | ||
string $c, | ||
bool $d | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters