當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Func::getContext方法代碼示例

本文整理匯總了PHP中Func::getContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP Func::getContext方法的具體用法?PHP Func::getContext怎麽用?PHP Func::getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Func的用法示例。


在下文中一共展示了Func::getContext方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $Boolean = new Func(function ($value = false) {
         $self = Func::getContext();
         if ($self instanceof Bln) {
             $self->value = $value ? true : false;
             return $self;
         } else {
             return $value ? true : false;
         }
     });
     $Boolean->instantiate = function () {
         return new Bln();
     };
     $Boolean->set('prototype', Bln::$protoObject);
     $Boolean->setMethods(Bln::$classMethods, true, false, true);
     return $Boolean;
 }
開發者ID:mk-pmb,項目名稱:js2php,代碼行數:22,代碼來源:Boolean.php

示例2: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $String = new Func(function ($value = '') {
         $self = Func::getContext();
         if ($self instanceof Str) {
             $self->value = to_string($value);
             return $self;
         } else {
             return to_string($value);
         }
     });
     $String->instantiate = function () {
         return new Str();
     };
     $String->set('prototype', Str::$protoObject);
     $String->setMethods(Str::$classMethods, true, false, true);
     return $String;
 }
開發者ID:mk-pmb,項目名稱:js2php,代碼行數:22,代碼來源:String.php

示例3: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $Number = new Func(function ($value = 0) {
         $self = Func::getContext();
         if ($self instanceof Number) {
             $self->value = to_number($value);
             return $self;
         } else {
             return to_number($value);
         }
     });
     $Number->instantiate = function () {
         return new Number();
     };
     $Number->set('prototype', Number::$protoObject);
     $Number->setMethods(Number::$classMethods, true, false, true);
     //constants
     $Number->set('NaN', NAN);
     $Number->set('MAX_VALUE', INF);
     $Number->set('MIN_VALUE', -INF);
     $Number->set('NEGATIVE_INFINITY', -INF);
     $Number->set('POSITIVE_INFINITY', INF);
     return $Number;
 }
開發者ID:mk-pmb,項目名稱:js2php,代碼行數:28,代碼來源:Number.php

示例4: array

Date::$classMethods = array('now' => function () {
    return Date::now();
}, 'parse' => function ($str) {
    $date = new Date($str);
    return $date->value;
}, 'UTC' => function () {
    $date = new Date();
    $date->_initFromParts(func_get_args(), 'UTC');
    return $date->value;
});
Date::$protoMethods = array('valueOf' => function () {
    $self = Func::getContext();
    return $self->value;
}, 'toJSON' => function () {
    $self = Func::getContext();
    //2014-08-09T12:00:00.000Z
    return $self->toJSON();
}, 'toUTCString' => function () {
    //todo
}, 'toString' => function () {
    $self = Func::getContext();
    //Sat Aug 09 2014 12:00:00 GMT+0000 (UTC)
    return str_replace('~', 'GMT', $self->date->format('D M d Y H:i:s ~O (T)'));
});
Date::$protoObject = new Object();
Date::$protoObject->setMethods(Date::$protoMethods, true, false, true);
//get the local timezone by looking for constant or environment variable; default to UTC
Date::$LOCAL_TZ = defined('LOCAL_TZ') ? constant('LOCAL_TZ') : getenv('LOCAL_TZ');
if (Date::$LOCAL_TZ === false) {
    Date::$LOCAL_TZ = 'UTC';
}
開發者ID:mk-pmb,項目名稱:js2php,代碼行數:31,代碼來源:Date.php

示例5: array

            $methods['defineProperty']($obj, $key, $prop->value);
        }
    }
});
Object::$protoMethods = array('hasOwnProperty' => function ($key) {
    $self = Func::getContext();
    $key = (string) $key;
    return array_key_exists($key, $self->data);
}, 'toString' => function () {
    $self = Func::getContext();
    if ($self === null) {
        $className = 'Undefined';
    } else {
        if ($self === Object::$null) {
            $className = 'Null';
        } else {
            $obj = objectify($self);
            $className = $obj->className;
        }
    }
    return '[object ' . $className . ']';
}, 'valueOf' => function () {
    return Func::getContext();
});
class Null
{
}
Object::$null = new Null();
//the methods are not set on Object.prototype until *after* Func class is defined
Object::$protoObject = new Object();
Object::$protoObject->proto = Object::$null;
開發者ID:mk-pmb,項目名稱:js2php,代碼行數:31,代碼來源:Object.php


注:本文中的Func::getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。