• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_called_class函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     if (!self::$timing) {
         echo "\n";
         return;
     }
     $class = get_called_class();
     echo "Timing results : {$class}\n";
     $s = sprintf("%40s %6s %9s %9s %4s\n", 'name', 'count', 'total', 'avg', '% best');
     echo str_repeat('=', strlen($s)) . "\n";
     echo $s;
     echo str_repeat('-', strlen($s)) . "\n";
     array_walk(self::$timing, function (&$value, $key) {
         $value['avg'] = round($value['total'] / $value['count'] * 1000000, 3);
     });
     usort(self::$timing, function ($a, $b) {
         $at = $a['avg'];
         $bt = $b['avg'];
         return $at === $bt ? 0 : ($at < $bt ? -1 : 1);
     });
     $best = self::$timing[0]['avg'];
     foreach (self::$timing as $timing) {
         printf("%40s %6d %7.3fms %7.3fus %4.1f%%\n", $timing['name'], $timing['count'], round($timing['total'] * 1000, 3), $timing['avg'], round($timing['avg'] / $best * 100, 3));
     }
     echo str_repeat('-', strlen($s)) . "\n\n";
     printf("\nTiming compensated for avg overhead for: timeIt of %.3fus and startTimer/endTimer of %.3fus per invocation\n\n", self::$timeItOverhead * 1000000, self::$startEndOverhead * 1000000);
     parent::tearDownAfterClass();
 }
开发者ID:mean-cj,项目名称:laravel-translation-manager,代码行数:28,代码来源:TranslationManagerTestCase.php


示例2: validateField

 public function validateField(Structure $document, $fieldName, array $params)
 {
     $value = $document->get($fieldName);
     if (!$value) {
         return;
     }
     if (empty($params[0])) {
         throw new Exception('Type not specified');
     }
     $requiredTypes = (array) $params[0];
     $allowedTypes = array('array', 'bool', 'callable', 'double', 'float', 'int', 'integer', 'long', 'null', 'numeric', 'object', 'real', 'resource', 'scalar', 'string');
     foreach ($requiredTypes as $type) {
         if (!in_array($type, $allowedTypes)) {
             throw new Exception('Type must be one of ' . implode(', ', $allowedTypes));
         }
         if (true === call_user_func('is_' . $type, $value)) {
             return;
         }
     }
     if (!isset($params['message'])) {
         if (count($requiredTypes) === 1) {
             $params['message'] = 'Field "' . $fieldName . '" must be of type ' . $requiredTypes[0] . ' in ' . get_called_class();
         } else {
             $params['message'] = 'Field "' . $fieldName . '" must be one of types ' . implode(', ', $requiredTypes) . ' in ' . get_called_class();
         }
     }
     $document->addError($fieldName, $this->getName(), $params['message']);
 }
开发者ID:sokil,项目名称:php-mongo,代码行数:28,代码来源:TypeValidator.php


示例3: crossover

 public function crossover($partner, $options = array())
 {
     $a = $partner->get_data();
     $b = $this->data;
     $a_c = strlen($a);
     $b_c = strlen($b);
     $c = '';
     $c_c = $a_c >= $b_c ? $a_c : $b_c;
     // if it has same length, great!, use std algorithm
     if ($a_c == $b_c) {
         $left = mt_rand(0, 1) == 1 ? $a : $b;
         $right = $left == $b ? $a : $b;
         $sp = mt_rand(0, $c_c);
         $c .= substr($left, 0, $sp);
         $c .= substr($right, $sp);
     } else {
         /*
          * put shorter chromosome, in longer chromosome
          * example:
          *   a: aaaa
          *   b: bb
          *   result: aabb OR abba OR bbaa
          * */
         $longer = $c_c == $a_c ? 'a' : 'b';
         $shorter = $longer == 'b' ? 'a' : 'b';
         $sp_begin = mt_rand(0, ${$longer . '_c'} - ${$shorter . '_c'});
         $tmp = substr_replace(${$longer}, ${$shorter}, -$sp_begin);
         $c .= $tmp . substr(${$longer}, strlen($tmp));
     }
     $class_name = get_called_class();
     return new $class_name($c);
 }
开发者ID:ryanhs,项目名称:genetic-algorithm-toolkit,代码行数:32,代码来源:SimpleStringStd.php


示例4: getFieldByName

 /**
  * @param $name
  *
  * @return mixed
  * @throws FieldNotFoundException
  */
 public function getFieldByName($name)
 {
     if (!isset($this->fields[$name])) {
         throw new FieldNotFoundException($name . ' doesn\'t exist in this ' . get_called_class());
     }
     return $this->fields[$name];
 }
开发者ID:bluedogtraining,项目名称:avetmiss,代码行数:13,代码来源:Fieldset.php


示例5: __construct

 public function __construct(HTTPRequest $httpRequest, HTTPResponse $httpResponse, Logger $logger)
 {
     $this->httpRequest = $httpRequest;
     $this->httpResponse = $httpResponse;
     $this->logger = $logger;
     $this->entity = get_called_class();
 }
开发者ID:dmeikle,项目名称:gossamerCMS-application,代码行数:7,代码来源:AbstractModel.php


示例6: __construct

 /**
  * Constructor.
  * Accepts an object, array, or JSON string.
  *
  * @param mixed $in -OPTIONAL
  */
 public function __construct($in = null)
 {
     $this->_called_class = get_called_class();
     $this->_class_vars = get_class_vars($this->_called_class);
     //	remove elements with names starting with underscore
     foreach ($this->_class_vars as $k => $v) {
         if ($k[0] === '_') {
             unset($this->_class_vars[$k]);
         } elseif (is_string($v) && 0 === stripos($v, '__class__')) {
             //	We must use `eval` because we want to handle
             //		'__class__Date' and
             //		'__class__DateTime("Jan 1, 2015")' with 1 or more parameters.
             $this->_class_vars[$k] = eval(preg_replace('/^__class__(.*)$/iu', 'return new $1;', $v));
             //	Objects are always passed by reference,
             //		but we want a separate copy so the original stays unchanged.
             $this->{$k} = clone $this->_class_vars[$k];
         }
     }
     $this->_public_names = array_keys($this->_class_vars);
     //	Don't waste time with assignObject if input is one of these.
     //		Just return leaving the default values.
     switch (gettype($in)) {
         case 'NULL':
         case 'null':
         case 'bool':
         case 'boolean':
             return;
     }
     $this->assignObject($in);
 }
开发者ID:diskerror,项目名称:typed,代码行数:36,代码来源:TypedClass.php


示例7: getTemplateFileFormatter

 /**
  * @return ITemplateFileFormatter
  * @throws InvalidStateException
  */
 public function getTemplateFileFormatter()
 {
     if ($this->templateFileFormatter === NULL) {
         throw new InvalidStateException(sprintf('Template file formatter was not set. Did you forget to call %s::injectTemplateFileFormatter()?', get_called_class()));
     }
     return $this->templateFileFormatter;
 }
开发者ID:rebendajirijr,项目名称:themed,代码行数:11,代码来源:TTemplateFileFormatterAware.php


示例8: model

 /**
  * Returns the static model of the specified AR class.
  *
  * @param string $className
  * @return YdActiveRecord the static model class
  */
 public static function model($className = null)
 {
     if (!$className) {
         $className = get_called_class();
     }
     return parent::model($className);
 }
开发者ID:cornernote,项目名称:yii-dressing,代码行数:13,代码来源:YdActiveRecord.php


示例9: __callStatic

 /**
  * Magic method run protected/private static methods.
  *
  * @param string $name The called method name.
  * @param array $arguments Array of arguments.
  */
 public static function __callStatic($name, $arguments)
 {
     $class = get_called_class();
     if (method_exists($class, $name)) {
         return forward_static_call_array([$class, $name], $arguments);
     }
 }
开发者ID:pdyn,项目名称:template,代码行数:13,代码来源:HtmlTemplateTest.php


示例10: organize

 public function organize(&$baseCvmp, &$ignoreVMs = [], $isMainInteration = true)
 {
     $class = get_called_class();
     $pareto = [];
     if (count($ignoreVMs) >= $baseCvmp['nvms'] or $class::$stop) {
         return $baseCvmp;
     }
     //Select Lower VM from the Rank
     $lowVM = $this->selectLowerVm($baseCvmp, $ignoreVMs);
     //generateCVMP
     $cvmps = $this->generateCVMP($baseCvmp, $lowVM);
     //foreach Possible CVMP
     $ignoreVMs[$lowVM] = $lowVM;
     foreach ($cvmps as $key => $cvmp) {
         Counter::$scenarios++;
         if (!$class::$stop and $this->isNonDominanted($baseCvmp, $cvmp)) {
             Counter::$pareto++;
             $pareto[] = $this->organize($cvmp, $ignoreVMs, false);
         }
     }
     //Taking the lowVM putted before
     array_pop($ignoreVMs);
     if (empty($pareto)) {
         Counter::$leaf++;
     }
     $pareto[] = $baseCvmp;
     $sCvmp = $this->getCvmpWithMaxCostBenefit($pareto);
     if ($isMainInteration) {
         $class::updateIgnoreVMs($ignoreVMs, $sCvmp, $lowVM);
         $sCvmp = $this->organize($sCvmp, $ignoreVMs, true);
     }
     return $sCvmp;
 }
