diff --git a/box.json b/box.json index 8416a9e9..22c5598e 100644 --- a/box.json +++ b/box.json @@ -5,7 +5,6 @@ "directories-bin": [ "config", "home", - "vendor/twig/twig/lib", "vendor/twig/twig/src" ], "files-bin": [ diff --git a/composer.json b/composer.json index 10553786..57a2db80 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "symfony/expression-language": "^6.1", "symfony/finder": "^6.1", "symfony/yaml": "^6.1", - "twig/twig": "^2.16.1", + "twig/twig": "^3.22", "composer/semver": "^3.4" }, "require-dev": { @@ -59,9 +59,6 @@ "config": { "allow-plugins": { "bamarni/composer-bin-plugin": true - }, - "audit": { - "block-insecure": false } } } diff --git a/composer.lock b/composer.lock index 30d95584..9afdd735 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9b9f67d0458b0da16619fe17cc362d3f", + "content-hash": "67289587712e907dc030733522d22224", "packages": [ { "name": "composer/semver", @@ -1485,82 +1485,6 @@ ], "time": "2024-12-23T08:48:59+00:00" }, - { - "name": "symfony/polyfill-php72", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, { "name": "symfony/service-contracts", "version": "v3.6.1", @@ -1888,38 +1812,37 @@ }, { "name": "twig/twig", - "version": "v2.16.1", + "version": "v3.22.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "19185947ec75d433a3ac650af32fc05649b95ee1" + "reference": "4509984193026de413baf4ba80f68590a7f2c51d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/19185947ec75d433a3ac650af32fc05649b95ee1", - "reference": "19185947ec75d433a3ac650af32fc05649b95ee1", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/4509984193026de413baf4ba80f68590a7f2c51d", + "reference": "4509984193026de413baf4ba80f68590a7f2c51d", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=8.1.0", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.8" + "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { - "psr/container": "^1.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3" + "phpstan/phpstan": "^2.0", + "psr/container": "^1.0|^2.0", + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.16-dev" - } - }, "autoload": { - "psr-0": { - "Twig_": "lib/" - }, + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -1952,7 +1875,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v2.16.1" + "source": "https://github.com/twigphp/Twig/tree/v3.22.0" }, "funding": [ { @@ -1964,7 +1887,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T17:53:56+00:00" + "time": "2025-10-29T15:56:47+00:00" } ], "packages-dev": [ diff --git a/src/Twig/EnvironmentBuilder.php b/src/Twig/EnvironmentBuilder.php index c836a5f2..630a4a1c 100644 --- a/src/Twig/EnvironmentBuilder.php +++ b/src/Twig/EnvironmentBuilder.php @@ -4,13 +4,15 @@ use my127\Workspace\Path\Path; use my127\Workspace\Twig\Loader\Filesystem; +use Twig\Environment; +use Twig\TwigFunction; class EnvironmentBuilder { /** @var Path */ private $path; - /** @var \Twig_Function[] */ + /** @var TwigFunction[] */ private $functions = []; /** @var mixed[] */ @@ -23,7 +25,7 @@ public function __construct(Path $path) public function addFunction(string $name, callable $function): void { - $this->functions[$name] = new \Twig_Function($name, $function); + $this->functions[$name] = new TwigFunction($name, $function); } public function addGlobal(string $name, $value) @@ -31,12 +33,12 @@ public function addGlobal(string $name, $value) $this->globals[$name] = $value; } - public function create(string $path): \Twig_Environment + public function create(string $path): Environment { $directory = $this->path->getRealPath($path); $loader = new Filesystem([$directory], $directory); - $environment = new \Twig_Environment($loader, [ + $environment = new Environment($loader, [ 'autoescape' => false, ]); diff --git a/src/Twig/Loader/Filesystem.php b/src/Twig/Loader/Filesystem.php index 6521f111..b57170ec 100644 --- a/src/Twig/Loader/Filesystem.php +++ b/src/Twig/Loader/Filesystem.php @@ -2,7 +2,10 @@ namespace my127\Workspace\Twig\Loader; -class Filesystem extends \Twig_Loader_Filesystem +use Twig\Loader\FilesystemLoader; +use Twig\Source; + +class Filesystem extends FilesystemLoader { private $path; @@ -13,7 +16,7 @@ public function __construct($paths = [], ?string $rootPath = null) $this->path = $rootPath; } - public function getSourceContext($name) + public function getSourceContext($name): Source { $path = $this->findTemplate($name); $content = file_get_contents($path); @@ -21,7 +24,7 @@ public function getSourceContext($name) $content = str_replace("@('", "attr('", $content); $content = str_replace('@("', 'attr("', $content); - return new \Twig_Source($content, $name, $path); + return new Source($content, $name, $path); } public function getRootPath(): string diff --git a/src/Types/Confd/Confd.php b/src/Types/Confd/Confd.php index 32abd323..dfb927ed 100644 --- a/src/Types/Confd/Confd.php +++ b/src/Types/Confd/Confd.php @@ -5,6 +5,7 @@ use my127\Workspace\Expression\Expression; use my127\Workspace\Path\Path; use my127\Workspace\Twig\Loader\Filesystem; +use Twig\Environment; class Confd { @@ -14,7 +15,7 @@ class Confd private $definition; /** - * @var \Twig_Environment + * @var Environment */ private $twig; @@ -33,7 +34,7 @@ class Confd */ private $rootPath; - public function __construct(Path $path, Definition $definition, \Twig_Environment $twig, Expression $expression) + public function __construct(Path $path, Definition $definition, Environment $twig, Expression $expression) { $this->definition = $definition; $this->twig = $twig;