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


PHP Expression\Expression类代码示例

本文整理汇总了PHP中Symfony\Component\Finder\Expression\Expression的典型用法代码示例。如果您正苦于以下问题:PHP Expression类的具体用法?PHP Expression怎么用?PHP Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testMixFlagsAndJokers

 public function testMixFlagsAndJokers()
 {
     $expr = new Expression('~^.*abc.*$~is');
     $expr->getRegex()->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
     $this->assertEquals('~abc~is', $expr->render());
     $expr->getRegex()->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
     $this->assertEquals('~^.*abc.*$~is', $expr->render());
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:8,代码来源:RegexTest.php

示例2: buildContentFiltering

 protected function buildContentFiltering(Command $command, array $contains, $not = false)
 {
     foreach ($contains as $contain) {
         $expr = Expression::create($contain);
         $command->add('| xargs -I{} -r grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}');
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:GnuFindAdapter.php

示例3: notPath

 /**
  * Adds rules that filenames must not match.
  *
  * You can use patterns (delimited with / sign) or simple strings.
  *
  * $collection->notPath('/^spec\/')
  *
  * @param $pattern
  *
  * @return FilesCollection
  */
 public function notPath($pattern)
 {
     $regex = Expression::create($pattern)->getRegex()->render();
     return $this->filter(function (SplFileInfo $file) use($regex) {
         return !preg_match($regex, $file->getPath());
     });
 }
开发者ID:hunslater,项目名称:grumphp,代码行数:18,代码来源:FilesCollection.php

示例4: buildContentFiltering

 /**
  * {@inheritdoc}
  */
 protected function buildContentFiltering(Command $command, array $contains, $not = false)
 {
     foreach ($contains as $contain) {
         $expr = Expression::create($contain);
         // todo: avoid forking process for each $pattern by using multiple -e options
         $command->add('| grep -v \'^$\'')->add('| xargs -I{} grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}');
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:11,代码来源:BsdFindAdapter.php

示例5: testGlobToRegex

 /**
  * @dataProvider getToRegexData
  */
 public function testGlobToRegex($glob, $match, $noMatch)
 {
     foreach ($match as $m) {
         $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
     }
     foreach ($noMatch as $m) {
         $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:12,代码来源:GlobTest.php

示例6: toRegex

 /**
  * Converts glob to regexp.
  *
  * PCRE patterns are left unchanged.
  * Glob strings are transformed with Glob::toRegex().
  *
  * @param string $str Pattern: glob or regexp
  *
  * @return string regexp corresponding to a given glob or regexp
  */
 protected function toRegex($str)
 {
     $value = Expression::create($str);
     if ($value->isGlob()) {
         $value = $value->getRegex();
         if (false === strpos($str, '/')) {
             $value->setStartFlag(false);
         }
     }
     return $value->render();
 }
开发者ID:mistymagich,项目名称:gush,代码行数:21,代码来源:PathFilterIterator.php

示例7: run

 /**
  * @param ContextInterface|GitCommitMsgContext $context
  */
 public function run(ContextInterface $context)
 {
     $config = $this->getConfiguration();
     $commitMessage = $context->getCommitMessage();
     foreach ($config['matchers'] as $rule) {
         $expression = Expression::create($rule);
         $regex = $expression->getRegex();
         if ((bool) $config['case_insensitive']) {
             $regex->addOption('i');
         }
         if ((bool) $config['multiline']) {
             $regex->addOption('m');
         }
         if (!preg_match($regex->render(), $commitMessage)) {
             throw new RuntimeException(sprintf('The commit message does not match the rule: %s', $rule));
         }
     }
 }
开发者ID:hunslater,项目名称:grumphp,代码行数:21,代码来源:CommitMessage.php

示例8: isRegex

 /**
  * Checks whether the string is a regex.
  *
  * @param string $str
  *
  * @return bool Whether the given string is a regex
  */
 protected function isRegex($str)
 {
     return Expression::create($str)->isRegex();
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:11,代码来源:MultiplePcreFilterIterator.php

示例9: toRegex

 /**
  * Converts glob to regexp.
  *
  * PCRE patterns are left unchanged.
  * Glob strings are transformed with Glob::toRegex().
  *
  * @param string $str Pattern: glob or regexp
  *
  * @return string regexp corresponding to a given glob or regexp
  */
 protected function toRegex($str)
 {
     return Expression::create($str)->getRegex()->render();
 }
开发者ID:howtolearntocode,项目名称:symfony,代码行数:14,代码来源:FilenameFilterIterator.php

示例10: buildPathsFiltering

 private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
 {
     if (0 === count($paths)) {
         return;
     }
     $command->add($not ? '-not' : null)->cmd('(');
     foreach ($paths as $i => $path) {
         $expr = Expression::create($path);
         if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
             $expr = Expression::create($expr->getGlob()->toRegex(false));
         }
         if ($expr->isRegex()) {
             $regex = $expr->getRegex();
             $regex->prepend($regex->hasStartFlag() ? preg_quote($dir) . DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
         } else {
             $expr->prepend('*')->append('*');
         }
         $command->add($i > 0 ? '-or' : null)->add($expr->isRegex() ? $expr->isCaseSensitive() ? '-regex' : '-iregex' : ($expr->isCaseSensitive() ? '-path' : '-ipath'))->arg($expr->renderPattern());
     }
     $command->cmd(')');
 }
开发者ID:VicDeo,项目名称:poc,代码行数:21,代码来源:AbstractFindAdapter.php

示例11: testRegexRendering

 /**
  * @dataProvider getRegexRenderingData
  */
 public function testRegexRendering($expr, $body)
 {
     $this->assertEquals($body, Expression::create($expr)->renderPattern());
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:7,代码来源:ExpressionTest.php

示例12: buildPathsFiltering

    /**
     * @param Command  $command
     * @param string   $dir
     * @param string[] $paths
     * @param Boolean  $not
     */
    private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
    {
        if (0 === count($paths)) {
            return;
        }

        $command->add($not ? '-not' : null)->cmd('(');

        foreach ($paths as $i => $path) {
            $expr = Expression::create($path);

            // Find does not support expandable globs ("*.{a,b}" syntax).
            if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
                $expr = Expression::create($expr->getGlob()->toRegex(false));
            }

            // Fixes 'not search' regex problems.
            if ($expr->isRegex()) {
                $regex = $expr->getRegex();
                $regex->prepend($regex->hasStartFlag() ? $dir.DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
            } else {
                $expr->prepend('*')->append('*');
            }

            $command
                ->add($i > 0 ? '-or' : null)
                ->add($expr->isRegex()
                    ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
                    : ($expr->isCaseSensitive() ? '-path' : '-ipath')
                )
                ->arg($expr->renderPattern());
        }

        $command->cmd(')');
    }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:41,代码来源:AbstractFindAdapter.php


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