本文整理汇总了PHP中Bar::test方法的典型用法代码示例。如果您正苦于以下问题:PHP Bar::test方法的具体用法?PHP Bar::test怎么用?PHP Bar::test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bar
的用法示例。
在下文中一共展示了Bar::test方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
class Foo
{
public function __construct()
{
Stat::getInstance();
}
}
class Error
{
private $trace;
public function __construct()
{
$this->trace = debug_backtrace(1);
}
}
class Bar
{
public function __destruct()
{
Stat::getInstance();
new Error();
}
public function test()
{
new Error();
}
}
$foo = new Foo();
$bar = new Bar();
$bar->test();
示例2: test
<?php
require __DIR__ . "/classes.php.inc";
class Foo
{
public static function test() : A
{
return new A();
}
}
class Bar extends Foo
{
public static function test() : A
{
return new B();
}
}
var_dump(Bar::test());
var_dump(Foo::test());
示例3: test2
}
public static function test2()
{
$a = new static();
// Gives Bar, the 'late static binding' class
var_dump($a);
}
}
class Bar extends Foo
{
public static function test3()
{
$a = new self();
var_dump($a);
// Gives Bar, this class
}
public static function test4()
{
parent::test();
// Gives Foo, even though we're calling from a child
}
public static function test5()
{
parent::test2();
// Gives Bar, because its using the late static binding context
}
}
$obj = Bar::test();
$obj = Bar::test3();
$obj = Bar::test4();
$obj = Bar::test5();
示例4: main
function main()
{
$bar = new Bar();
echo $bar->test();
}
示例5: test
}
class Simple
{
function test()
{
static $i;
$i++;
return $i;
}
}
test();
test();
Foo::test();
Foo::test();
Bar::test();
Bar::test();
$simple = new Simple();
$simple->test();
$simple->test();
static $one = 20, $two, $three = 40;
if ($one !== 20) {
return 'fail_1';
}
if ($two !== null) {
return 'fail_2';
}
if ($three !== 40) {
return 'fail_3';
}
return test() + Foo::test() + Bar::test() + $simple->test() === 12 ? 'success' : 'fail';
示例6: call
<?php
class Foo
{
static function call()
{
return 'fail';
}
static function test()
{
return static::call();
}
static function get()
{
return new static();
}
}
class Bar extends Foo
{
static function call()
{
return 'success';
}
}
$bar = Bar::get();
if (!$bar instanceof Bar) {
return 'fail_get';
}
return Bar::test();