Exemple #1
0
}
$object = new Foo(array('foo' => 'foo'));
// heating_up
for ($i = 0; $i < 1000; $i++) {
    $object->get('foo');
}
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $object->get('foo');
}
echo "get('foo'): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $object->get('bar');
}
echo "get('bar') => getBar(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $object->getBar();
}
echo "instance getBar(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $object->getFoo();
}
echo "dynamic getFoo(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $object->foo;
}
echo "->foo: " . (microtime(true) - $mark) . "\n";
Exemple #2
0
<?php

/**
 * GitHub Issue:    https://github.com/ejmr/php-mode/issues/53
 *
 * Test if switching from Drupal coding style to other coding styles updates
 * the whitespace effects.
 *
 * This file contains arbitrary PHP code with some whitespace added to the end
 * of some lines.
 *
 */
class Foo
{
    private $bar;
    public function __construct($bar)
    {
        $this->bar = $bar;
    }
    public function getBar()
    {
        // here is the whitespace
        return $this->bar;
    }
}
$foo = new Foo('bar');
$bar = $foo->getBar();