PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,148 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Finder\Expression;
@trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
class Expression implements ValueInterface
{
const TYPE_REGEX = 1;
const TYPE_GLOB = 2;
/**
* @var ValueInterface
*/
private $value;
/**
* @param string $expr
*
* @return self
*/
public static function create($expr)
{
return new self($expr);
}
/**
* @param string $expr
*/
public function __construct($expr)
{
try {
$this->value = Regex::create($expr);
} catch (\InvalidArgumentException $e) {
$this->value = new Glob($expr);
}
}
/**
* @return string
*/
public function __toString()
{
return $this->render();
}
/**
* {@inheritdoc}
*/
public function render()
{
return $this->value->render();
}
/**
* {@inheritdoc}
*/
public function renderPattern()
{
return $this->value->renderPattern();
}
/**
* @return bool
*/
public function isCaseSensitive()
{
return $this->value->isCaseSensitive();
}
/**
* @return int
*/
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
*/
public function isRegex()
{
return self::TYPE_REGEX === $this->value->getType();
}
/**
* @return bool
*/
public function isGlob()
{
return self::TYPE_GLOB === $this->value->getType();
}
/**
* @return Glob
*
* @throws \LogicException
*/
public function getGlob()
{
if (self::TYPE_GLOB !== $this->value->getType()) {
throw new \LogicException('Regex can\'t be transformed to glob.');
}
return $this->value;
}
/**
* @return Regex
*/
public function getRegex()
{
return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
}
}

View File

@ -0,0 +1,108 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Finder\Expression;
@trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
use Symfony\Component\Finder\Glob as FinderGlob;
/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
class Glob implements ValueInterface
{
private $pattern;
/**
* @param string $pattern
*/
public function __construct($pattern)
{
$this->pattern = $pattern;
}
/**
* {@inheritdoc}
*/
public function render()
{
return $this->pattern;
}
/**
* {@inheritdoc}
*/
public function renderPattern()
{
return $this->pattern;
}
/**
* {@inheritdoc}
*/
public function getType()
{
return Expression::TYPE_GLOB;
}
/**
* {@inheritdoc}
*/
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;
}
/**
* Tests if glob is expandable ("*.{a,b}" syntax).
*
* @return bool
*/
public function isExpandable()
{
return false !== strpos($this->pattern, '{')
&& false !== strpos($this->pattern, '}');
}
/**
* @param bool $strictLeadingDot
* @param bool $strictWildcardSlash
*
* @return Regex
*/
public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
{
$regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
return new Regex($regex);
}
}

View File

@ -0,0 +1,321 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Finder\Expression;
@trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
class Regex implements ValueInterface
{
const START_FLAG = '^';
const END_FLAG = '$';
const BOUNDARY = '~';
const JOKER = '.*';
const ESCAPING = '\\';
/**
* @var string
*/
private $pattern;
/**
* @var string
*/
private $options;
/**
* @var bool
*/
private $startFlag;
/**
* @var bool
*/
private $endFlag;
/**
* @var bool
*/
private $startJoker;
/**
* @var bool
*/
private $endJoker;
/**
* @param string $expr
*
* @return self
*
* @throws \InvalidArgumentException
*/
public static function create($expr)
{
if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
$start = substr($m[1], 0, 1);
$end = substr($m[1], -1);
if (
($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
|| ('{' === $start && '}' === $end)
|| ('(' === $start && ')' === $end)
) {
return new self(substr($m[1], 1, -1), $m[2], $end);
}
}
throw new \InvalidArgumentException('Given expression is not a regex.');
}
/**
* @param string $pattern
* @param string $options
* @param string $delimiter
*/
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;
}
/**
* @return string
*/
public function __toString()
{
return $this->render();
}
/**
* {@inheritdoc}
*/
public function render()
{
return self::BOUNDARY
.$this->renderPattern()
.self::BOUNDARY
.$this->options;
}
/**
* {@inheritdoc}
*/
public function renderPattern()
{
return ($this->startFlag ? self::START_FLAG : '')
.($this->startJoker ? self::JOKER : '')
.str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
.($this->endJoker ? self::JOKER : '')
.($this->endFlag ? self::END_FLAG : '');
}
/**
* {@inheritdoc}
*/
public function isCaseSensitive()
{
return !$this->hasOption('i');
}
/**
* {@inheritdoc}
*/
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
*
* @return bool
*/
public function hasOption($option)
{
return false !== strpos($this->options, $option);
}
/**
* @param string $option
*
* @return $this
*/
public function addOption($option)
{
if (!$this->hasOption($option)) {
$this->options .= $option;
}
return $this;
}
/**
* @param string $option
*
* @return $this
*/
public function removeOption($option)
{
$this->options = str_replace($option, '', $this->options);
return $this;
}
/**
* @param bool $startFlag
*
* @return $this
*/
public function setStartFlag($startFlag)
{
$this->startFlag = $startFlag;
return $this;
}
/**
* @return bool
*/
public function hasStartFlag()
{
return $this->startFlag;
}
/**
* @param bool $endFlag
*
* @return $this
*/
public function setEndFlag($endFlag)
{
$this->endFlag = (bool) $endFlag;
return $this;
}
/**
* @return bool
*/
public function hasEndFlag()
{
return $this->endFlag;
}
/**
* @param bool $startJoker
*
* @return $this
*/
public function setStartJoker($startJoker)
{
$this->startJoker = $startJoker;
return $this;
}
/**
* @return bool
*/
public function hasStartJoker()
{
return $this->startJoker;
}
/**
* @param bool $endJoker
*
* @return $this
*/
public function setEndJoker($endJoker)
{
$this->endJoker = (bool) $endJoker;
return $this;
}
/**
* @return bool
*/
public function hasEndJoker()
{
return $this->endJoker;
}
/**
* @return $this
*/
public function replaceJokers($replacement)
{
$replace = function ($subject) use ($replacement) {
$subject = $subject[0];
$replace = 0 === substr_count($subject, '\\') % 2;
return $replace ? str_replace('.', $replacement, $subject) : $subject;
};
$this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
return $this;
}
/**
* @param string $pattern
*/
private function parsePattern($pattern)
{
if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
$pattern = substr($pattern, 1);
}
if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
$pattern = substr($pattern, 2);
}
if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
$pattern = substr($pattern, 0, -1);
}
if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
$pattern = substr($pattern, 0, -2);
}
$this->pattern = $pattern;
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Finder\Expression;
@trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
interface ValueInterface
{
/**
* Renders string representation of expression.
*
* @return string
*/
public function render();
/**
* Renders string representation of pattern.
*
* @return string
*/
public function renderPattern();
/**
* Returns value case sensitivity.
*
* @return bool
*/
public function isCaseSensitive();
/**
* Returns expression type.
*
* @return int
*/
public function getType();
/**
* @param string $expr
*
* @return $this
*/
public function prepend($expr);
/**
* @param string $expr
*
* @return $this
*/
public function append($expr);
}