本文整理汇总了PHP中Bar::foo方法的典型用法代码示例。如果您正苦于以下问题:PHP Bar::foo方法的具体用法?PHP Bar::foo怎么用?PHP Bar::foo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bar
的用法示例。
在下文中一共展示了Bar::foo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: var_dump
echo "ReflectionFunction(1):";
var_dump($rf->getStaticVariables());
foo();
echo "ReflectionFunction(2):";
var_dump($rf->getStaticVariables());
foo();
$rf = new ReflectionFunction('foo');
echo "ReflectionFunction(3):";
var_dump($rf->getStaticVariables());
echo "---- ReflectionMethod ----\n";
$rf = new ReflectionMethod('Bar', 'foo');
echo "ReflectionMethod(1):";
var_dump($rf->getStaticVariables());
Bar::foo();
echo "ReflectionMethod(2):";
var_dump($rf->getStaticVariables());
Bar::foo();
$rf = new ReflectionFunction('foo');
echo "ReflectionMethod(3):";
var_dump($rf->getStaticVariables());
echo "---- ReflectionClosure ----\n";
$rf = new ReflectionFunction($foo);
echo "ReflectionFunction(1-closure):";
var_dump($rf->getStaticVariables());
$foo();
echo "ReflectionFunction(2-closure):";
var_dump($rf->getStaticVariables());
$foo();
$rf = new ReflectionFunction($foo);
echo "ReflectionFunction(3-closure):";
var_dump($rf->getStaticVariables());
示例2: foo
<?php
trait T
{
public final function foo()
{
return 'T::foo';
}
}
class Foo
{
use T;
}
class Bar extends Foo
{
public final function foo()
{
return 'Bar::foo';
}
}
$bar = new Bar();
echo $bar->foo() . "\n";
示例3: Bar
<?php
namespace jubianchi;
use jubianchi\Traits\Foo;
require_once __DIR__ . '/Traits/Foo.php';
class Bar
{
use Foo;
}
xdebug_start_code_coverage();
$b = new Bar();
$b->foo();
var_dump(xdebug_get_code_coverage());
$reflector = new \ReflectionClass('\\jubianchi\\Bar');
var_dump($reflector->getMethod('foo')->getFileName(), $reflector->getMethod('foo')->getStartLine(), $reflector->getMethod('foo')->getEndLine());
示例4: Foo
function test_references()
{
// basic references (belongs_to)
$f = new Foo(array('id' => 1, 'name' => 'Joe'));
$f->put();
$b = new Bar(array('id' => 1, 'name' => 'Jim', 'foo' => 1));
$b->put();
$this->assertEquals($b->name, 'Jim');
$this->assertEquals($b->foo, 1);
$this->assertEquals($b->foo()->name, 'Joe');
$this->assertEquals($b->foo()->name, 'Joe');
// fake reference should fail
try {
$this->assertTrue($b->fake());
} catch (Exception $e) {
$this->assertRegExp('/Call to undefined method Bar::fake in .+tests\\/ModelTest\\.php on line [0-9]+/', $e->getMessage());
}
}
示例5: function
<?php
namespace Dotink\Lab;
use Dotink\Parody\Mime;
return ['setup' => function ($data, $shared) {
needs('src/Quip.php');
needs('src/Mime.php');
}, 'tests' => ['Test' => function ($data, $shared) {
$static = Mime::define('Bar');
$instance = Mime::create('Bar')->onCall('foo')->give('bar');
$static->onCall('foo')->give('bar');
assert(\Bar::foo())->equals('bar');
assert($instance()->foo())->equals('bar');
$instance = $static->create()->onCall('foo')->give('bar');
assert($instance()->foo())->equals('bar');
$static->onNew('test', function ($mime) {
$mime->onCall('foo')->give('foo');
});
$instance = new \Bar('test');
assert($instance->foo())->equals('foo');
}]];