upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -49,13 +49,11 @@ abstract class AbstractFileExtractor
}
/**
* @param string $file
*
* @return bool
*
* @throws InvalidArgumentException
*/
protected function isFile($file)
protected function isFile(string $file)
{
if (!is_file($file)) {
throw new InvalidArgumentException(sprintf('The "%s" file does not exist.', $file));
@@ -65,16 +63,14 @@ abstract class AbstractFileExtractor
}
/**
* @param string $file
*
* @return bool
*/
abstract protected function canBeExtracted($file);
abstract protected function canBeExtracted(string $file);
/**
* @param string|array $resource Files, a file or a directory
*
* @return iterable files to be extracted
* @return iterable
*/
abstract protected function extractFromDirectory($resource);
}

View File

@@ -29,10 +29,8 @@ class ChainExtractor implements ExtractorInterface
/**
* Adds a loader to the translation extractor.
*
* @param string $format The format of the loader
*/
public function addExtractor($format, ExtractorInterface $extractor)
public function addExtractor(string $format, ExtractorInterface $extractor)
{
$this->extractors[$format] = $extractor;
}
@@ -40,7 +38,7 @@ class ChainExtractor implements ExtractorInterface
/**
* {@inheritdoc}
*/
public function setPrefix($prefix)
public function setPrefix(string $prefix)
{
foreach ($this->extractors as $extractor) {
$extractor->setPrefix($prefix);

View File

@@ -30,8 +30,6 @@ interface ExtractorInterface
/**
* Sets the prefix that should be used for new found messages.
*
* @param string $prefix The prefix
*/
public function setPrefix($prefix);
public function setPrefix(string $prefix);
}

View File

@@ -27,15 +27,11 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
/**
* Prefix for new found message.
*
* @var string
*/
private $prefix = '';
/**
* The sequence that captures translation messages.
*
* @var array
*/
protected $sequences = [
[
@@ -50,25 +46,83 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
],
[
'->',
'transChoice',
'trans',
'(',
self::MESSAGE_TOKEN,
],
[
'new',
'TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
',',
self::METHOD_ARGUMENTS_TOKEN,
',',
self::METHOD_ARGUMENTS_TOKEN,
',',
self::DOMAIN_TOKEN,
],
[
'->',
'trans',
'new',
'TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
],
[
'->',
'transChoice',
'new',
'\\',
'Symfony',
'\\',
'Component',
'\\',
'Translation',
'\\',
'TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
',',
self::METHOD_ARGUMENTS_TOKEN,
',',
self::DOMAIN_TOKEN,
],
[
'new',
'\Symfony\Component\Translation\TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
',',
self::METHOD_ARGUMENTS_TOKEN,
',',
self::DOMAIN_TOKEN,
],
[
'new',
'\\',
'Symfony',
'\\',
'Component',
'\\',
'Translation',
'\\',
'TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
],
[
'new',
'\Symfony\Component\Translation\TranslatableMessage',
'(',
self::MESSAGE_TOKEN,
],
[
't',
'(',
self::MESSAGE_TOKEN,
',',
self::METHOD_ARGUMENTS_TOKEN,
',',
self::DOMAIN_TOKEN,
],
[
't',
'(',
self::MESSAGE_TOKEN,
],
@@ -90,7 +144,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
/**
* {@inheritdoc}
*/
public function setPrefix($prefix)
public function setPrefix(string $prefix)
{
$this->prefix = $prefix;
}
@@ -207,17 +261,9 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
/**
* Extracts trans message from PHP tokens.
*
* @param array $tokens
* @param string $filename
*/
protected function parseTokens($tokens, MessageCatalogue $catalog/* , string $filename */)
protected function parseTokens(array $tokens, MessageCatalogue $catalog, string $filename)
{
if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED);
}
$filename = 2 < \func_num_args() ? func_get_arg(2) : '';
$tokenIterator = new \ArrayIterator($tokens);
for ($key = 0; $key < $tokenIterator->count(); ++$key) {
@@ -265,13 +311,11 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
}
/**
* @param string $file
*
* @return bool
*
* @throws \InvalidArgumentException
*/
protected function canBeExtracted($file)
protected function canBeExtracted(string $file)
{
return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION);
}
@@ -281,6 +325,10 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
*/
protected function extractFromDirectory($directory)
{
if (!class_exists(Finder::class)) {
throw new \LogicException(sprintf('You cannot use "%s" as the "symfony/finder" package is not installed. Try running "composer require symfony/finder".', static::class));
}
$finder = new Finder();
return $finder->files()->name('*.php')->in($directory);

View File

@@ -65,9 +65,9 @@ class PhpStringTokenParser
*
* @param string $str String token content
*
* @return string The parsed string
* @return string
*/
public static function parse($str)
public static function parse(string $str)
{
$bLength = 0;
if ('b' === $str[0]) {
@@ -91,9 +91,9 @@ class PhpStringTokenParser
* @param string $str String without quotes
* @param string|null $quote Quote type
*
* @return string String with escape sequences parsed
* @return string
*/
public static function parseEscapeSequences($str, $quote)
public static function parseEscapeSequences(string $str, string $quote = null)
{
if (null !== $quote) {
$str = str_replace('\\'.$quote, $quote, $str);
@@ -125,9 +125,9 @@ class PhpStringTokenParser
* @param string $startToken Doc string start token content (<<<SMTHG)
* @param string $str String token content
*
* @return string Parsed string
* @return string
*/
public static function parseDocString($startToken, $str)
public static function parseDocString(string $startToken, string $str)
{
// strip last newline (thanks tokenizer for sticking it into the string!)
$str = preg_replace('~(\r\n|\n|\r)$~', '', $str);