Inheritance: extends a
コード例 #1
0
ファイル: prop_ctx.php プロジェクト: badlamer/hhvm
function main()
{
    $b = new b();
    $b->f($b);
    t::f($b);
    $b->set($b, 'new value');
    t::set($b, 'newer value');
    $a = new a();
    $a->f($a);
    t::f($a);
}
コード例 #2
0
ファイル: controller.php プロジェクト: boltphp/core
 public function view($file, $vars = [], $paths = [])
 {
     // loop through vars and
     // print our params
     foreach ($this->_parameters as $key => $value) {
         if (!array_key_exists($key, $vars)) {
             $vars[$key] = $value;
         }
     }
     if (!is_array($paths)) {
         $paths = [];
     }
     // paths to find
     $paths += $this->parent('bolt\\browser')->path('views');
     // find this template
     $find = new Finder();
     $base = pathinfo($file)['dirname'];
     $name = pathinfo($file)['basename'];
     // loop through each path
     foreach ($paths as $path) {
         $files = $find->files()->in(b::path($path, $base))->name($name);
         if (iterator_count($files)) {
             $it = iterator_to_array($files);
             $first = array_shift($it);
             return new view(['file' => $first->getRealPath(), 'vars' => $vars, 'context' => $this, 'helpers' => []]);
         }
     }
     // nope
     return false;
 }
コード例 #3
0
ファイル: render.php プロジェクト: boltphp/core
 public static function setEngine($ext, $ref)
 {
     if (is_string($ref)) {
         $ref = b::getReflectionClass($ref);
     }
     self::$engines[$ext] = $ref;
 }
