This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

View File

@@ -29,6 +29,8 @@ class ChainExtractor implements ExtractorInterface
/**
* Adds a loader to the translation extractor.
*
* @return void
*/
public function addExtractor(string $format, ExtractorInterface $extractor)
{
@@ -36,7 +38,7 @@ class ChainExtractor implements ExtractorInterface
}
/**
* {@inheritdoc}
* @return void
*/
public function setPrefix(string $prefix)
{
@@ -46,7 +48,7 @@ class ChainExtractor implements ExtractorInterface
}
/**
* {@inheritdoc}
* @return void
*/
public function extract(string|iterable $directory, MessageCatalogue $catalogue)
{

View File

@@ -25,11 +25,15 @@ interface ExtractorInterface
* Extracts translation messages from files, a file or a directory to the catalogue.
*
* @param string|iterable<string> $resource Files, a file or a directory
*
* @return void
*/
public function extract(string|iterable $resource, MessageCatalogue $catalogue);
/**
* Sets the prefix that should be used for new found messages.
*
* @return void
*/
public function setPrefix(string $prefix);
}

View File

@@ -11,6 +11,8 @@
namespace Symfony\Component\Translation\Extractor;
trigger_deprecation('symfony/translation', '6.2', '"%s" is deprecated, use "%s" instead.', PhpExtractor::class, PhpAstExtractor::class);
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\MessageCatalogue;
@@ -18,6 +20,8 @@ use Symfony\Component\Translation\MessageCatalogue;
* PhpExtractor extracts translation messages from a PHP template.
*
* @author Michel Salib <michelsalib@hotmail.com>
*
* @deprecated since Symfony 6.2, use the PhpAstExtractor instead
*/
class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
{
@@ -129,7 +133,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
];
/**
* {@inheritdoc}
* @return void
*/
public function extract(string|iterable $resource, MessageCatalogue $catalog)
{
@@ -142,7 +146,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
}
/**
* {@inheritdoc}
* @return void
*/
public function setPrefix(string $prefix)
{
@@ -164,7 +168,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
/**
* Seeks to a non-whitespace token.
*/
private function seekToNextRelevantToken(\Iterator $tokenIterator)
private function seekToNextRelevantToken(\Iterator $tokenIterator): void
{
for (; $tokenIterator->valid(); $tokenIterator->next()) {
$t = $tokenIterator->current();
@@ -174,7 +178,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
}
}
private function skipMethodArgument(\Iterator $tokenIterator)
private function skipMethodArgument(\Iterator $tokenIterator): void
{
$openBraces = 0;
@@ -199,7 +203,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
* Extracts the message from the iterator while the tokens
* match allowed message tokens.
*/
private function getValue(\Iterator $tokenIterator)
private function getValue(\Iterator $tokenIterator): string
{
$message = '';
$docToken = '';
@@ -257,6 +261,8 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
/**
* Extracts trans message from PHP tokens.
*
* @return void
*/
protected function parseTokens(array $tokens, MessageCatalogue $catalog, string $filename)
{
@@ -314,9 +320,6 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION);
}
/**
* {@inheritdoc}
*/
protected function extractFromDirectory(string|array $directory): iterable
{
if (!class_exists(Finder::class)) {

View File

@@ -11,6 +11,8 @@
namespace Symfony\Component\Translation\Extractor;
trigger_deprecation('symfony/translation', '6.2', '"%s" is deprecated.', PhpStringTokenParser::class);
/*
* The following is derived from code at http://github.com/nikic/PHP-Parser
*
@@ -47,6 +49,9 @@ namespace Symfony\Component\Translation\Extractor;
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @deprecated since Symfony 6.2
*/
class PhpStringTokenParser
{
protected static $replacements = [
@@ -89,7 +94,7 @@ class PhpStringTokenParser
* @param string $str String without quotes
* @param string|null $quote Quote type
*/
public static function parseEscapeSequences(string $str, string $quote = null): string
public static function parseEscapeSequences(string $str, ?string $quote = null): string
{
if (null !== $quote) {
$str = str_replace('\\'.$quote, $quote, $str);