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


PHP ArrayObject::uksort方法代码示例

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


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

示例1: parse

 /**
  * Scans and parses PHP files.
  *
  * @return array
  * @throws \RuntimeException If no PHP files have been found.
  */
 public function parse()
 {
     $files = array();
     $flags = \RecursiveDirectoryIterator::CURRENT_AS_FILEINFO | \RecursiveDirectoryIterator::SKIP_DOTS;
     if (defined('\\RecursiveDirectoryIterator::FOLLOW_SYMLINKS')) {
         // Available from PHP 5.3.1
         $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
     }
     foreach ($this->config->source as $source) {
         $entries = array();
         if (is_dir($source)) {
             foreach (new \RecursiveIteratorIterator(new SourceFilesFilterIterator(new \RecursiveDirectoryIterator($source, $flags), $this->config->exclude)) as $entry) {
                 if (!$entry->isFile()) {
                     continue;
                 }
                 $entries[] = $entry;
             }
         } elseif ($this->isPhar($source)) {
             if (!extension_loaded('phar')) {
                 throw new RuntimeException('Phar extension is not loaded');
             }
             foreach (new \RecursiveIteratorIterator(new \Phar($source, $flags)) as $entry) {
                 if (!$entry->isFile()) {
                     continue;
                 }
                 $entries[] = $entry;
             }
         } else {
             $entries[] = new \SplFileInfo($source);
         }
         $regexp = '~\\.' . implode('|', $this->config->extensions->toArray()) . '$~i';
         foreach ($entries as $entry) {
             if (!preg_match($regexp, $entry->getFilename())) {
                 continue;
             }
             $pathName = $this->normalizePath($entry->getPathName());
             $files[$pathName] = $entry->getSize();
             if (false !== $entry->getRealPath() && $pathName !== $entry->getRealPath()) {
                 $this->symlinks[$entry->getRealPath()] = $pathName;
             }
         }
     }
     if (empty($files)) {
         throw new RuntimeException('No PHP files found');
     }
     $this->fireEvent('parseStart', array_sum($files));
     $broker = new Broker(new Backend($this, !empty($this->config->report)), Broker::OPTION_DEFAULT & ~(Broker::OPTION_PARSE_FUNCTION_BODY | Broker::OPTION_SAVE_TOKEN_STREAM));
     $errors = array();
     foreach ($files as $filePath => $size) {
         $content = $this->charsetConvertor->convertFile($filePath);
         try {
             $broker->processString($content, $filePath);
         } catch (\Exception $e) {
             $errors[] = $e;
         }
         $this->fireEvent('parseProgress', $size);
     }
     // Classes
     $this->parsedClasses->exchangeArray($broker->getClasses(Backend::TOKENIZED_CLASSES | Backend::INTERNAL_CLASSES | Backend::NONEXISTENT_CLASSES));
     $this->parsedClasses->uksort('strcasecmp');
     // Constants
     $this->parsedConstants->exchangeArray($broker->getConstants());
     $this->parsedConstants->uksort('strcasecmp');
     // Functions
     $this->parsedFunctions->exchangeArray($broker->getFunctions());
     $this->parsedFunctions->uksort('strcasecmp');
     $documentedCounter = function ($count, $element) {
         return $count += (int) $element->isDocumented();
     };
     return (object) array('classes' => count($broker->getClasses(Backend::TOKENIZED_CLASSES)), 'constants' => count($this->parsedConstants), 'functions' => count($this->parsedFunctions), 'internalClasses' => count($broker->getClasses(Backend::INTERNAL_CLASSES)), 'documentedClasses' => array_reduce($broker->getClasses(Backend::TOKENIZED_CLASSES), $documentedCounter), 'documentedConstants' => array_reduce($this->parsedConstants->getArrayCopy(), $documentedCounter), 'documentedFunctions' => array_reduce($this->parsedFunctions->getArrayCopy(), $documentedCounter), 'documentedInternalClasses' => array_reduce($broker->getClasses(Backend::INTERNAL_CLASSES), $documentedCounter), 'errors' => $errors);
 }
开发者ID:sirone,项目名称:apigen,代码行数:77,代码来源:Generator.php

示例2: ArrayObject

<?php

/* Prototype  : int ArrayObject::uksort(callback cmp_function)
 * Description: proto int ArrayIterator::uksort(callback cmp_function)
 Sort the entries by key using user defined function.
 * Source code: ext/spl/spl_array.c
 * Alias to functions: 
 */
$ao = new ArrayObject();
try {
    $ao->uksort();
} catch (BadMethodCallException $e) {
    echo $e->getMessage() . "\n";
}
try {
    $ao->uksort(1, 2);
} catch (BadMethodCallException $e) {
    echo $e->getMessage() . "\n";
}
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:21,代码来源:arrayObject_uksort_error1.php

示例3: cmp

<?php

function cmp($a, $b)
{
    $a = preg_replace('@^(a|an|the) @', '', $a);
    $b = preg_replace('@^(a|an|the) @', '', $b);
    return strcasecmp($a, $b);
}
$array = array("John" => 1, "the Earth" => 2, "an apple" => 3, "a banana" => 4);
$arrayObject = new ArrayObject($array);
$arrayObject->uksort('cmp');
foreach ($arrayObject as $key => $value) {
    echo "{$key}: {$value}\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:14,代码来源:uksort.php

示例4: cmp

<?php

/* Prototype  : int ArrayObject::uksort(callback cmp_function)
 * Description: proto int ArrayIterator::uksort(callback cmp_function)
 * Sort the entries by key using user defined function. 
 * Source code: ext/spl/spl_array.c
 * Alias to functions: 
 */
echo "*** Testing ArrayObject::uksort() : basic functionality ***\n";
// Reverse sorter
function cmp($value1, $value2)
{
    if ($value1 == $value2) {
        return 0;
    } else {
        if ($value1 < $value2) {
            return 1;
        } else {
            return -1;
        }
    }
}
$ao = new ArrayObject(array(3 => 0, 2 => 1, 5 => 2, 6 => 3, 1 => 4));
$ao->uksort('cmp');
var_dump($ao);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:27,代码来源:arrayObject_uksort_basic1.php

示例5: uksort

 public function uksort($cmp_function)
 {
     $this->lazyLoadArray();
     parent::uksort($cmp_function);
 }
开发者ID:jinshana,项目名称:kajonacms,代码行数:5,代码来源:class_orm_assignment_array.php

示例6: uksort

 /**
  * Implementation of ArrayObject::uksort().
  *
  * This function sorts the keys of the entries using a user-supplied
  * comparison function. The key to entry correlations will be maintained.
  *
  * No value is returned.
  *
  * @param callable $cmpFunction The callback comparison function.
  */
 public function uksort($cmpFunction)
 {
     $this->arrayObject->uksort($cmpFunction);
 }
开发者ID:pbull,项目名称:acquia-platform-cloud-data-model,代码行数:14,代码来源:ArrayObjectImplementationMethods.php


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