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


PHP ArrayIterator::uasort方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fraggles = (include __DIR__ . '/../../../examples/fraggles.php');
     $arrayIterator = new \ArrayIterator($fraggles);
     // Print the array
     $output->writeln("The array in natural order");
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     // print the array sorted
     $output->writeln("The array in alphabetical order");
     $arrayIterator->asort();
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     // print the array sorted
     $output->writeln("Emprorer First order");
     $arrayIterator->uasort([$this, 'emperorFirst']);
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     $output->writeln("Done");
     return;
 }
开发者ID:Stunt,项目名称:iterators,代码行数:24,代码来源:ArrayIteratorCommand.php

示例2: getMigrationClasses

 /**
  * @param bool $all
  * @return \ArrayIterator
  */
 public function getMigrationClasses($all = false)
 {
     $classes = new \ArrayIterator();
     $sModuleDir = __DIR__ . "/../../../../../../module";
     //        var_dump(file_exists($sModuleDir));
     $aMigrationDir = array();
     //        if(file_exists($sModuleDir)){
     //            foreach (new \DirectoryIterator($sModuleDir) as $fileInfo) {
     //                if($fileInfo->isDot()) continue;
     //                if(!$fileInfo->isDir()) continue;
     //                $sDirTmp = $sModuleDir."/".$fileInfo->getFilename()."/migrations";
     //                if(file_exists($sDirTmp)){
     //                    $aMigrationDir[] = $sDirTmp;
     //                }
     //            }
     //
     //        }
     $aMigrationDir[] = $this->migrationsDir;
     //        var_dump($aMigrationDir);
     foreach ($aMigrationDir as $sDirTmp) {
         $iterator = new \GlobIterator(sprintf('%s/Version*.php', $sDirTmp), \FilesystemIterator::KEY_AS_FILENAME);
         foreach ($iterator as $item) {
             /** @var $item \SplFileInfo */
             if (preg_match('/(Version(\\d+))\\.php/', $item->getFilename(), $matches)) {
                 $applied = $this->migrationVersionTable->applied($matches[2], $this->migrationsDirMd5);
                 if ($all || !$applied) {
                     $className = $this->migrationsNamespace . '\\' . $matches[1];
                     if (!class_exists($className)) {
                         /** @noinspection PhpIncludeInspection */
                         require_once $sDirTmp . '/' . $item->getFilename();
                     }
                     if (class_exists($className)) {
                         $reflectionClass = new \ReflectionClass($className);
                         $reflectionDescription = new \ReflectionProperty($className, 'description');
                         if ($reflectionClass->implementsInterface('YcheukfMigration\\Library\\MigrationInterface')) {
                             $classes->append(array('version' => $matches[2], 'class' => $className, 'description' => $reflectionDescription->getValue(), 'applied' => $applied));
                         }
                     }
                 }
             }
         }
     }
     //var_dump($classes);
     //exit;
     $classes->uasort(function ($a, $b) {
         if ($a['version'] == $b['version']) {
             return 0;
         }
         return $a['version'] < $b['version'] ? -1 : 1;
     });
     return $classes;
 }
开发者ID:ycheukf,项目名称:migration,代码行数:56,代码来源:Migration.php

示例3: uasort

 public function uasort($cmp_function)
 {
     parent::uasort($cmp_function);
     $this->refreshPositions();
 }
开发者ID:disider,项目名称:Propel2,代码行数:5,代码来源:CollectionIterator.php

示例4: getMigrationClasses

 /**
  * Найти список классов миграций
  * @return \ArrayIterator [version,class]
  */
 public function getMigrationClasses()
 {
     $classes = new \ArrayIterator();
     $iterator = new \GlobIterator(sprintf('%s/Version*.php', $this->migrationClassFolder), \FilesystemIterator::KEY_AS_FILENAME);
     foreach ($iterator as $item) {
         if (preg_match('/(Version(\\d+))\\.php/', $item->getFilename(), $matches)) {
             $className = $this->namespaceMigrationsClasses . '\\' . $matches[1];
             if (!class_exists($className)) {
                 require_once $this->migrationClassFolder . '/' . $item->getFilename();
             }
             if (class_exists($className)) {
                 $reflection = new \ReflectionClass($className);
                 if ($reflection->implementsInterface('ZendDbMigrations\\Library\\MigrationInterface')) {
                     $classes->append(array('version' => $matches[2], 'class' => $className));
                 }
             }
         }
     }
     $classes->uasort(function ($a, $b) {
         if ($a['version'] == $b['version']) {
             return 0;
         }
         return $a['version'] < $b['version'] ? -1 : 1;
     });
     return $classes;
 }
开发者ID:slamking,项目名称:ZendDbMigrations,代码行数:30,代码来源:Migration.php

示例5: getMigrationClasses

 /**
  * @param bool $all
  * @param string $source
  * @return \ArrayIterator
  */
 public function getMigrationClasses($all = false, $source = null)
 {
     $classes = new \ArrayIterator();
     foreach ($this->migrationsDir as $sourceName => $sourceDir) {
         if (!is_null($source) && $sourceName != $source) {
             continue;
         }
         $iterator = new \GlobIterator(sprintf('%s/Version*.php', $sourceDir), \FilesystemIterator::KEY_AS_FILENAME);
         foreach ($iterator as $item) {
             /** @var $item \SplFileInfo */
             if (preg_match('/(Version(\\d+))\\.php/', $item->getFilename(), $matches)) {
                 $applied = $this->migrationVersionTable->applied($matches[2]);
                 if ($all || !$applied) {
                     $className = $this->migrationsNamespace . '\\' . $matches[1];
                     if (!class_exists($className)) {
                         /** @noinspection PhpIncludeInspection */
                         require_once $sourceDir . '/' . $item->getFilename();
                     }
                     if (class_exists($className)) {
                         $reflectionClass = new \ReflectionClass($className);
                         $reflectionDescription = new \ReflectionProperty($className, 'description');
                         if ($reflectionClass->implementsInterface('ZfSimpleMigrations\\Library\\MigrationInterface')) {
                             $classes->append(['version' => $matches[2], 'class' => $className, 'description' => $reflectionDescription->getValue(), 'applied' => $applied, 'source' => $sourceName]);
                         }
                     }
                 }
             }
         }
     }
     $classes->uasort(function ($a, $b) {
         if ($a['version'] == $b['version']) {
             return 0;
         }
         return $a['version'] < $b['version'] ? -1 : 1;
     });
     return $classes;
 }
开发者ID:nicolas-berezin,项目名称:ZfSimpleMigrations,代码行数:42,代码来源:Migration.php

示例6: getIterator

 /** Build an iterator for this Collection.
  */
 public function getIterator()
 {
     $order = $this->order;
     $iterator = new ArrayIterator($this->collected);
     if (!empty($order)) {
         $desc = $this->desc ? 1 : -1;
         $iterator->uasort(function ($a, $b) use($order, $desc) {
             $a = $a->{$order}();
             $b = $b->{$order}();
             if ($a == $b) {
                 return 0;
             }
             return $a < $b ? $desc : -$desc;
         });
     }
     return $iterator;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:19,代码来源:collection.php


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