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


PHP Utils::cmpInt方法代码示例

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


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

示例1: getBestDelimiter

 private function getBestDelimiter($pattern)
 {
     $delimiters = array();
     foreach (self::$delimiters as $k => $d) {
         if (false === strpos($pattern, $d)) {
             return $d;
         }
         $delimiters[$d] = array(substr_count($pattern, $d), $k);
     }
     uasort($delimiters, function ($a, $b) {
         if ($a[0] === $b[0]) {
             return Utils::cmpInt($a, $b);
         }
         return $a[0] < $b[0] ? -1 : 1;
     });
     return key($delimiters);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:17,代码来源:EregToPregFixer.php

示例2: getFixersHelp

 protected function getFixersHelp()
 {
     $help = '';
     $maxName = 0;
     $fixers = $this->fixer->getFixers();
     // sort fixers by level and name
     usort($fixers, function (FixerInterface $a, FixerInterface $b) {
         $cmp = Utils::cmpInt($a->getLevel(), $b->getLevel());
         if (0 !== $cmp) {
             return $cmp;
         }
         return strcmp($a->getName(), $b->getName());
     });
     foreach ($fixers as $fixer) {
         if (strlen($fixer->getName()) > $maxName) {
             $maxName = strlen($fixer->getName());
         }
     }
     $count = count($fixers) - 1;
     foreach ($fixers as $i => $fixer) {
         $chunks = explode("\n", wordwrap(sprintf("[%s]\n%s", $this->fixer->getLevelAsString($fixer), $fixer->getDescription()), 72 - $maxName, "\n"));
         $help .= sprintf(" * <comment>%s</comment>%s %s\n", $fixer->getName(), str_repeat(' ', $maxName - strlen($fixer->getName())), array_shift($chunks));
         while ($c = array_shift($chunks)) {
             $help .= str_repeat(' ', $maxName + 4) . $c . "\n";
         }
         if ($count !== $i) {
             $help .= "\n";
         }
     }
     return $help;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:FixCommand.php

示例3: sortFixers

 private function sortFixers()
 {
     usort($this->fixers, function (FixerInterface $a, FixerInterface $b) {
         return Utils::cmpInt($b->getPriority(), $a->getPriority());
     });
 }
开发者ID:nazimodi,项目名称:PHP-CS-Fixer,代码行数:6,代码来源:Fixer.php

示例4: sortFixers

 /**
  * Sort fixers by their priorities.
  *
  * @return $this
  */
 private function sortFixers()
 {
     // Schwartzian transform is used to improve the efficiency and avoid
     // `usort(): Array was modified by the user comparison function` warning for mocked objects.
     $data = array_map(function (FixerInterface $fixer) {
         return array($fixer, $fixer->getPriority());
     }, $this->fixers);
     usort($data, function (array $a, array $b) {
         return Utils::cmpInt($b[1], $a[1]);
     });
     $this->fixers = array_map(function (array $item) {
         return $item[0];
     }, $data);
     return $this;
 }
开发者ID:tirozhang,项目名称:PHP-CS-Fixer,代码行数:20,代码来源:FixerFactory.php

示例5: sortTransformers

 /**
  * Sort registered Transformers.
  */
 private function sortTransformers()
 {
     usort($this->items, function (TransformerInterface $a, TransformerInterface $b) {
         return Utils::cmpInt($b->getPriority(), $a->getPriority());
     });
 }
开发者ID:Flesh192,项目名称:magento,代码行数:9,代码来源:Transformers.php

示例6: sortFixers

 /**
  * @param FixerInterface[] $fixers
  *
  * @return FixerInterface[]
  */
 private function sortFixers(array $fixers)
 {
     usort($fixers, function (FixerInterface $a, FixerInterface $b) {
         return Utils::cmpInt($b->getPriority(), $a->getPriority());
     });
     return $fixers;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:Fixer.php

示例7: getBestDelimiter

 /**
  * Get the delimiter that would require the least escaping in a regular expression.
  *
  * @param string $pattern the regular expression
  *
  * @return string the preg delimiter
  */
 private function getBestDelimiter($pattern)
 {
     // try do find something that's not used
     $delimiters = array();
     foreach (self::$delimiters as $k => $d) {
         if (false === strpos($pattern, $d)) {
             return $d;
         }
         $delimiters[$d] = array(substr_count($pattern, $d), $k);
     }
     // return the least used delimiter, using the position in the list as a tie breaker
     uasort($delimiters, function ($a, $b) {
         if ($a[0] === $b[0]) {
             return Utils::cmpInt($a, $b);
         }
         return $a[0] < $b[0] ? -1 : 1;
     });
     return key($delimiters);
 }
开发者ID:skillberto,项目名称:PHP-CS-Fixer,代码行数:26,代码来源:EregToPregFixer.php

示例8: testCmpInt

 /**
  * @dataProvider provideCmpIntCases
  */
 public function testCmpInt($expected, $left, $right)
 {
     $this->assertSame($expected, Utils::cmpInt($left, $right));
 }
开发者ID:kenyiu,项目名称:PHP-CS-Fixer,代码行数:7,代码来源:UtilsTest.php


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