コード例 #4
0
ファイル: element.php プロジェクト: boltphp/core
 public function __construct($dom, $node = false)
 {
     $this->_dom = $dom;
     $this->_node = $node;
     $this->_guid = b::guid("domref");
     $this->attr('data-domref', $this->_guid);
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: boltphp/core
 public function isInterfaceOf($obj, $class)
 {
     if (!is_object($obj)) {
         return false;
     }
     return in_array(b::normalizeClassName($class), class_implements($obj));
 }
コード例 #6
0
ファイル: a.php プロジェクト: boltphp/core
 public function get($key, $default = null)
 {
     if (!is_numeric($key)) {
         $key = '[' . trim(str_replace('.', '][', $key), '[]') . ']';
     }
     $value = $this->_access->getValue($this->_value, $key);
     return b::bucket('create', $value ?: $default);
 }
コード例 #7
0
ファイル: CouldBePrivate.02.php プロジェクト: exakat/exakat
 function ab()
 {
     $this->aprotectedButReally = $this->apublic + $this->aprivate;
     $a->aprotectedButReally = 1;
     self::$asprotectedButSBPrivateSelf = 1;
     static::$asprotectedButSBPrivateStatic = 2;
     \a::$asprotectedButSBPrivateFull = 3;
     \b::$asprotectedButSBPrivateChildren = 3;
 }
コード例 #8
0
 function f()
 {
     self::nonStaticButSelfClass();
     static::nonStaticButSelfClass();
     parent::nonStaticButSelfClass();
     P::nonStaticAClass();
     P::staticAClass();
     A1::nonStaticButSelfClass();
     \a1::nonStaticButSelfClass();
     b::nonStaticButSelfClass();
 }
コード例 #9
0
ファイル: middleware.php プロジェクト: boltphp/core
 public final function matchRoute(\bolt\browser\route $route, \bolt\browser\request $req)
 {
     $collection = b::browser('route\\collection\\create', [$route]);
     $match = new UrlMatcher($collection, $req->getContext());
     // we're going to try and match our request
     // if not we fall back to error
     try {
         return $match->matchRequest($req);
     } catch (ResourceNotFoundException $e) {
         return false;
     }
 }
コード例 #10
0
ファイル: collection.php プロジェクト: boltphp/core
 public static function fromControllers(\bolt\browser\route\collection $collection)
 {
     $routes = [];
     // get all loaded classes
     if (($classes = b::getClassImplements('\\bolt\\browser\\route\\face')) != false) {
         foreach ($classes as $class) {
             if ($class->name === 'bolt\\browser\\controller' or !$class->hasProperty('routes') and !$class->hasMethod('getRoutes')) {
                 continue;
             }
             // skip our controller class and make sure we have at least $routes || getRoutes()
             $_ = ['ref' => $class, 'collection' => $class->hasProperty('routeCollection') ? $class->getStaticPropertyValue('routeCollection') : ['prefix' => ''], 'routes' => []];
             if ($class->hasProperty('routes')) {
                 $_['routes'] = array_merge($_['routes'], $class->getStaticPropertyValue('routes'));
             }
             if ($class->hasMethod('getRoutes')) {
                 $name = $class->name;
                 $_['routes'] = array_merge($_['routes'], $name::getRoutes());
             }
             $routes[] = $_;
         }
     }
     foreach ($routes as $class) {
         $c = new collection();
         // loop through routes
         foreach ($class['routes'] as $key => $route) {
             $name = b::param('name', false, $route);
             if (!$name and !is_string($key)) {
                 $name = "route" . rand(9, 999);
             } else {
                 if (!$name) {
                     $name = $key;
                 }
             }
             // no name
             unset($route['name']);
             // add our two default things
             $route['controller'] = $class['ref']->name;
             $route['action'] = b::param('action', false, $route);
             // loop through each part and set it
             $c->add($name, b::browser_route('create', $route));
         }
         // get our prefix vars
         extract(array_merge(['prefix' => '', 'requirements' => [], 'options' => [], 'host' => false, 'schemes' => []], $class['collection']), EXTR_OVERWRITE);
         // set prefix
         $c->addPrefix($prefix, $requirements, $options, $host, $schemes);
         // add this collection
         $collection->addCollection($c);
     }
     return null;
 }
コード例 #11
0
ファイル: AccessPrivate.01.php プロジェクト: exakat/exakat
 function __construct()
 {
     a::y();
     b::y();
     c::y();
     d::y();
     a::$x;
     b::$x;
     c::$x;
     d::$x;
     a::$xpr;
     b::$xpr;
     c::$xpr;
     d::$xpr;
 }
コード例 #12
0
ファイル: engine.php プロジェクト: boltphp/core
 public static function collect()
 {
     // collect all engines
     if (($engines = b::getClassImplements('\\bolt\\render\\engine\\face')) != false) {
         foreach ($engines as $class) {
             if ($class->name === 'bolt\\render\\engine\\base') {
                 continue;
             }
             $ext = $class->getConstant('EXT');
             if (!b::render('hasEngine', $ext)) {
                 b::render('setEngine', $ext, $class);
             }
         }
     }
 }
コード例 #13
0
ファイル: assetsTest.php プロジェクト: boltphp/core
 public function test_devModeFilter()
 {
     if (!class_exists('lessc')) {
         $this->markTestSkipped('LessPHP is not installed');
     }
     b::env('dev');
     // we need out less filter
     $this->a->filter('less', 'Lessphp');
     $this->a->filter('*', 'CssMin', false);
     $file = b::path($this->dir, 'less/file.less');
     $exp = "footer {\n  background: green;\n}\n" . "body header {\n  background: red;\n}";
     $this->assertEquals($exp, $this->a->processFile($file));
     b::env('prod');
     $exp = "footer{background:green}" . "body header{background:red}";
     $this->assertEquals($exp, $this->a->processFile($file));
 }
コード例 #14
0
ファイル: manager.php プロジェクト: boltphp/core
 public function __construct($config)
 {
     // set our source
     $this->_source = $config['source'];
     // handle
     $handle = $this->_source->getHandle();
     // configure
     $cfg = new Configuration();
     // set
     $cfg->setMetadataDriverImpl(new driver($this));
     $cfg->setProxyDir($config['tmp']);
     $cfg->setProxyNamespace('bolt\\model\\proxy');
     // create our entity manager
     $this->_em = EntityManager::create($handle, $cfg, $handle->getEventManager());
     // find all of our defined entities
     foreach (b::getClassExtends('\\bolt\\model\\entity') as $class) {
         $this->add($class->getConstant('NAME'), $class->name);
     }
 }
コード例 #15
0
ファイル: assets.php プロジェクト: boltphp/core
 public function handle($req, $res)
 {
     $route = b::browser('route\\create', ['path' => $this->config->value('route', '/a/{path}'), 'require' => ['path' => '.*']]);
     // match a route
     if (($params = $this->matchRoute($route, $req)) === false) {
         return false;
     }
     // content
     $content = "";
     // paths
     $paths = $req->assets->getDirs();
     // explode out the path
     foreach (explode('&', $params['path']) as $path) {
         $info = pathinfo($path);
         // get our path
         $dir = $info['dirname'];
         $file = $info['basename'];
         $ext = $info['extension'];
         // find this template
         $find = new Finder();
         // loop through each path
         foreach ($paths as $path) {
             // find the files
             $files = $find->files()->in(b::path($path, $dir))->name($file);
             if (iterator_count($files)) {
                 $it = iterator_to_array($files);
                 $first = array_shift($it);
                 $real = $first->getRealPath();
                 // rel
                 $rel = str_replace($path, '', $real);
                 // process a file and append it's content
                 $content .= \bolt\browser\assets::instance()->processFile($real, ['rel' => $rel, 'url' => 'http://localhost/' . str_replace('{path}', '', $route->getPath()), 'filterOnly' => $req->query->get('filterOnly')]);
             }
         }
     }
     // figureo ut
     $res->headers->set('Content-Type', $this->_mapContentTypeFromExt($ext));
     // set our content
     $res->setContent($content);
     return $res;
 }
コード例 #16
0
ファイル: route.php プロジェクト: boltphp/core
 public function build($params = [])
 {
     // what method
     $method = $this->request->getMethod();
     // is there an action
     $action = b::param('_action', false, $params);
     // lets figure out what function we're going to call
     $try = ['dispatch', "{$method}{$action}", $action, $method];
     foreach ($try as $func) {
         if (method_exists($this, $func)) {
             break;
         }
     }
     // reflect the controller and method
     // and figure out what params we need
     $ref = b::getReflectionClass(get_called_class());
     // get
     $args = $this->getArgsFromMethodRef($ref->getMethod($func), $params);
     // wonderfull, lets call the function and figure out what
     // they respond with
     return call_user_func_array([$this, $func], $args);
 }
コード例 #17
0
<?php

spl_autoload_register(function ($classname) {
    if (in_array($classname, array('a', 'b', 'c'))) {
        require_once __DIR__ . "/{$classname}.php";
    }
});
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
}, error_reporting());
a::staticTest();
$b = new b();
$b->test();
コード例 #18
0
ファイル: view.php プロジェクト: boltphp/core
 public function render()
 {
     // render
     $str = b::render('file', $this->_file, ['context' => $this->_context, 'vars' => $this->_vars]);
     return $str;
 }
コード例 #19
0
ファイル: bolt.php プロジェクト: boltphp/core
function b()
{
    return b::instance();
}
コード例 #20
0
ファイル: bug48215_2.php プロジェクト: badlamer/hhvm
 function C()
 {
     b::b();
 }
コード例 #21
0
ファイル: Staticmethodcall.03.php プロジェクト: exakat/exakat
<?php

$a = b::c() * 2;
$a = b::c() + 2;
$a = b::c() / 2;
$a = b::c() % 2;
コード例 #22
0
ファイル: static.php プロジェクト: reneolivo/PHP-Toolkit
<?php

class a
{
    public static $var;
    public function a($var)
    {
        self::$var = $var;
    }
    public function ret()
    {
        return self::$var;
    }
}
class b extends a
{
    public static $var;
}
class c extends a
{
}
$a = new a('-a-');
$a2 = new a('-a2-');
$b = new b('-b-');
$c = new c('-c-');
b::$var = 'b';
echo 'A: ' . a::$var;
echo 'A2: ' . $a2::$var;
echo ', B: ' . b::$var;
echo ', C: ' . c::$var;
コード例 #23
0
ファイル: fwd.php プロジェクト: badlamer/hhvm
<?php

function fiz($a)
{
    var_dump($a);
}
class a
{
    static function __callStatic($n, $a)
    {
        return $a[0];
    }
}
class b extends a
{
    static function bar()
    {
        fiz(parent::foo(42));
    }
}
b::bar();
コード例 #24
0
 function __construct()
 {
     b::b();
 }
コード例 #25
0
ファイル: Staticmethodcall.04.php プロジェクト: exakat/exakat
<?php

$a = -b::c();
コード例 #26
0
<?php

b::a();
b::d();
b::e();
E::a();
E::d();
E::e();
\E::a();
\E::d();
\E::e();
class b
{
    public function a()
    {
    }
    public static function d()
    {
    }
    public function e()
    {
    }
}
class E
{
    public static function a()
    {
    }
    public static function d()
    {
    }
コード例 #27
0
ファイル: test2.php プロジェクト: reneolivo/PHP-Toolkit
 public function b($a)
 {
     self::$a = $a;
 }
コード例 #28
0
ファイル: t.php プロジェクト: eaglewu/evenement
<?php

trait a
{
    protected $listeners;
    public function on()
    {
        $this->listeners = [123];
        return $this->listeners;
    }
}
class b
{
    use a;
}
$b = new b();
var_dump($b->on());
class event
{
    use \Evenement\EventEmitterTrait;
}
$event = new event();
var_dump($event);
$event->on('key1', function ($msg) {
    echo "key1 event: \n";
    var_dump($msg);
});
$event->on('key2', function ($val) {
    return $val + 1;
});
class env
コード例 #29
0
{
    public $x = 2;
    function y()
    {
        SELF::definedInParent();
        SELF::definedInParentParent();
        SELF::undefined();
        SELF::definedinStatic();
        SELF::$pdefinedInParent;
        SELF::$pdefinedInParentParent;
        SELF::$pundefined;
        SELF::$pdefinedinStatic;
    }
    function definedinStatic()
    {
        print __METHOD__ . "\n";
    }
    private $pdefinedinStatic;
}
class c
{
    private $x = 1;
    function definedInParentParent()
    {
        print __METHOD__ . "\n";
    }
    private $pdefinedInParentParent;
}
$b = new b();
//print a::$x
print $b->y();
コード例 #30
0
ファイル: assets.php プロジェクト: boltphp/core
 public function processDirTree($path, $ext)
 {
     $files = b::getRegexFiles($path, "^.+\\.{$ext}\$");
     $tree = [];
     foreach ($files as $file) {
         $tree[$file] = $this->processFileTree($this->getFile($file), $ext);
     }
     return $tree;
 }