-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2374 - Implement nullable object return type
- Loading branch information
Showing
4 changed files
with
83 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
namespace Stub\Types; | ||
|
||
class Obj | ||
{ | ||
public function nullableObjectReturnNull() -> object | null | ||
{ | ||
return null; | ||
} | ||
|
||
public function nullableObjectReturnObj() -> object | null | ||
{ | ||
return new \stdClass(); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Phalcon Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extension\Types; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stub\Types\Obj; | ||
|
||
final class ObjTypeTest extends TestCase | ||
{ | ||
public function testIntFalse(): void | ||
{ | ||
$class = new Obj(); | ||
|
||
$this->assertNull($class->nullableObjectReturnNull()); | ||
$this->assertSame(new \stdClass(), $class->nullableObjectReturnObj()); | ||
} | ||
} |