当前位置: 首页>>代码示例>>PHP>>正文


PHP static类代码示例

本文整理汇总了PHP中static的典型用法代码示例。如果您正苦于以下问题:PHP static类的具体用法?PHP static怎么用?PHP static使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了static类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: withoutOrders

 /**
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public static function withoutOrders()
 {
     $instance = new static();
     $query = $instance->newQuery();
     $query->getQuery()->orders = [];
     return $query;
 }
开发者ID:GlobalsDD,项目名称:admin,代码行数:10,代码来源:SleepingOwlModel.php

示例2: fetch

 /**
  * Retrieves all Hail Api Object of a specific type
  *
  * @return void
  */
 public static function fetch()
 {
     try {
         $list = HailApi::getList(static::getObjectType());
     } catch (HailApiException $ex) {
         Debug::warningHandler(E_WARNING, $ex->getMessage(), $ex->getFile(), $ex->getLine(), $ex->getTrace());
         die($ex->getMessage());
         return;
     }
     $hailIdList = array();
     foreach ($list as $hailData) {
         // Check if we can find an existing item.
         $hailObj = static::get()->filter(array('HailID' => $hailData->id))->First();
         if (!$hailObj) {
             $hailObj = new static();
         }
         $result = $hailObj->importHailData($hailData);
         if ($result) {
             //Build up Hail ID list
             $hailIdList[] = $hailData->id;
         }
     }
     //Remove all object for which we don't have reference
     static::get()->exclude('HailID', $hailIdList)->removeAll();
 }
开发者ID:firebrandhq,项目名称:silverstripe-hail,代码行数:30,代码来源:HailApiObject.php

示例3: build

 /**
  * @param $key
  * @param $value
  *
  * @return static
  */
 public static function build($key, $value)
 {
     $EnvironmentVariable = new static();
     $EnvironmentVariable->setKey($key);
     $EnvironmentVariable->setValue($value);
     return $EnvironmentVariable;
 }
开发者ID:allansun,项目名称:docker-cloud-php-api,代码行数:13,代码来源:EnvironmentVariable.php

示例4: createCollection

 /**
  * Creates collection of items.
  *
  * Override it if you need to implement
  * derived collection that requires specific initialization.
  *
  * @param array $items
  *
  * @return static
  */
 protected function createCollection(array $items)
 {
     $collection = new static();
     $itemsRef =& $collection->items();
     $itemsRef = $items;
     return $collection;
 }
开发者ID:nayjest,项目名称:collection,代码行数:17,代码来源:CollectionReadTrait.php

示例5: getInstance

 /**
  * Get instance 
  *
  * @return static
  */
 public static function getInstance()
 {
     if (!static::$instance instanceof static) {
         static::$instance = new static();
     }
     return static::$instance->getConnection();
 }
开发者ID:dilbadil,项目名称:phpbridge,代码行数:12,代码来源:Db.php

示例6: simpleInvoke

 /**
  * 
  * @param type $array
  * @param type $throw
  * @return \storm\actions\IntentPayload
  */
 public static function simpleInvoke($array = [], $throw = true)
 {
     $action = new static();
     $payload = new IntentPayload($array);
     $action->invoke($payload, $throw);
     return $payload;
 }
开发者ID:projectstorm,项目名称:php-actions,代码行数:13,代码来源:Action.php

示例7: replaceFacet

 /**
  * Remove any instance of the facet from the parameters and add a new one.
  *
  * @param string $field    Facet field
  * @param string $value    Facet value
  * @param string $operator Facet type to add (AND, OR, NOT)
  *
  * @return string
  */
 public function replaceFacet($field, $value, $operator = 'AND')
 {
     $newParams = clone $this->params;
     $newParams->removeAllFilters($field);
     $helper = new static($newParams);
     return $helper->addFacet($field, $value, $operator);
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:16,代码来源:UrlQueryHelper.php

示例8: __callStatic

 /**
  * Handle dynamic static method calls into the method.
  *
  * @param  string $method
  * @param  array $parameters
  * @return mixed
  */
 public static function __callStatic($method, $parameters)
 {
     $instance = new static();
     $class = get_class($instance->getModel());
     $model = new $class();
     return call_user_func_array([$model, $method], $parameters);
 }
开发者ID:yajra,项目名称:cms-core,代码行数:14,代码来源:RepositoryAbstract.php

示例9: register

 public static function register($data)
 {
     static::$error = false;
     $user = new static();
     if (!$user->set($data)->success()) {
         static::$error = 'REGISTER_VALIDATION_FALSE';
         return false;
     }
     $login = isset($data[static::ROW_LOGIN]) ? $data[static::ROW_LOGIN] : '';
     if (!$login) {
         static::$error = 'REGISTER_NO_LOGIN';
         return false;
     }
     $found = static::findBy(static::ROW_LOGIN, $login)->getFirst();
     if ($found) {
         static::$error = 'REGISTER_DUBLICATE_USER';
         return false;
     }
     $password = isset($data[static::ROW_PASSWORD]) ? $data[static::ROW_PASSWORD] : '';
     if (!$password) {
         static::$error = 'REGISTER_NO_PASSWORD';
         return false;
     }
     $user->{static::ROW_HASH_RESTORE} = static::makeHash();
     $user->save();
     return $user;
 }
开发者ID:smoren,项目名称:mushroom-framework,代码行数:27,代码来源:User.php

示例10: find

 /**
  * Queries the table for the given primary key value ($id).  $id can also
  * contain 2 special values:
  *
  * <ul>
  * <li>'all' - Will return all of the records in the table</li>
  * <li>'first' - Will return the first record.  This will set automatically
  * set the 'limit' option to 1.</li>
  * </ul>
  *
  * The following options are available to use in the $options parameter:
  *
  * <ul>
  * <li>include - an array of associations to include in the query.  Example:
  * <code>array('group', 'posts')</code></li>
  * <li>select - an array of columns to select (defaults to '*').  Example:
  * <code>array('first_name', 'last_name')</code></li>
  * <li>limit - the maximum number of records to fetch</li>
  * <li>offset - the offset to start from</li>
  * <li>order - an array containing the ORDER BY clause.  Example:
  * <code>array('last_name', 'ASC')</code></li>
  * <li>where - an array of arrays containing the where clauses.  Example:
  * <code>array(array('enabled', '=', 1), array('blacklisted', '=', 0))</code>
  * <li>or_where - identical to 'where' except these are OR WHERE statements.</li>
  *
  * Usage:
  *
  * <code>$user = User::find(2, array('include' => array('group')));</code>
  *
  * @param	int|string	$id			the primary key value
  * @param	srray		$options	the find options
  * @return	object		the result
  */
 public static function find($id = 'all', $options = array())
 {
     $instance = new static();
     $results = $instance->run_find($id, $options);
     unset($instance);
     return $results;
 }
开发者ID:netspencer,项目名称:fuel,代码行数:40,代码来源:model.php

示例11: create

 /**
  * Creates token
  * @param string $type Type of the token
  * @param string $name Name of the token unique for selected type
  * @param callable|AlgorithmInterface $algorithm Algorithm of the token generation
  * @param int|\DateTime|Expression $expire Expiration date of the token
  * @return static
  */
 public static function create($type, $name, $algorithm = null, $expire = null)
 {
     if ($algorithm === null) {
         $algorithm = new RandomString();
     }
     $token = static::findOne(['type' => $type, 'name' => $name]);
     if ($token == null) {
         $token = new static();
     }
     $token->type = $type;
     $token->name = $name;
     if (is_callable($algorithm)) {
         $token->token = call_user_func($algorithm);
     } else {
         $token->token = $algorithm->generate();
     }
     if (is_integer($expire)) {
         $token->expire_at = \DateTime::createFromFormat('U', $expire, new \DateTimeZone('UTC'))->setTimezone(new \DateTimeZone('MSK'))->format('Y-m-d H:i:s');
     } elseif ($expire instanceof \DateTime) {
         $token->expire_at = $expire->format('Y-m-d h:i:s');
     } else {
         $token->expire_at = $expire;
     }
     $token->created_at = new Expression('NOW()');
     $token->save(false);
     return $token;
 }
开发者ID:omnilight,项目名称:yii2-tokens,代码行数:35,代码来源:Token.php

示例12: createQuestion

 public function createQuestion(Model $questionable, $data, Model $author)
 {
     $question = new static();
     $question->fill(array_merge($data, ['author_id' => $author->id, 'author_type' => get_class($author)]));
     $questionable->questions()->save($question);
     return $question;
 }
开发者ID:DraperStudio,项目名称:Laravel-Questionable,代码行数:7,代码来源:Question.php

示例13: set_stat

 /**
  * Set an API statistic in the DB
  * 
  * @param int $code		The HTTP status code from the request or cache
  * @param string $uri	The dynamic call URL or the static call name
  * @param string $api	The API to set the stats for
  * 
  * @return bool True if the stat was added/updated successfully, or false if it wasn't.
  */
 public static function set_stat($code, $uri, $api = null, $is_static = null)
 {
     // Save queries if we don't need the stats.
     if (\Config::get('engine.track_usage_stats', false) === false) {
         return true;
     }
     $api_name = $api === null ? \V1\APIRequest::get('api') : $api;
     $is_static = $is_static === null ? \V1\APIRequest::is_static() : $is_static;
     $api = \V1\Model\APIs::get_api($api_name);
     // Do we have a stat entry for this timeframe?
     $existing_api_stats_obj = static::query()->where('apis_id', '=', $api['id'])->where('code', '=', (int) $code)->where('call', '=', $uri)->where('created_at', '>', time() - (int) \Config::get('api_stats_increment', 30) * 60)->get_one();
     // If we have a row, update it.
     if (!empty($existing_api_stats_obj)) {
         $existing_api_stats_obj->count++;
         return $existing_api_stats_obj->save();
     }
     // Add the new entry.
     $api_stats_object = new static();
     $api_stats_object->apis_id = $api['id'];
     $api_stats_object->code = $code;
     $api_stats_object->count = 1;
     $api_stats_object->call = $uri;
     $api_stats_object->is_static = intval($is_static);
     return $api_stats_object->save();
 }
开发者ID:bitapihub,项目名称:api-optimization-engine,代码行数:34,代码来源:apistats.php

示例14: isColumnNullable

 public static function isColumnNullable($column_name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" . $instance->getTable() . "' AND COLUMN_NAME='" . $column_name . "' AND table_schema='" . env('DB_DATABASE') . "'"))[0];
     return $answer->IS_NULLABLE == 'YES' ? true : false;
 }
开发者ID:Ghitu,项目名称:crud,代码行数:7,代码来源:CrudTrait.php

示例15: register

 /**
  * Register the error handler.
  *
  * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable)
  *
  * @return The registered error handler
  */
 public static function register($level = null)
 {
     $handler = new static();
     $handler->setLevel($level);
     set_error_handler(array($handler, 'handle'));
     return $handler;
 }
开发者ID:assistechnologie,项目名称:webui,代码行数:14,代码来源:ErrorHandler.php


注:本文中的static类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。