-
-
Notifications
You must be signed in to change notification settings - Fork 22
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 #20 from lisachenko/feature/user-class-handlers
[Feature] Implement userland object handlers
- Loading branch information
Showing
11 changed files
with
798 additions
and
3 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,29 @@ | ||
<?php | ||
/** | ||
* Z-Engine framework | ||
* | ||
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com> | ||
* | ||
* This source file is subject to the license that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace ZEngine\ClassExtension; | ||
|
||
/** | ||
* Interface ObjectCastInterface allows to cast given object to scalar values, like integer, floats, etc | ||
*/ | ||
interface ObjectCastInterface | ||
{ | ||
/** | ||
* Performs casting of given object to another value | ||
* | ||
* @param object $instance Instance of object that should be casted | ||
* @param int $typeTo Type of casting, @see ReflectionValue::IS_* constants | ||
* | ||
* @return mixed Casted value | ||
*/ | ||
public static function __cast(object $instance, int $typeTo); | ||
} |
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,29 @@ | ||
<?php | ||
/** | ||
* Z-Engine framework | ||
* | ||
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com> | ||
* | ||
* This source file is subject to the license that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace ZEngine\ClassExtension; | ||
|
||
/** | ||
* Interface ObjectCompareValuesInterface allows to perform comparison of objects | ||
*/ | ||
interface ObjectCompareValuesInterface | ||
{ | ||
/** | ||
* Performs comparison of given object with another value | ||
* | ||
* @param mixed $one First side of operation | ||
* @param mixed $another Another side of operation | ||
* | ||
* @return int Result of comparison: 1 is greater, -1 is less, 0 is equal | ||
*/ | ||
public static function __compare($one, $another): int; | ||
} |
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,32 @@ | ||
<?php | ||
/** | ||
* Z-Engine framework | ||
* | ||
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com> | ||
* | ||
* This source file is subject to the license that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace ZEngine\ClassExtension; | ||
|
||
use Closure; | ||
use FFI\CData; | ||
|
||
/** | ||
* Interface ObjectCreateInterface allows to hook into the object initialization process (eg new FooBar()) | ||
*/ | ||
interface ObjectCreateInterface | ||
{ | ||
/** | ||
* Performs low-level initialization of object during new instances creation | ||
* | ||
* @param CData $classType Class type to initialize (zend_class_entry) | ||
* @param Closure $initializer Original initializer that accepts a zend_class_entry and creates a new zend_object | ||
* | ||
* @return CData Pointer to the zend_object instance | ||
*/ | ||
public static function __init(CData $classType, Closure $initializer): CData; | ||
} |
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,35 @@ | ||
<?php | ||
/** | ||
* Z-Engine framework | ||
* | ||
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com> | ||
* | ||
* This source file is subject to the license that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace ZEngine\ClassExtension; | ||
|
||
use Closure; | ||
use FFI\CData; | ||
|
||
/** | ||
* Trait ObjectCreateTrait contains default hook implementation for object initialization | ||
*/ | ||
trait ObjectCreateTrait | ||
{ | ||
/** | ||
* Performs low-level initialization of object during new instances creation | ||
* | ||
* @param CData $classType Class type to initialize (zend_class_entry) | ||
* @param Closure $initializer Original initializer that accepts a zend_class_entry and creates a new zend_object | ||
* | ||
* @return CData Pointer to the zend_object instance | ||
*/ | ||
public static function __init(CData $classType, Closure $initializer): CData | ||
{ | ||
return $initializer($classType); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
/** | ||
* Z-Engine framework | ||
* | ||
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com> | ||
* | ||
* This source file is subject to the license that is bundled | ||
* with this source code in the file LICENSE. | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace ZEngine\ClassExtension; | ||
|
||
/** | ||
* Interface ObjectDoOperationInterface allows to perform math operations (aka operator overloading) on object | ||
*/ | ||
interface ObjectDoOperationInterface | ||
{ | ||
/** | ||
* Performs casting of given object to another value | ||
* | ||
* @param int $opCode Operation code | ||
* @param mixed $left left side of operation | ||
* @param mixed $right Right side of operation | ||
* | ||
* @return mixed Result of operation value | ||
*/ | ||
public static function __doOperation(int $opCode, $left, $right); | ||
} |
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
Oops, something went wrong.