Skip to content

Commit

Permalink
[Finder] Fixed expression classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfsimon committed Oct 29, 2012
1 parent 5c6dbeb commit 6258d12
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 27 deletions.
20 changes: 20 additions & 0 deletions src/Symfony/Component/Finder/Expression/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ public function getType()
return $this->value->getType();
}

/**
* {@inheritdoc}
*/
public function prepend($expr)
{
$this->value->prepend($expr);

return $this;
}

/**
* {@inheritdoc}
*/
public function append($expr)
{
$this->value->append($expr);

return $this;
}

/**
* @return bool
*/
Expand Down
20 changes: 20 additions & 0 deletions src/Symfony/Component/Finder/Expression/Glob.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ public function isCaseSensitive()
return true;
}

/**
* {@inheritdoc}
*/
public function prepend($expr)
{
$this->pattern = $expr.$this->pattern;

return $this;
}

/**
* {@inheritdoc}
*/
public function append($expr)
{
$this->pattern .= $expr;

return $this;
}

/**
* @param bool $strictLeadingDot
* @param bool $strictWildcardSlash
Expand Down
56 changes: 29 additions & 27 deletions src/Symfony/Component/Finder/Expression/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function create($expr)
$end = substr($m[1], -1);

if (($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start)) || ($start === '{' && $end === '}')) {
return new self(substr($m[1], 1, -1), $m[2]);
return new self(substr($m[1], 1, -1), $m[2], $end);
}
}

Expand All @@ -76,9 +76,15 @@ public static function create($expr)
/**
* @param string $pattern
* @param string $options
* @param string $delimiter
*/
public function __construct($pattern, $options = '')
public function __construct($pattern, $options = '', $delimiter = null)
{
if (null !== $delimiter) {
// removes delimiter escaping
$pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
}

$this->parsePattern($pattern);
$this->options = $options;
}
Expand Down Expand Up @@ -109,7 +115,7 @@ public function renderPattern()
{
return ($this->startFlag ? self::START_FLAG : '')
.($this->startJoker ? self::JOKER : '')
.$this->pattern
.str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
.($this->endJoker ? self::JOKER : '')
.($this->endFlag ? self::END_FLAG : '');
}
Expand All @@ -130,6 +136,26 @@ public function getType()
return Expression::TYPE_REGEX;
}

/**
* {@inheritdoc}
*/
public function prepend($expr)
{
$this->pattern = $expr.$this->pattern;

return $this;
}

/**
* {@inheritdoc}
*/
public function append($expr)
{
$this->pattern .= $expr;

return $this;
}

/**
* @param string $option
*
Expand Down Expand Up @@ -246,30 +272,6 @@ public function hasEndJoker()
return $this->endJoker;
}

/**
* @param string $expr
*
* @return Regex
*/
public function prepend($expr)
{
$this->pattern = $expr.$this->pattern;

return $this;
}

/**
* @param string $expr
*
* @return Regex
*/
public function append($expr)
{
$this->pattern .= $expr;

return $this;
}

/**
* @param array $replacements
*
Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Finder/Expression/ValueInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,18 @@ function isCaseSensitive();
* @return int
*/
function getType();

/**
* @param string $expr
*
* @return ValueInterface
*/
public function prepend($expr);

/**
* @param string $expr
*
* @return ValueInterface
*/
public function append($expr);
}

0 comments on commit 6258d12

Please sign in to comment.