Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixed issue #1667
- Loading branch information
1 parent
1c878c3
commit b791567
Showing
6 changed files
with
101 additions
and
17 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
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,6 @@ | ||
namespace Test\TypeHinting; | ||
|
||
abstract class TestAbstract | ||
{ | ||
abstract public function testFunc(array text = [], string text2 = "", boolean flag = true, int optional = null); | ||
} |
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,50 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Zephir Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Extension\TypeHinting; | ||
|
||
use PHPUnit\Framework\SkippedTestError; | ||
use TestConcreteClass; | ||
use Zephir\Support\TestCase; | ||
|
||
class AbstractTest extends TestCase | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return void | ||
*/ | ||
public static function setUpBeforeClass() | ||
{ | ||
if (PHP_VERSION_ID < 70000) { | ||
throw new SkippedTestError("Scalar type hint are avalibale in PHP 7 only"); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
* @link https://github.com/phalcon/zephir/issues/1667 | ||
*/ | ||
public function shouldCreateCompatibleChildClassUsingTypeHintedParams() | ||
{ | ||
$childClass = new TestConcreteClass(); | ||
|
||
$this->assertEquals( | ||
[[1667], '/', true, null], | ||
$childClass->testFunc([1667], '/', true, null) | ||
); | ||
|
||
$this->assertEquals( | ||
[['issue'], '\\', true, 1667], | ||
$childClass->testFunc(['issue'], '\\', true, 1667) | ||
); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir package. | ||
* | ||
* (c) Zephir Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Test\TypeHinting\TestAbstract; | ||
|
||
class TestConcreteClass extends TestAbstract | ||
{ | ||
public function testFunc(array $text = [], string $text2 = '', bool $flag = true, int $optional = null) | ||
{ | ||
return func_get_args(); | ||
} | ||
} |