about summary refs log tree commit diff stats
path: root/vendor/phpunit/php-text-template
diff options
context:
space:
mode:
authorfox <fox@fakecake.org>2026-05-26 06:45:47 +0300
committerfox <fox@fakecake.org>2026-05-26 06:45:47 +0300
commit4ce7212e8c26cd613db0cfc75ef8a5a0ba6eb7be (patch)
tree0ec2e37f6f86d59a904a2f1de2a15294ef1ae349 /vendor/phpunit/php-text-template
parentcae514dddfc59f533a93a47afc283371d5949843 (diff)
parentdc60880d9cc4074a231fd21c9508d0f78beaf1f1 (diff)
downloadthe-epube-4ce7212e8c26cd613db0cfc75ef8a5a0ba6eb7be.tar.gz
the-epube-4ce7212e8c26cd613db0cfc75ef8a5a0ba6eb7be.tar.xz
Merge branch 'dev' into 'master'
Dev

See merge request git/the-epube!39
Diffstat (limited to 'vendor/phpunit/php-text-template')
-rw-r--r--vendor/phpunit/php-text-template/.psalm/baseline.xml2
-rw-r--r--vendor/phpunit/php-text-template/.psalm/config.xml16
-rw-r--r--vendor/phpunit/php-text-template/ChangeLog.md43
-rw-r--r--vendor/phpunit/php-text-template/LICENSE33
-rw-r--r--vendor/phpunit/php-text-template/README.md12
-rw-r--r--vendor/phpunit/php-text-template/composer.json43
-rw-r--r--vendor/phpunit/php-text-template/src/Template.php107
-rw-r--r--vendor/phpunit/php-text-template/src/exceptions/Exception.php16
-rw-r--r--vendor/phpunit/php-text-template/src/exceptions/InvalidArgumentException.php14
-rw-r--r--vendor/phpunit/php-text-template/src/exceptions/RuntimeException.php16
10 files changed, 302 insertions, 0 deletions
diff --git a/vendor/phpunit/php-text-template/.psalm/baseline.xml b/vendor/phpunit/php-text-template/.psalm/baseline.xml
new file mode 100644
index 0000000..77e688e
--- /dev/null
+++ b/vendor/phpunit/php-text-template/.psalm/baseline.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<files psalm-version="4.0.1@b1e2e30026936ef8d5bf6a354d1c3959b6231f44"/>
diff --git a/vendor/phpunit/php-text-template/.psalm/config.xml b/vendor/phpunit/php-text-template/.psalm/config.xml
new file mode 100644
index 0000000..2a4b16f
--- /dev/null
+++ b/vendor/phpunit/php-text-template/.psalm/config.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<psalm
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="https://getpsalm.org/schema/config"
+    xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
+    resolveFromConfigFile="false"
+    totallyTyped="false"
+    errorBaseline=".psalm/baseline.xml"
+>
+    <projectFiles>
+        <directory name="src" />
+        <ignoreFiles>
+            <directory name="vendor" />
+        </ignoreFiles>
+    </projectFiles>
+</psalm>
diff --git a/vendor/phpunit/php-text-template/ChangeLog.md b/vendor/phpunit/php-text-template/ChangeLog.md
new file mode 100644
index 0000000..32a48a7
--- /dev/null
+++ b/vendor/phpunit/php-text-template/ChangeLog.md
@@ -0,0 +1,43 @@
+# ChangeLog
+
+All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
+
+## [2.0.4] - 2020-10-26
+
+### Fixed
+
+* `SebastianBergmann\Template\Exception` now correctly extends `\Throwable`
+
+## [2.0.3] - 2020-09-28
+
+### Changed
+
+* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
+
+## [2.0.2] - 2020-06-26
+
+### Added
+
+* This component is now supported on PHP 8
+
+## [2.0.1] - 2020-06-15
+
+### Changed
+
+* Tests etc. are now ignored for archive exports
+
+## [2.0.0] - 2020-02-07
+
+### Changed
+
+* The `Text_Template` class was renamed to `SebastianBergmann\Template\Template`
+
+### Removed
+
+* Removed support for PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7.0, PHP 7.1, and PHP 7.2 
+
+[2.0.4]: https://github.com/sebastianbergmann/php-text-template/compare/2.0.3...2.0.4
+[2.0.3]: https://github.com/sebastianbergmann/php-text-template/compare/2.0.2...2.0.3
+[2.0.2]: https://github.com/sebastianbergmann/php-text-template/compare/2.0.1...2.0.2
+[2.0.1]: https://github.com/sebastianbergmann/php-text-template/compare/2.0.0...2.0.1
+[2.0.0]: https://github.com/sebastianbergmann/php-text-template/compare/1.2.1...2.0.0
diff --git a/vendor/phpunit/php-text-template/LICENSE b/vendor/phpunit/php-text-template/LICENSE
new file mode 100644
index 0000000..6db5566
--- /dev/null
+++ b/vendor/phpunit/php-text-template/LICENSE
@@ -0,0 +1,33 @@
+phpunit/php-text-template
+
+Copyright (c) 2009-2020, Sebastian Bergmann <sebastian@phpunit.de>.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+
+ * Neither the name of Sebastian Bergmann nor the names of his
+   contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/phpunit/php-text-template/README.md b/vendor/phpunit/php-text-template/README.md
new file mode 100644
index 0000000..b286593
--- /dev/null
+++ b/vendor/phpunit/php-text-template/README.md
@@ -0,0 +1,12 @@
+# Text_Template
+
+## Installation
+
+You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
+
+    composer require phpunit/php-text-template
+
+If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
+
+    composer require --dev phpunit/php-text-template
+
diff --git a/vendor/phpunit/php-text-template/composer.json b/vendor/phpunit/php-text-template/composer.json
new file mode 100644
index 0000000..a51b34b
--- /dev/null
+++ b/vendor/phpunit/php-text-template/composer.json
@@ -0,0 +1,43 @@
+{
+    "name": "phpunit/php-text-template",
+    "description": "Simple template engine.",
+    "type": "library",
+    "keywords": [
+        "template"
+    ],
+    "homepage": "https://github.com/sebastianbergmann/php-text-template/",
+    "license": "BSD-3-Clause",
+    "authors": [
+        {
+            "name": "Sebastian Bergmann",
+            "email": "sebastian@phpunit.de",
+            "role": "lead"
+        }
+    ],
+    "support": {
+        "issues": "https://github.com/sebastianbergmann/php-text-template/issues"
+    },
+    "config": {
+        "platform": {
+            "php": "7.3.0"
+        },
+        "optimize-autoloader": true,
+        "sort-packages": true
+    },
+    "require": {
+        "php": ">=7.3"
+    },
+    "require-dev": {
+        "phpunit/phpunit": "^9.3"
+    },
+    "autoload": {
+        "classmap": [
+            "src/"
+        ]
+    },
+    "extra": {
+        "branch-alias": {
+            "dev-master": "2.0-dev"
+        }
+    }
+}
diff --git a/vendor/phpunit/php-text-template/src/Template.php b/vendor/phpunit/php-text-template/src/Template.php
new file mode 100644
index 0000000..25e29ea
--- /dev/null
+++ b/vendor/phpunit/php-text-template/src/Template.php
@@ -0,0 +1,107 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of phpunit/php-text-template.
+ *
+ * (c) Sebastian Bergmann <sebastian@phpunit.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\Template;
+
+use function array_merge;
+use function file_exists;
+use function file_get_contents;
+use function file_put_contents;
+use function sprintf;
+use function str_replace;
+
+final class Template
+{
+    /**
+     * @var string
+     */
+    private $template = '';
+
+    /**
+     * @var string
+     */
+    private $openDelimiter;
+
+    /**
+     * @var string
+     */
+    private $closeDelimiter;
+
+    /**
+     * @var array
+     */
+    private $values = [];
+
+    /**
+     * @throws InvalidArgumentException
+     */
+    public function __construct(string $file = '', string $openDelimiter = '{', string $closeDelimiter = '}')
+    {
+        $this->setFile($file);
+
+        $this->openDelimiter  = $openDelimiter;
+        $this->closeDelimiter = $closeDelimiter;
+    }
+
+    /**
+     * @throws InvalidArgumentException
+     */
+    public function setFile(string $file): void
+    {
+        $distFile = $file . '.dist';
+
+        if (file_exists($file)) {
+            $this->template = file_get_contents($file);
+        } elseif (file_exists($distFile)) {
+            $this->template = file_get_contents($distFile);
+        } else {
+            throw new InvalidArgumentException(
+                sprintf(
+                    'Failed to load template "%s"',
+                    $file
+                )
+            );
+        }
+    }
+
+    public function setVar(array $values, bool $merge = true): void
+    {
+        if (!$merge || empty($this->values)) {
+            $this->values = $values;
+        } else {
+            $this->values = array_merge($this->values, $values);
+        }
+    }
+
+    public function render(): string
+    {
+        $keys = [];
+
+        foreach ($this->values as $key => $value) {
+            $keys[] = $this->openDelimiter . $key . $this->closeDelimiter;
+        }
+
+        return str_replace($keys, $this->values, $this->template);
+    }
+
+    /**
+     * @codeCoverageIgnore
+     */
+    public function renderTo(string $target): void
+    {
+        if (!file_put_contents($target, $this->render())) {
+            throw new RuntimeException(
+                sprintf(
+                    'Writing rendered result to "%s" failed',
+                    $target
+                )
+            );
+        }
+    }
+}
diff --git a/vendor/phpunit/php-text-template/src/exceptions/Exception.php b/vendor/phpunit/php-text-template/src/exceptions/Exception.php
new file mode 100644
index 0000000..d7dc5cb
--- /dev/null
+++ b/vendor/phpunit/php-text-template/src/exceptions/Exception.php
@@ -0,0 +1,16 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of phpunit/php-text-template.
+ *
+ * (c) Sebastian Bergmann <sebastian@phpunit.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\Template;
+
+use Throwable;
+
+interface Exception extends Throwable
+{
+}
diff --git a/vendor/phpunit/php-text-template/src/exceptions/InvalidArgumentException.php b/vendor/phpunit/php-text-template/src/exceptions/InvalidArgumentException.php
new file mode 100644
index 0000000..10e1cd1
--- /dev/null
+++ b/vendor/phpunit/php-text-template/src/exceptions/InvalidArgumentException.php
@@ -0,0 +1,14 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of phpunit/php-text-template.
+ *
+ * (c) Sebastian Bergmann <sebastian@phpunit.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\Template;
+
+final class InvalidArgumentException extends \InvalidArgumentException implements Exception
+{
+}
diff --git a/vendor/phpunit/php-text-template/src/exceptions/RuntimeException.php b/vendor/phpunit/php-text-template/src/exceptions/RuntimeException.php
new file mode 100644
index 0000000..131498e
--- /dev/null
+++ b/vendor/phpunit/php-text-template/src/exceptions/RuntimeException.php
@@ -0,0 +1,16 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of phpunit/php-text-template.
+ *
+ * (c) Sebastian Bergmann <sebastian@phpunit.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\Template;
+
+use InvalidArgumentException;
+
+final class RuntimeException extends InvalidArgumentException implements Exception
+{
+}