开发者ID:arthurd2,项目名称:order-at-cloud,代码行数:33,代码来源:OrderCloud.php


示例11: create

 /**
  * Creates and instance of the mock WebServiceApplicationWeb object.
  *
  * The test can implement the following overrides:
  * - mockAppendBody
  * - mockGetBody
  * - mockPrepentBody
  * - mockSetBody
  *
  * If any *Body methods are implemented in the test class, all should be implemented otherwise behaviour will be unreliable.
  *
  * @param   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     // Collect all the relevant methods in WebServiceApplicationWeb (work in progress).
     $methods = array('allowCache', 'appendBody', 'clearHeaders', 'close', 'execute', 'get', 'getBody', 'getDocument', 'getHeaders', 'getIdentity', 'getLanguage', 'getSession', 'loadConfiguration', 'loadDispatcher', 'loadDocument', 'loadIdentity', 'loadLanguage', 'loadSession', 'prependBody', 'redirect', 'registerEvent', 'sendHeaders', 'set', 'setBody', 'setHeader', 'triggerEvent');
     // Create the mock.
     $mockObject = $test->getMock('WebServiceApplicationWeb', $methods, array(), '', true);
     // Mock calls to JApplicationWeb::getDocument().
     $mockObject->expects($test->any())->method('getDocument')->will($test->returnValue(TestMockDocument::create($test)));
     // Mock calls to JApplicationWeb::getLanguage().
     $mockObject->expects($test->any())->method('getLanguage')->will($test->returnValue(TestMockLanguage::create($test)));
     // Mock a call to JApplicationWeb::getSession().
     if (isset($options['session'])) {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue($options['session']));
     } else {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue(TestMockSession::create($test)));
     }
     $test->assignMockCallbacks($mockObject, array('appendBody' => array(is_callable(array($test, 'mockAppendBody')) ? $test : get_called_class(), 'mockAppendBody'), 'getBody' => array(is_callable(array($test, 'mockGetBody')) ? $test : get_called_class(), 'mockGetBody'), 'prependBody' => array(is_callable(array($test, 'mockPrependBody')) ? $test : get_called_class(), 'mockPrependBody'), 'setBody' => array(is_callable(array($test, 'mockSetBody')) ? $test : get_called_class(), 'mockSetBody')));
     // Reset the body storage.
     self::$body = array();
     return $mockObject;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:43,代码来源:web.php


示例12: __unset

 public function __unset($name)
 {
     if (!$this->__isset($name)) {
         Exception::error(I18n::__('Property %s->%s does not exist.', get_called_class(), $name));
     }
     unset($this->{$name});
 }
开发者ID:johnstyle,项目名称:sjo,代码行数:7,代码来源:Entity.php


示例13: getAbsoluteTemplatePath

 protected function getAbsoluteTemplatePath($template_path)
 {
     $config = new \Config();
     $class_name = substr(get_called_class(), strrpos(get_called_class(), '\\') + 1);
     $class_name = str_replace('View_', '', $class_name);
     return $config->paths->server_root . '/../Layout/Common/Client/Template/' . implode('/', explode('_', $class_name)) . '.php';
 }
开发者ID:dekmabot,项目名称:dezen-site-blog,代码行数:7,代码来源:Abstract.php


示例14: handleWorkflowMessage

 /**
  * @param WorkflowMessage $workflowMessage
  * @return void
  */
 public function handleWorkflowMessage(WorkflowMessage $workflowMessage)
 {
     if (!MessageNameUtils::isProcessingCommand($workflowMessage->messageName())) {
         $this->workflowEngine->dispatch(LogMessage::logUnsupportedMessageReceived($workflowMessage));
     }
     try {
         if ($workflowMessage->messageType() === MessageNameUtils::COLLECT_DATA) {
             $processingMessage = $this->handleCollectData($workflowMessage);
             if (!$processingMessage instanceof ProcessingMessage) {
                 throw new \RuntimeException(sprintf("%s::handleCollectData method returned %s instead of a ProcessingMessage", get_called_class(), is_object($processingMessage) ? get_class($processingMessage) : gettype($processingMessage)));
             }
         } else {
             if ($workflowMessage->messageType() === MessageNameUtils::PROCESS_DATA) {
                 $processingMessage = $this->handleProcessData($workflowMessage);
                 if (!$processingMessage instanceof ProcessingMessage) {
                     throw new \RuntimeException(sprintf("%s::handleProcessData method returned %s instead of a ProcessingMessage", get_called_class(), is_object($processingMessage) ? get_class($processingMessage) : gettype($processingMessage)));
                 }
             } else {
                 $this->workflowEngine->dispatch(LogMessage::logUnsupportedMessageReceived($workflowMessage));
                 return;
             }
         }
         $this->workflowEngine->dispatch($processingMessage);
         return;
     } catch (\Exception $ex) {
         $this->workflowEngine->dispatch(LogMessage::logException($ex, $workflowMessage));
         return;
     }
 }
