maj ordre func
This commit is contained in:
parent
bab9ba81fe
commit
5c6d55ed46
@ -276,7 +276,7 @@ EOT;
|
|||||||
$pvalues = $this->unserialize($channel, $prow);
|
$pvalues = $this->unserialize($channel, $prow);
|
||||||
}
|
}
|
||||||
|
|
||||||
$updates = $initFunc->prependArgs(null, [$item, $values, $pvalues])->invoke();
|
$updates = $initFunc->prependArgs([$item, $values, $pvalues])->invoke();
|
||||||
if ($updates === [false]) return 0;
|
if ($updates === [false]) return 0;
|
||||||
if (is_array($updates) && $updates) {
|
if (is_array($updates) && $updates) {
|
||||||
if ($insert === null) $insert = false;
|
if ($insert === null) $insert = false;
|
||||||
@ -289,7 +289,7 @@ EOT;
|
|||||||
|
|
||||||
if ($func !== null) {
|
if ($func !== null) {
|
||||||
$updates = func::with($func)
|
$updates = func::with($func)
|
||||||
->prependArgs(null, [$item, $values, $pvalues])
|
->prependArgs([$item, $values, $pvalues])
|
||||||
->bind($channel, true)
|
->bind($channel, true)
|
||||||
->invoke();
|
->invoke();
|
||||||
if ($updates === [false]) return 0;
|
if ($updates === [false]) return 0;
|
||||||
|
@ -81,7 +81,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||||||
|
|
||||||
protected function cookRow(?array $row): ?array {
|
protected function cookRow(?array $row): ?array {
|
||||||
if ($this->cookFunc !== null) {
|
if ($this->cookFunc !== null) {
|
||||||
$row = $this->cookFunc->prependArgs(null, [$row])->invoke();
|
$row = $this->cookFunc->prependArgs([$row])->invoke();
|
||||||
}
|
}
|
||||||
if ($row !== null) {
|
if ($row !== null) {
|
||||||
foreach ($row as &$col) {
|
foreach ($row as &$col) {
|
||||||
|
@ -597,14 +597,14 @@ class func {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prependArgs(?int $stripCount=null, ?array $args=null): self {
|
function prependArgs(?array $args, ?int $stripCount=null): self {
|
||||||
if ($stripCount !== null || $args !== null) {
|
if ($stripCount !== null || $args !== null) {
|
||||||
array_splice($this->prefixArgs, 0, $stripCount ?? 0, $args);
|
array_splice($this->prefixArgs, 0, $stripCount ?? 0, $args);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendArgs(?int $stripCount=null, ?array $args=null): self {
|
function appendArgs(?array $args, ?int $stripCount=null): self {
|
||||||
if ($stripCount !== null || $args !== null) {
|
if ($stripCount !== null || $args !== null) {
|
||||||
$stripCount ??= 0;
|
$stripCount ??= 0;
|
||||||
if ($stripCount > 0) array_splice($this->prefixArgs, -$stripCount);
|
if ($stripCount > 0) array_splice($this->prefixArgs, -$stripCount);
|
||||||
|
@ -1103,8 +1103,10 @@ namespace nulib\php {
|
|||||||
|
|
||||||
function testRebind() {
|
function testRebind() {
|
||||||
$func = func::with([C1::class, "tmethod"]);
|
$func = func::with([C1::class, "tmethod"]);
|
||||||
|
// objets du même type
|
||||||
self::assertSame(11, $func->bind(new C1(0))->invoke());
|
self::assertSame(11, $func->bind(new C1(0))->invoke());
|
||||||
self::assertSame(12, $func->bind(new C1(1))->invoke());
|
self::assertSame(12, $func->bind(new C1(1))->invoke());
|
||||||
|
// objets de type différent
|
||||||
self::assertException(ValueException::class, function() use ($func) {
|
self::assertException(ValueException::class, function() use ($func) {
|
||||||
$func->bind(new C0())->invoke();
|
$func->bind(new C0())->invoke();
|
||||||
});
|
});
|
||||||
@ -1116,19 +1118,19 @@ namespace nulib\php {
|
|||||||
|
|
||||||
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->replaceArgs(["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->replaceArgs(["x", "y", "z"])->invoke());
|
||||||
|
|
||||||
self::assertSame(["x", "y", "z", "a", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(null, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z", "a", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"])->invoke());
|
||||||
self::assertSame(["x", "y", "z", "a", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(0, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z", "a", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"], 0)->invoke());
|
||||||
self::assertSame(["x", "y", "z", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(1, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z", "b", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"], 1)->invoke());
|
||||||
self::assertSame(["x", "y", "z", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(2, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z", "c"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"], 2)->invoke());
|
||||||
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->prependArgs(3, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"], 3)->invoke());
|
||||||
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->prependArgs(4, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->prependArgs(["x", "y", "z"], 4)->invoke());
|
||||||
|
|
||||||
self::assertSame(["a", "b", "c", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(null, ["x", "y", "z"])->invoke());
|
self::assertSame(["a", "b", "c", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"])->invoke());
|
||||||
self::assertSame(["a", "b", "c", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(0, ["x", "y", "z"])->invoke());
|
self::assertSame(["a", "b", "c", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"], 0)->invoke());
|
||||||
self::assertSame(["a", "b", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(1, ["x", "y", "z"])->invoke());
|
self::assertSame(["a", "b", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"], 1)->invoke());
|
||||||
self::assertSame(["a", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(2, ["x", "y", "z"])->invoke());
|
self::assertSame(["a", "x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"], 2)->invoke());
|
||||||
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(3, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"], 3)->invoke());
|
||||||
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(4, ["x", "y", "z"])->invoke());
|
self::assertSame(["x", "y", "z"], func::with($closure, ["a", "b", "c"])->appendArgs(["x", "y", "z"], 4)->invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user