本文整理汇总了PHP中get_type函数的典型用法代码示例。如果您正苦于以下问题:PHP get_type函数的具体用法?PHP get_type怎么用?PHP get_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTextFromData
protected function getTextFromData($data)
{
if (!is_array($data)) {
throw new \RuntimeException('Wrong type of data to markdownify: ' . get_type($data));
}
return Yaml::dump($data, 3);
}
示例2: setResolver
/**
* @param $callable
*
* @throws InvalidResolverException
*/
public function setResolver($callable)
{
if (!is_callable($callable)) {
throw new InvalidResolverException(s('Routing resolver must be a callable, received "%s".', get_type($callable)));
}
$this->resolver = $callable;
}
示例3: getTextFromData
protected function getTextFromData($data)
{
if (!is_string($data)) {
throw new \RuntimeException('Wrong type of data to markdownify: ' . get_type($data));
}
return (new MarkdownifyExtra())->parseString($data);
}
示例4: run
public function run(ApplicationInterface $app)
{
$connector = Connector::getInstance();
$connector->setSourcesBasePath(getcwd());
$matcher = new Matcher();
// redirect errors to PhpConsole
\PhpConsole\Handler::getInstance()->start();
$app->getEventsHandler()->bind('*', function (EventInterface $event) use($app, $connector, $matcher) {
/**
* @var $connector \PhpConsole\Connector
*/
if ($connector->isActiveClient()) {
$console = \PhpConsole\Handler::getInstance();
$context = $event->getContext();
$origin = $event->getOrigin();
switch (true) {
case $event->getName() == 'application.workflow.step.run':
$console->debug(sprintf('Starting running step %s', $origin->getName()), 'workflow.step');
break;
case $event->getName() == 'application.workflow.hook.run':
$middleware = $origin->getMiddleware();
$console->debug(sprintf('Running Middleware %s (%s)', $middleware->getReference(), $middleware->getDescription()), 'workflow.hook');
$this->dumpNotifications($console, $middleware->getNotifications());
break;
case $matcher->match(ServicesFactory::EVENT_INSTANCE_BUILT . '.*', $event->getName()):
$console->debug(sprintf('Built service %s (%s)', $context['serviceSpecs']->getId(), is_object($context['instance']) ? get_class($context['instance']) : get_type($context['instance'])), 'services');
break;
case $matcher->match($event->getName(), '*.notify.*'):
$this->dumpNotifications($console, $event->getContext('notifications'));
break;
}
}
});
}
示例5: transform
/**
* Transforms an array to a csv set of strings
*
* @param array|null $array
* @return string
*/
public function transform($array)
{
if (!is_array($array)) {
throw new TransformationFailedException(sprintf('%s is not an array', get_type($array)));
}
return implode(',', $array);
}
示例6: test_load_file
public function test_load_file()
{
$path = path(__DIR__, '/../configs/array.php');
$driver = new ArrayConfigDriver();
$config = $driver->loadFile($path);
$this->assertTrue(get_type($config) == 'array');
$this->assertEquals(require $path, $config);
}
示例7: _create
/**
* Creates a new record and adds it to the DB based on the stuff given in $info
* @param info Array|Zend_Config The stuff to put in the DB
* @return $this
*/
protected function _create($info)
{
$info instanceof Zend_Config && ($info = $info->toArray());
if (!is_array($info)) {
throw new Kizano_Exception(sprintf('%s::%s(): Argument $info expected type (string), received `%s\'', __CLASS__, __FUNCTION__, get_type($info)));
}
foreach ($info as $name => $value) {
$this[$name] = $value;
}
return $this->save();
}
示例8: invoke
/**
* @param IDefinition $definition
* @param $command
*
* @return mixed
* @throws InvalidCommandHandlerException
*/
public function invoke(IDefinition $definition, $command)
{
$handler = $definition->getHandler();
if ($this->isValidHandlerClass($handler)) {
$handler = $this->createHandler($handler);
}
if ($this->isValidHandler($handler)) {
return $this->invokeHandler($handler, $command);
}
throw new InvalidCommandHandlerException(s('Handler "%s" must implement method "handle($command)".', is_string($handler) ? $handler : get_type($handler)));
}
示例9: getImgPath
function getImgPath($galleryFolder, $destination_folder, $imgName)
{
$imgPath = '';
if ($handle = opendir($destination_folder)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file, $imgName) !== false && strpos($file, '_sm') === false) {
$img = $destination_folder . $file;
$imgData = base64_encode(file_get_contents($img));
$imgPath = 'data: ' . get_type($img) . ';base64,' . $imgData;
}
}
closedir($handle);
}
return $imgPath;
}
示例10: files
/**
* Retrieves the attachments of the specified object
*
* @param mixed $object
* @return WebDev\AttachmentBundle\Attachement\File[]
*/
public function files($object)
{
if (!is_object($object)) {
throw new Exception("Can't retrieve the attachments of a " . get_type($object));
}
$class = new ReflectionClass($object);
$files = array();
foreach ($this->reader->getClassAnnotations($class) as $annotation) {
if (!$annotation instanceof FileAttachment) {
continue;
}
$file = new File($annotation, $object, $this);
$files[$file->getName()] = $file;
}
return $files;
}
示例11: nameConstant
public static function nameConstant(SpritePackageInterface $package, SpriteImage $sprite)
{
$converter = $package->getConstantsConverter();
if (!empty($converter)) {
if (!is_callable($converter, true)) {
throw new RuntimeException('Variable of type `%s` is not callable', get_type($converter));
}
$params = [$package, $sprite];
$name = call_user_func_array($converter, $params);
} else {
$name = $sprite->name;
}
// Last resort replacements
$name = preg_replace('~^[0-9]+~', '', $name);
return str_replace('-', '_', $name);
}
示例12: invokeRoute
/**
* @param IRoute $route
*
* @return IHttpResponse
* @throws InvalidRouteValue
*/
public function invokeRoute(IRoute $route)
{
$invoker = $this->findInvoker($route);
if ($invoker) {
$response = $invoker->invoke($route, $this->container);
if ($response instanceof IHttpResponseHolder) {
$response = $response->getHttpResponse();
} else {
if ($response instanceof IHttpResponseable) {
$response = $response->toHttpResponse();
}
}
if (!$response instanceof IHttpResponse) {
$response = new HttpResponse(HttpStatusCode::OK, $response);
}
return $response;
}
throw new InvalidRouteValue(s('Could not resolve route value of type %s.', get_type($route->getAction())));
}
示例13: newSubtitle
public static function newSubtitle()
{
if (!isset($_FILES['newsub_file'])) {
return null;
}
$newsub_amt = count($_FILES['newsub_file']['name']);
$folder = 'subtitle/';
$return = array();
for ($i = 0; $i < $newsub_amt; $i++) {
$extension = get_type($_FILES['newsub_file']['name'][$i]);
$name = 'sub_' . strtotime('now') . rand(10000000, 99999999);
if ($_FILES['newsub_file']['tmp_name'][$i] && $extension == 'srt') {
$extension = 'srt';
move_uploaded_file($_FILES['newsub_file']['tmp_name'][$i], UPLOAD_PATH . "{$folder}{$name}.{$extension}");
$return[$i] = UPLOAD_URL . "{$folder}{$name}.{$extension}";
} else {
$return[$i] = null;
}
}
return $return;
}
示例14: render_value
function render_value($dbc, $db_name, $name, $with_def = false)
{
if (strpos($name, $db_name . ':o') === 0) {
$id = str_replace($db_name . ':o', "", $name);
$query = "select * from def where id ='{$id}'";
$result = mysqli_query($dbc, $query) or die('Error querying database:' . $query);
if ($row = mysqli_fetch_array($result)) {
$pre_label = $row[name];
$def = $row[def];
$result = get_entity_link($id, get_type($dbc, $name) . ': ' . $pre_label, $db_name);
if ($with_def && $def != '') {
$result .= ' <em><small>(' . tcmks_substr($def) . ')' . '</small></em>';
}
} else {
$result = $name;
}
} else {
$result = $name;
}
return $result;
}
示例15: encode
/**
* @param $data
* @param int $options
*
* @return string
* @throws InvalidDataTypeException
* @throws JsonEncodeException
*/
public function encode($data, $options = 0)
{
$json = null;
if ($data instanceof IArrayable) {
$json = @json_encode($data->toArray(), $options);
} else {
if ($data instanceof IJsonable) {
$json = $data->toJson($options);
} else {
if (is_array($data) || is_object($data)) {
$json = @json_encode($data, $options);
} else {
throw new InvalidDataTypeException(s('Can not convert data of type "%s" to json.', get_type($data)));
}
}
}
if ($json === false) {
throw new JsonEncodeException(json_last_error_msg(), $data);
}
return $json;
}