开发者ID:prooph,项目名称:processing,代码行数:33,代码来源:AbstractWorkflowMessageHandler.php


示例15: factory

 public static function factory($config = array(), $required = array())
 {
     if (!defined('static::ENDPOINT')) {
         throw new Exception\ServiceEndpointException('A client must have an endpoint');
     }
     $default = array('base_url' => '{scheme}://{domain}/' . static::ENDPOINT);
     $required = array_merge(array('scheme', 'domain', 'base_url'), $required);
     $config = Collection::fromConfig($config, $default, $required);
     $client = new static($config->get('base_url'), $config);
     $refClass = new \ReflectionClass(get_called_class());
     $serviceDefinitionPath = dirname($refClass->getFileName());
     $classNamePieces = explode('\\', get_called_class());
     $serviceDefinitionFile = array_pop($classNamePieces) . '.json';
     switch (true) {
         case is_readable(dirname($serviceDefinitionPath) . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . $serviceDefinitionFile):
             $serviceDefinition = $serviceDefinitionPath . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . $serviceDefinitionFile;
             break;
         case is_readable($serviceDefinitionPath . DIRECTORY_SEPARATOR . $serviceDefinitionFile):
             $serviceDefinition = $serviceDefinitionPath . DIRECTORY_SEPARATOR . $serviceDefinitionFile;
             break;
         default:
             throw new Exception\ClientConfigurationException('A client must have a service definition. Could not read the file "' . $serviceDefinition . '"');
     }
     $description = ServiceDescription::factory($serviceDefinition);
     $client->setDescription($description);
     return $client;
 }
开发者ID:fancyguy,项目名称:guzzle-client,代码行数:27,代码来源:GuzzleClient.php


示例16: extractProperty

 protected static function extractProperty($element, $property)
 {
     if (!is_a($element, get_called_class()) || !property_exists($element, $property)) {
         throw new \InvalidArgumentException('property ' . $property . ' does not exists in class: ' . get_called_class());
     }
     return $element->{$property};
 }
开发者ID:maniaplanet,项目名称:dedicated-server-api,代码行数:7,代码来源:AbstractStructure.php


示例17: start

 /**
  * Starting the error handler
  *
  * @param int $errorLevel
  */
 public static function start($errorLevel = \E_WARNING)
 {
     if (!static::$stack) {
         set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
     }
     static::$stack[] = null;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:12,代码来源:ErrorHandler.php


示例18: fromCommand

 public static function fromCommand(OperationCommand $command)
 {
     $response = json_decode($command->getResponse()->getBody(true), true);
     $class = get_called_class();
     // Cannot do new self() with abstract class
     return new $class($response);
 }
开发者ID:hautelook,项目名称:rabbitmq-api,代码行数:7,代码来源:AbstractRabbitMQModel.php


示例19: create

	/**
	 * Creates and instance of the mock JApplication object.
	 *
	 * @param   TestCase  $test  A test object.
	 * @param   array     $data  Data to prime the cache with.
	 *
	 * @return  object
	 *
	 * @since   12.1
	 */
	public static function create(TestCase $test, $data = array())
	{
		self::$cache = $data;

		// Collect all the relevant methods in JConfig.
		$methods = array(
			'get',
			'store',
		);

		// Create the mock.
		$mockObject = $test->getMock(
			'JCache',
			$methods,
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			false
		);

		$test->assignMockCallbacks(
			$mockObject,
			array(
				'get' => array(get_called_class(), 'mockGet'),
				'store' => array(get_called_class(), 'mockStore'),
			)
		);

		return $mockObject;
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:42,代码来源:cache.php


示例20: instance

 /**
  * Returns the implementation implementation registered with the Facade.
  *
  * @return Xaamin\Whatsapi\Contracts\WhatsapiInterface
  */
 public static function instance()
 {
     if (!static::$instance) {
         static::$instance = forward_static_call_array(array(get_called_class(), 'create'), func_get_args());
     }
     return static::$instance;
 }
开发者ID:shinichi81,项目名称:whatsapi-1,代码行数:12,代码来源:Facade.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_cancel_comment_reply_link函数代码示例发布时间:2022-05-15
下一篇:
PHP get_calendar函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap