Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c6e82be

Browse files
Update to the newest Z-Engine hook API
1 parent aee0871 commit c6e82be

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

‎composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"lisachenko/z-engine": "^0.6.0",
13+
"lisachenko/z-engine": "^0.7",
1414
"php": "~7.4"
1515
},
1616
"autoload": {

‎src/Matrix.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Native\Type;
1313

1414
use InvalidArgumentException;
15+
use ZEngine\ClassExtension\Hook\CompareValuesHook;
16+
use ZEngine\ClassExtension\Hook\DoOperationHook;
1517
use ZEngine\ClassExtension\ObjectCompareValuesInterface;
1618
use ZEngine\ClassExtension\ObjectCreateInterface;
1719
use ZEngine\ClassExtension\ObjectCreateTrait;
@@ -221,16 +223,18 @@ public function equals(Matrix $another): bool
221223
}
222224

223225
/**
224-
* Performs operation on given object
226+
* Performs an operation on given object
225227
*
226-
* @param int $opCode Operation code
227-
* @param Matrix|int|float $left left side of operation
228-
* @param Matrix|int|float $right Right side of operation
228+
* @param DoOperationHook $hook Instance of current hook
229229
*
230-
* @return Matrix Result of operation value
230+
* @return mixed Result of operation value
231231
*/
232-
public static function __doOperation(int$opCode, $left, $right): Matrix
232+
public static function __doOperation(DoOperationHook$hook): Matrix
233233
{
234+
$left = $hook->getFirst();
235+
$right = $hook->getSecond();
236+
$opCode = $hook->getOpcode();
237+
234238
$isLeftMatrix = $left instanceof Matrix;
235239
$isRightMatrix = $right instanceof Matrix;
236240
$isLeftNumeric = is_numeric($left);
@@ -274,13 +278,14 @@ public static function __doOperation(int $opCode, $left, $right): Matrix
274278
/**
275279
* Performs comparison of given object with another value
276280
*
277-
* @param mixed $one First side of operation
278-
* @param mixed $another Another side of operation
281+
* @param CompareValuesHook $hook Instance of current hook
279282
*
280283
* @return int Result of comparison: 1 is greater, -1 is less, 0 is equal
281284
*/
282-
public static function __compare($one, $another): int
285+
public static function __compare(CompareValuesHook$hook): int
283286
{
287+
$one = $hook->getFirst();
288+
$another = $hook->getSecond();
284289
if (!($one instanceof Matrix) || !($another instanceof Matrix)) {
285290
throw new \InvalidArgumentException('Matrix can be compared only with another matrix');
286291
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /