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


PHP Type::getName方法代码示例

本文整理汇总了PHP中Type::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::getName方法的具体用法?PHP Type::getName怎么用?PHP Type::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Type的用法示例。


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

示例1: getName

 /**
  * Gets the string representation of this type.
  * If key and value are mixed, "array" is returned.
  * If only key is mixed, "T[]" is returned, where T is the name of the value type.
  * Otherwise, "array<K, V>" is returned, where K is the name of the key type.
  * 
  * @return string The string representation.
  */
 public function getName(array $options = array())
 {
     if ($this->keyType === Type::ofMixed()) {
         if ($this->itemType === Type::ofMixed()) {
             return "array";
         }
         return $this->itemType->getName() . "[]";
     }
     return "array<" . $this->keyType->getName() . "," . $this->itemType->getName() . ">";
 }
开发者ID:Kaemmelot,项目名称:php-type-reflection,代码行数:18,代码来源:ArrayType.php

示例2: findByOwnerAndFilterWithPercents

 /**
  * Metodo que calcula el porcentaje de los tipos de gasto del usuario pasado
  * como parametro en funcion del rango de fechas pasado como parametro.
  * Para realizar el calculo, primero obtiene todos los gastos y la cantidad
  * numerica de gasto que representan. Despues se invoca a un metodo privado
  * para conocer el total de gasto del usuario y se calculan los porcentajes
  * de cada tipo de gasto. Finalmente, se crea un tipo de gasto especial que
  * representa el porcentaje de gasto de aquellos gastos que no tengan ningun
  * tipo de gasto asignado.
  */
 public function findByOwnerAndFilterWithPercents($owner, $startDate, $endDate)
 {
     $stmt = $this->db->prepare("SELECT SUM(s.quantity) as 'spending.quantity',\n                t.idType as 'type.id',\n                t.name as 'type.name'\n        FROM SPENDING s LEFT JOIN TYPE_SPENDING ts  ON s.idSpending = ts.spending LEFT JOIN TYPE t on ts.type = t.idType\n        WHERE s.owner = ?  AND s.dateSpending BETWEEN ? AND ? AND ts.spending IS NOT NULL GROUP BY ts.type");
     $stmt->execute(array($owner, $startDate, $endDate));
     $types_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if (sizeof($types_db)) {
         $total = $this->getTotal($owner, $startDate, $endDate);
         $types = [];
         foreach ($types_db as $type_loop) {
             $type = new Type();
             $type->setName($type_loop['type.name']);
             $percent = $type_loop["spending.quantity"] * 100 / $total;
             array_push($types, array("typename" => $type->getName(), "percent" => round($percent, 2), "total" => (double) $type_loop["spending.quantity"]));
         }
         $totalWithoutType = $this->getTotalSpendingsWithoutType($owner, $startDate, $endDate);
         if ($totalWithoutType != 0) {
             $percentSpecialType = $totalWithoutType * 100 / $total;
             $specialType = new Type();
             $specialType->setName("Without category");
             array_push($types, array("typename" => $specialType->getName(), "percent" => round($percentSpecialType, 2), "total" => (double) $totalWithoutType));
         }
         return $types;
     } else {
         return NULL;
     }
 }
开发者ID:adri229,项目名称:wallas,代码行数:36,代码来源:TypeDAO.php

示例3: isInstanceOf

 /**
  * @param Type $OtherType
  * @return bool
  */
 public function isInstanceOf(Type $OtherType)
 {
     $thisTypeName = $this->getName();
     $otherTypeName = $OtherType->getName();
     if ($thisTypeName === $otherTypeName) {
         return true;
     }
     return (new \ReflectionClass($thisTypeName))->isSubclassOf($otherTypeName);
 }
开发者ID:tueena,项目名称:core,代码行数:13,代码来源:Type.php

示例4: store

 /**
  * @param Type $type
  *
  * @return string
  * @throws exceptions\DBDuplicateEntryException
  * @throws exceptions\DBForeignKeyException
  */
 public function store(Type $type)
 {
     $query = 'INSERT INTO types (name, description) VALUES (:name, :description);';
     $this->db->prepare($query);
     $this->db->bindValue(':name', $type->getName());
     $this->db->bindValue(':description', $type->getDescription());
     $this->db->execute();
     return $this->db->lastInsertId();
 }
开发者ID:arkuuu,项目名称:publin,代码行数:16,代码来源:TypeModel.php

示例5: isAssignableFrom

 /**
  * Checks whether the provided type equals this type or is a subtype of this type.
  *
  * @param Type $type
  * @return boolean
  */
 public function isAssignableFrom(Type $type)
 {
     if ($type->getName() === $this->getName()) {
         return true;
     }
     if (!$type instanceof ClassType) {
         return false;
     }
     return $type->isSubtypeOf($this);
 }
开发者ID:Kaemmelot,项目名称:php-type-reflection,代码行数:16,代码来源:ClassType.php

示例6: __construct

 public function __construct($reactionID)
 {
     $dbMgr = new DatabaseManager(true);
     $objectData = $dbMgr->getReactionData($reactionID);
     $this->reactionID = $objectData['reactionID'];
     $this->reactionType = $objectData['reactionType'];
     $this->inputs = $dbMgr->getReactionInputs($this->reactionID);
     $objectFactory = new ObjectFactory();
     foreach ($this->inputs as $input) {
         $inputType = $objectFactory->create(ObjectFactory::TYPE, $input['typeID']);
         $inputVolume = $inputType->getVolume() * $input['inputQty'];
         $this->inputVolume += $inputVolume;
     }
     $this->output = $objectFactory->create(ObjectFactory::TYPE, $objectData['typeID']);
     $this->outputQty = $objectData['outputQty'];
     $this->outputVolume = $this->outputQty * $this->output->getVolume();
     $this->reactionName = $this->output->getName();
     if ($this->reactionType == 3) {
         $this->reactionName += " Alchemy";
     }
     $dbMgr = null;
 }
开发者ID:Covert-Inferno,项目名称:reaction-toolkit,代码行数:22,代码来源:Reaction.php

示例7: isAssignableFrom

 /**
  * Checks whether the provided type is either an interface that is equal to or extends this interface
  * or is a class that implements this interface.
  *
  * @param Type $type
  * @return boolean
  */
 public function isAssignableFrom(Type $type)
 {
     if ($type->getName() === $this->getName()) {
         return true;
     }
     if ($type instanceof InterfaceType) {
         return $type->isSubtypeOf($this);
     } else {
         if ($type instanceof ClassType) {
             return $type->isImplementorOf($this);
         }
     }
     return false;
 }
开发者ID:Kaemmelot,项目名称:php-type-reflection,代码行数:21,代码来源:InterfaceType.php

示例8: log

 /**
  * log an error of the given type
  * @param string $message
  * @param string $file
  * @param int $line
  * @param int $type
  * @throws \Exception
  */
 public function log($message, $file, $line, $type = E_ERROR)
 {
     if (!empty($this->_fileName) && ($fh = fopen($this->_fileName, 'a'))) {
         if ($message instanceof \Exception) {
             $eClass = get_class($message);
             $eMessage = $eClass . ' with message: "' . $message->getMessage() . ' Code: ' . $message->getCode() . '"' . PHP_EOL . 'in ' . $message->getFile() . ' on line ' . $message->getLine() . PHP_EOL . 'Stack-Trace' . PHP_EOL . '  ';
             $eMessage .= str_replace(PHP_EOL, PHP_EOL . '  ', $message->getTraceAsString());
             $message = $eMessage;
         }
         fwrite($fh, sprintf('[' . date('r') . '] [' . Type::getName($type) . '] %s in %s on line %s' . PHP_EOL, $message, $file, $line));
         fclose($fh);
     } else {
         throw new \Exception('No Log-File specified or file not accessible!');
     }
 }
开发者ID:robotr,项目名称:mvcDemo,代码行数:23,代码来源:Logger.php

示例9: __construct

 /**
  * ctor
  * @param array $config
  */
 public function __construct($config = [])
 {
     $this->_config = $config;
     // callback for set_error_handler/set_exception_handler
     $this->_callable = function () {
         $args = func_get_args();
         if ($fh = fopen($this->_fileName, 'a')) {
             if (5 == count($args)) {
                 // Error-Handling
                 if (isset($args[4])) {
                     if (isset($args[4]['e']) && $args[4]['e'] instanceof \Exception) {
                         // caught Exception
                         /** @var \Exception $exc */
                         $exc = $args[4]['e'];
                         unset($args[4]['e']);
                         // todo - ? $source = array_shift($args[4]); ?
                         $args[0] = Type::E_USER_EXCEPTION;
                         $args[1] = get_class($exc) . ': ' . $exc->getMessage();
                         $args[2] = $exc->getFile();
                         $args[3] = $exc->getLine();
                         $args[4] = $exc->getTraceAsString();
                         $this->_keys[] = 'trace';
                     } else {
                         unset($args[4]);
                     }
                 }
             } elseif (1 == count($args) && $args[0] instanceof \Exception) {
                 // Exception-Handling
                 // todo sanitize method-args
                 /** @var \Exception $exc */
                 $exc = array_shift($args);
                 $args[0] = Type::E_USER_CATCHABLE;
                 $args[1] = 'Uncaught ' . get_class($exc) . ': ' . $exc->getMessage();
                 $args[2] = $exc->getFile();
                 $args[3] = $exc->getLine();
                 $args[4] = $exc->getTraceAsString();
                 $this->_keys[] = 'trace';
             }
             // create log-message
             $args = array_combine($this->_keys, $args);
             $args['code'] = Type::getName($args['code']);
             $args['date'] = date('r');
             fwrite($fh, !in_array('trace', $this->_keys) ? $this->_getMessage($args) : $this->_getTraceMessage($args));
             fclose($fh);
         }
     };
 }
开发者ID:robotr,项目名称:mvcDemo,代码行数:51,代码来源:Handler.php

示例10: testCreate

 /**
  * @covers \Weasel\JsonMarshaller\Config\Annotations\JsonSubTypes\Type
  */
 public function testCreate()
 {
     $test = new Type("testValue", "testName");
     $this->assertEquals("testValue", $test->getValue());
     $this->assertEquals("testName", $test->getName());
 }
开发者ID:siad007,项目名称:php-weasel,代码行数:9,代码来源:TypeTest.php

示例11: addType

 /**
  * @param Type $type
  */
 public function addType(Type $type)
 {
     $this->types[$type->getName()] = $type;
 }
开发者ID:elastification,项目名称:php-backup-restore,代码行数:7,代码来源:Index.php

示例12: registerType

 public function registerType(Type $type)
 {
     $this->types[$type->getName()] = $type;
 }
开发者ID:linkorb,项目名称:primate,代码行数:4,代码来源:Primate.php

示例13: defineColumn

 protected function defineColumn(Type $type)
 {
     return \sprintf('`%s` %s', $type->getName(), $type->getDataType());
 }
开发者ID:dazarobbo,项目名称:cola,代码行数:4,代码来源:MySQLStatementGenerator.php

示例14: testGetName

 public function testGetName()
 {
     $this->assertSame(self::$name, $this->parameter->getName());
 }
开发者ID:emarref,项目名称:jwt,代码行数:4,代码来源:TypeTest.php

示例15: register

 /**
  * Registers a data type.
  * 
  * @param \WordPress\Data\Type $type
  * 
  * @return \WordPress\Data\Manager
  */
 public function register(Type $type)
 {
     $this->types[$type->getName()] = $type;
     return $this;
 }
开发者ID:wells5609,项目名称:wp-app,代码行数:12,代码来源:Manager.php


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