本文整理汇总了PHP中Bar类的典型用法代码示例。如果您正苦于以下问题:PHP Bar类的具体用法?PHP Bar怎么用?PHP Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test()
{
$bar = new Bar();
$bar->setMessage('foobar');
$this->assertEquals('foobar', $bar->getMessage());
$this->assertEquals('foobar', $bar->message);
}
示例2: doSomething
public function doSomething()
{
$this->logger->info("Entering application.");
$bar = new Bar();
$bar->doIt();
echo "<p>done</p>";
$this->logger->info("Exiting application.");
}
示例3: main
function main()
{
$k = new Bar();
$y = new Baz();
foo();
$k->asd();
$y->k();
}
示例4: read
function read($id)
{
global $output;
$output .= "read" . PHP_EOL;
$a = new Bar();
$b = new Foo($a);
$a->set($b);
$session = array('old' => $b);
return msgpack_serialize($session);
}
示例5: eraseData
protected function eraseData()
{
Foo::truncate();
Bar::truncate();
Baz::truncate();
Bom::truncate();
}
示例6: invoke
public static function invoke(Foo $instance)
{
// Same class, other instance, direct call.
$instance->call();
// Same class, other instance, indirect call.
$foo = new Foo();
$foo->call();
// Same class, other instance, indirect call.
$x = new Foo();
$y = $x;
$z = $y;
$z->call();
// Same class, other instance, direct call.
(new Foo())->call();
// Other class, other instance, indirect call.
$bar = new Bar();
$bar->call();
// Other class, other instance, direct call.
(new Bar())->call();
}
示例7: test_decorator
public function test_decorator()
{
$foo = new Foo();
$bar = Bar::wrap($foo);
// internal object
$this->assertEquals($foo, $bar->object);
// original property
$this->assertEquals($bar->a1, 10);
// new property
$this->assertEquals($bar->b, 20);
// redifine original property
$this->assertEquals($bar->a2, 22);
// original function
$this->assertEquals($bar->fooFunction(), 14);
// isset
$this->assertTrue(isset($bar->b));
$this->assertTrue(isset($bar->a1));
}
示例8: __construct
/**
* Bar constructor.
* @param Session $session
* @param string[] $barData
*/
public function __construct($session, $barData)
{
$this->Session = $session;
$this->DB = $session->DB;
if (empty(array_diff_key(Bar::ValidArray(), $barData))) {
//Loading an existing bar
$this->Refresh($barData);
$this->Valid = true;
} else {
if (empty(array_diff_key(Bar::NewArray(), $barData))) {
//Creating a new bar
$this->Type = $barData['type'];
$this->Title = $barData['title'];
$this->Description = $barData['description'];
$this->CreateStamp = $this->ModifyStamp = (double) microtime(true);
$id = (int) $this->DB->Query("\n INSERT INTO tblBars\n (userID, type, title, description, createStamp, modifyStamp)\n VALUES(\n " . (int) $this->Session->ID . "\n , " . $this->DB->Quote($this->Type) . "\n , " . $this->DB->Quote($this->Title) . "\n , " . $this->DB->Quote($this->Description) . "\n , {$this->CreateStamp}\n , {$this->ModifyStamp}\n )\n ", true);
if ($id) {
$this->ID = $id;
$this->Valid = true;
}
}
}
}
示例9: getFooWithInlineService
/**
* Gets the 'foo_with_inline' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return \Foo A Foo instance
*/
protected function getFooWithInlineService()
{
$a = new \Bar();
$this->services['foo_with_inline'] = $instance = new \Foo();
$a->setBaz($this->get('baz'));
$a->pub = 'pub';
$instance->setBar($a);
return $instance;
}
示例10: 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());
示例11: array
$mail->Subject = 'Somebody sent you a token!';
$mail->Body = 'HEY YOU GUYS! LOOK WAT I DONE DID!!!!!!.';
$mail->AltBody = 'Received token.';
$email = $_POST['email'];
$name = $_POST['name'];
if (!$mail->send()) {
$message = 'Message could not be sent. <p>';
} else {
$message = 'Message has been sent.';
}
return $app['twig']->render("email.html.twig", array('message' => $message));
});
$app->post("/add_preferred_bar/{id}", function ($id) use($app) {
$user = Patron::find($id);
$all_bars = Bar::getAll();
$bar = Bar::find($_POST['add_bar']);
$user->addPreferredBar($bar);
return $app['twig']->render("patron.html.twig", array('user' => $user, 'user_tokens' => $user->getTokens(), 'all_bars' => $all_bars, 'preferred_bars' => true, 'send_token' => false, 'token_form' => false, 'edit_user' => false));
});
// $app->delete("/delete_preferred_bar/{id}/{bar_id}", function($id, $bar_id) use($app) {
// $user = Patron::find($id);
// $all_bars = Bar::getAll();
// $bar = Bar::find($bar_id);
// $user->deleteBar($bar);
// return $app['twig']->render("patron.html.twig", array(
// 'user' => $user,
// 'user_tokens' =>$user->getTokens(),
// 'all_bars' => $all_bars,
// 'preferred_bars' => false,
// 'send_token' => false,
// 'token_form' => false,
示例12: pang
{
return "FooBar2::ping();";
}
function pang()
{
return "FooBar2::pang();";
}
}
class FooBar3 extends Bar
{
function cheer()
{
return "FooBar3::cheer();";
}
}
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
示例13: test_references
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());
}
}
示例14: f
<?php
class Foo
{
protected function f()
{
return 'Foo';
}
}
trait T
{
public function f()
{
return 'Bar';
}
}
class Bar extends Foo
{
use T;
}
$b = new Bar();
echo $b->f() . "\n";
示例15: function
}
});
//Sign Up Routes:
$app->get("/show_customer_signup", function () use($app) {
return $app['twig']->render('index.html.twig', array('about' => false, 'sign_up' => true, "sign_in" => false, 'team' => false, 'customer_signup' => true, 'business_signup' => false));
});
$app->get("/show_business_signup", function () use($app) {
return $app['twig']->render('index.html.twig', array('about' => false, 'sign_up' => true, "sign_in" => false, 'team' => false, 'customer_signup' => false, 'business_signup' => true));
});
$app->post("/customer_signup", function () use($app) {
$new_user = new Patron($_POST['username'], $_POST['email']);
$new_user->save();
return $app['twig']->render("signup_confirmation.html.twig");
});
$app->post("/business_signup", function () use($app) {
$new_bar = new Bar($_POST['name'], $_POST['phone'], $_POST['address'], $_POST['website']);
$new_bar->save();
return $app['twig']->render("signup_confirmation.html.twig");
});
//Get Show email search
$app->get("/show_email_search/{id}", function ($id) use($app) {
$user = Patron::find($id);
$all_bars = Bar::getAll();
return $app['twig']->render("patron.html.twig", array('user' => $user, 'user_tokens' => $user->getTokens(), 'all_bars' => $all_bars, 'preferred_bars' => false, 'send_token' => true, 'token_form' => false, 'edit_user' => false));
});
//Get Show User Tokens
$app->get("/show_user_tokens/{id}", function ($id) use($app) {
$user = Patron::find($id);
$tokens = $user->getTokens();
return $app['twig']->render("patron.html.twig", array('user' => $user, 'user_tokens' => $tokens, 'preferred_bars' => false, 'send_token' => false, 'token_form' => true, 'edit_user' => false));
});