modifs.mineures sans commentaires
This commit is contained in:
parent
f59dfb27b0
commit
e295e8d225
|
@ -1,36 +1,418 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
function tltf_zero(): int { return 0; }
|
function tsimple(): int { return 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace nur\sery\wip\php\impl {
|
namespace nur\sery\wip\php\impl {
|
||||||
function nptf_zero(): int { return 0; }
|
function ntsimple(): int { return 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace nur\sery\wip\php {
|
namespace nur\sery\wip\php {
|
||||||
use nulib\tests\TestCase;
|
use nulib\tests\TestCase;
|
||||||
|
use nur\sery\wip\php\impl\MyClass;
|
||||||
|
|
||||||
class funcTest extends TestCase {
|
class funcTest extends TestCase {
|
||||||
function testSimple() {
|
function testSimple() {
|
||||||
|
# scalaires
|
||||||
$func = null; self::assertFalse(func::verifix_simple($func));
|
$func = null; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = null; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
$func = false; self::assertFalse(func::verifix_simple($func));
|
$func = false; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = false; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
$func = ""; self::assertFalse(func::verifix_simple($func));
|
$func = ""; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ""; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
$func = 'tltf_zero'; self::assertTrue(func::verifix_simple($func));
|
$func = "::"; self::assertFalse(func::verifix_simple($func));
|
||||||
self::assertSame([false, "tltf_zero"], $func);
|
$func = "::"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
$func = 'tltf_zero'; self::assertTrue(func::verifix_simple($func, false));
|
|
||||||
self::assertSame([false, "tltf_zero"], $func);
|
|
||||||
|
|
||||||
$func = 'nur\sery\wip\php\impl\nptf_zero'; self::assertTrue(func::verifix_simple($func));
|
$func = "->"; self::assertFalse(func::verifix_simple($func));
|
||||||
self::assertSame([false, 'nur\sery\wip\php\impl\nptf_zero'], $func);
|
$func = "->"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
$func = 'nur\sery\wip\php\impl\nptf_zero'; self::assertTrue(func::verifix_simple($func, false));
|
|
||||||
self::assertSame([false, 'nur\sery\wip\php\impl\nptf_zero'], $func);
|
$func = "tsimple"; self::assertTrue(func::verifix_simple($func));
|
||||||
|
$func = "tsimple"; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertTrue(func::verifix_simple($func));
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = 'tmissing'; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = 'tmissing'; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = "::tstatic"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = "::tstatic"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = "->tmethod"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = "->tmethod"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = "::tmissing"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = "::tmissing"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = "->tmissing"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = "->tmissing"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = MyClass::class."::tstatic"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = MyClass::class."::tstatic"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = MyClass::class."->tmethod"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = MyClass::class."->tmethod"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = MyClass::class."::tmissing"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = MyClass::class."::tmissing"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = MyClass::class."->tmissing"; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = MyClass::class."->tmissing"; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
# tableaux avec un seul scalaire
|
||||||
|
$func = []; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = []; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [""]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [""]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["::"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["::"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["->"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["->"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["tsimple"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["tsimple"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ['nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ['nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class."::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class."::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class."->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class."->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class."::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class."::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class."->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class."->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
# tableaux avec deux scalaires
|
||||||
|
$func = [null, "tsimple"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "tsimple"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, "tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, "::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, "->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, "::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [null, "->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [null, "->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_simple($func));
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertTrue(func::verifix_simple($func));
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false, "tmissing"]; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false, "::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false, "->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false, "::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [false, "->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [false, "->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "tsimple"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "tsimple"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = ["", "->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = ["", "->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "::tstatic"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "::tstatic"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "->tmethod"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "->tmethod"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "::tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "::tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "->tmissing"]; self::assertFalse(func::verifix_simple($func));
|
||||||
|
$func = [MyClass::class, "->tmissing"]; self::assertFalse(func::verifix_simple($func, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSimpleResults() {
|
||||||
|
$func = "tsimple"; self::assertTrue(func::verifix_simple($func));
|
||||||
|
self::assertSame([false, "tsimple"], $func);
|
||||||
|
$func = "tsimple"; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, "tsimple"], $func);
|
||||||
|
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertTrue(func::verifix_simple($func));
|
||||||
|
self::assertSame([false, 'nur\sery\wip\php\impl\ntsimple'], $func);
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, 'nur\sery\wip\php\impl\ntsimple'], $func);
|
||||||
|
|
||||||
|
$func = 'tmissing'; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, "tmissing"], $func);
|
||||||
|
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_simple($func));
|
||||||
|
self::assertSame([false, "tsimple"], $func);
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, "tsimple"], $func);
|
||||||
|
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertTrue(func::verifix_simple($func));
|
||||||
|
self::assertSame([false, 'nur\sery\wip\php\impl\ntsimple'], $func);
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, 'nur\sery\wip\php\impl\ntsimple'], $func);
|
||||||
|
|
||||||
|
$func = [false, "tmissing"]; self::assertTrue(func::verifix_simple($func, false));
|
||||||
|
self::assertSame([false, "tmissing"], $func);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testStatic() {
|
||||||
|
# scalaires
|
||||||
|
$func = null; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = null; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = false; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = false; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ""; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ""; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "::"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "::"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "->"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "->"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "tsimple"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "tsimple"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = 'nur\sery\wip\php\impl\ntsimple'; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = 'tmissing'; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = 'tmissing'; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "::tstatic"; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "::tstatic"; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "->tmethod"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "->tmethod"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "::tmissing"; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "::tmissing"; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = "->tmissing"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = "->tmissing"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = MyClass::class."::tstatic"; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = MyClass::class."::tstatic"; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = MyClass::class."->tmethod"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = MyClass::class."->tmethod"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = MyClass::class."::tmissing"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = MyClass::class."::tmissing"; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = MyClass::class."->tmissing"; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = MyClass::class."->tmissing"; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
# tableaux avec un seul scalaire
|
||||||
|
$func = []; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = []; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [""]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [""]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["::"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["::"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["->"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["->"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["tsimple"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["tsimple"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ['nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ['nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["::tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class."::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class."::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class."->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class."->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class."::tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class."::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class."->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class."->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
# tableaux avec deux scalaires
|
||||||
|
$func = [null, "tsimple"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "tsimple"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, "tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, "::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, "->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, "::tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [null, "->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [null, "->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "tsimple"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "::tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [false, "->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [false, "->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "tsimple"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "tsimple"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", 'nur\sery\wip\php\impl\ntsimple']; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "::tmissing"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = ["", "->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = ["", "->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "::tstatic"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "::tstatic"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tmethod"]; self::assertTrue(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "tmethod"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "->tmethod"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "->tmethod"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "::tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "::tmissing"]; self::assertTrue(func::verifix_static($func, false, $bound));
|
||||||
|
|
||||||
|
$func = [MyClass::class, "->tmissing"]; self::assertFalse(func::verifix_static($func, true, $bound));
|
||||||
|
$func = [MyClass::class, "->tmissing"]; self::assertFalse(func::verifix_static($func, false, $bound));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testStaticResults() {
|
||||||
|
|
||||||
$func = 'inexistant_function_xxx'; self::assertFalse(func::verifix_simple($func));
|
|
||||||
$func = 'inexistant_function_xxx'; self::assertTrue(func::verifix_simple($func, false));
|
|
||||||
self::assertSame([false, "inexistant_function_xxx"], $func);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
namespace nur\sery\wip\php\impl;
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
static function tstatic(): int {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tmethod(): int {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ class func {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$f = $func[1];
|
$f = $func[1];
|
||||||
|
if ($f === "") return false;
|
||||||
if (strpos($f, "::") !== false) return false;
|
if (strpos($f, "::") !== false) return false;
|
||||||
if (strpos($f, "->") !== false) return false;
|
if (strpos($f, "->") !== false) return false;
|
||||||
if ($strict) {
|
if ($strict) {
|
||||||
|
@ -52,30 +53,55 @@ class func {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function parse_class(string $cf, ?string &$c, ?string &$f): bool {
|
private static function is_invalid(?string $m): bool {
|
||||||
if (strpos($cf, "->") !== false) return false;
|
return $m === null || $m === "" || $m === "::" || $m === "->";
|
||||||
if ($cf === "::") return false;
|
}
|
||||||
$pos = strpos($cf, "::");
|
|
||||||
if ($pos == 0) return false; # inclus $pos === false
|
private static function is_nfunction(?string $m): bool {
|
||||||
$c = substr($cf, 0, $pos);
|
return strpos($m, "\\") !== false;
|
||||||
$f = cv::vn(substr($cf, $pos + 2));
|
}
|
||||||
|
|
||||||
|
private static function parse_static(?string &$m): bool {
|
||||||
|
$pos = strpos($m, "::");
|
||||||
|
if ($pos === false) return false;
|
||||||
|
$m = substr($m, $pos + 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function parse_static(string $cf, ?string &$c, ?string &$f, ?bool &$bound): bool {
|
private static function parse_method(?string &$m): bool {
|
||||||
if (strpos($cf, "->") !== false) return false;
|
$pos = strpos($m, "->");
|
||||||
if ($cf === "::") return false;
|
|
||||||
$pos = strpos($cf, "::");
|
|
||||||
if ($pos === false) return false;
|
if ($pos === false) return false;
|
||||||
if ($pos == strlen($cf) - 2) return false;
|
$m = substr($m, $pos + 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function parse_class_m(?string $cm, ?string &$c, ?string &$m): bool {
|
||||||
|
if (self::is_invalid($cm) || self::parse_method($cm)) return false;
|
||||||
|
$pos = strpos($cm, "::");
|
||||||
|
if ($pos === false) return false;
|
||||||
|
if ($pos === 0) return false;
|
||||||
|
$tmpc = substr($cm, 0, $pos);
|
||||||
|
$cm = substr($cm, $pos + 2);
|
||||||
|
if (self::is_nfunction($cm)) return false;
|
||||||
|
[$c, $m] = [$tmpc, cv::vn($cm)];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function parse_c_method(?string $cm, ?string &$c, ?string &$m, ?bool &$bound): bool {
|
||||||
|
if (self::is_invalid($cm) || self::parse_method($cm)) return false;
|
||||||
|
$pos = strpos($cm, "::");
|
||||||
|
if ($pos === false) return false;
|
||||||
|
if ($pos == strlen($cm) - 2) return false;
|
||||||
if ($pos > 0) {
|
if ($pos > 0) {
|
||||||
$c = substr($cf, 0, $pos);
|
$tmpc = substr($cm, 0, $pos);
|
||||||
$bound = true;
|
$bound = true;
|
||||||
} else {
|
} else {
|
||||||
$c = null;
|
$tmpc = null;
|
||||||
$bound = false;
|
$bound = false;
|
||||||
}
|
}
|
||||||
$f = substr($cf, $pos + 2);
|
$cm = substr($cm, $pos + 2);
|
||||||
|
if (self::is_nfunction($cm)) return false;
|
||||||
|
[$c, $m] = [$tmpc, cv::vn($cm)];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,35 +124,49 @@ class func {
|
||||||
*/
|
*/
|
||||||
static function verifix_static(&$func, bool $strict=true, ?bool &$bound=null): bool {
|
static function verifix_static(&$func, bool $strict=true, ?bool &$bound=null): bool {
|
||||||
if (is_string($func)) {
|
if (is_string($func)) {
|
||||||
if (!self::parse_static($func, $c, $f, $bound)) return false;
|
if (!self::parse_c_method($func, $c, $f, $bound)) return false;
|
||||||
$func = [$c, $f];
|
$func = [$c, $f];
|
||||||
} elseif (is_array($func)) {
|
} elseif (is_array($func)) {
|
||||||
if (!array_key_exists(0, $func)) return false;
|
if (!array_key_exists(0, $func)) return false;
|
||||||
$c = $func[0];
|
$c = $func[0];
|
||||||
if (self::parse_class($c, $c, $f)) {
|
if (self::parse_class_m($c, $c, $f)) {
|
||||||
|
$func[0] = $c;
|
||||||
if ($f !== null) {
|
if ($f !== null) {
|
||||||
# ["class::method"]
|
# ["class::method"] --> ["class", "method"]
|
||||||
array_splice($func, 1, 0, [$f]);
|
array_splice($func, 1, 0, [$f]);
|
||||||
}
|
}
|
||||||
$bound = true;
|
$bound = true;
|
||||||
|
} elseif (self::parse_c_method($c, $c, $f, $bound)) {
|
||||||
|
# ["::method"] --> [null, "method"]
|
||||||
|
array_splice($func, 0, 0, [null]);
|
||||||
|
$func[1] = $f;
|
||||||
} else {
|
} else {
|
||||||
$bound = false;
|
if (self::is_invalid($c)) $c = null;
|
||||||
|
$func[0] = $c;
|
||||||
|
$bound = is_string($c);
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
if (!array_key_exists(1, $func)) return false;
|
if (!array_key_exists(1, $func)) return false;
|
||||||
$f = $func[1];
|
$f = $func[1];
|
||||||
if (!is_string($f)) return false;
|
if (!is_string($f)) return false;
|
||||||
if (!self::parse_static($f, $rc, $f, $rbound)) return false;
|
if (self::parse_c_method($f, $rc, $f, $rbound)) {
|
||||||
if ($rc !== null && $c === null) {
|
if ($rc !== null && $c === null) {
|
||||||
$c = $rc;
|
$c = $rc;
|
||||||
$bound = $rbound;
|
$bound = $rbound;
|
||||||
}
|
}
|
||||||
$func[0] = $c;
|
} elseif (self::is_invalid($f)) {
|
||||||
|
return false;
|
||||||
|
} elseif (self::is_nfunction($f)) {
|
||||||
|
return false;
|
||||||
|
} elseif (self::parse_method($f)) {
|
||||||
|
return false;
|
||||||
|
} elseif (self::parse_static($f)) {
|
||||||
|
}
|
||||||
$func[1] = $f;
|
$func[1] = $f;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($strict && !method_exists($c, $f)) return false;
|
if ($strict && $bound && !method_exists($c, $f)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue