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

@@ -1 +0,0 @@
*.php diff=php

View File

@@ -1,5 +0,0 @@
/composer.lock
/composer.phar
/.idea
/vendor

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.0.1@b1e2e30026936ef8d5bf6a354d1c3959b6231f44"/>

View File

@@ -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>

View File

@@ -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

View File

@@ -1,6 +1,6 @@
Text_Template
phpunit/php-text-template
Copyright (c) 2009-2015, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2009-2020, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -2,13 +2,11 @@
## Installation
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
To add this package as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-text-template` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Text_Template:
composer require phpunit/php-text-template
{
"require": {
"phpunit/php-text-template": "~1.2"
}
}
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

View File

@@ -17,13 +17,27 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues"
},
"config": {
"platform": {
"php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"require": {
"php": ">=5.3.3"
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"autoload": {
"classmap": [
"src/"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
}
}

View File

@@ -1,85 +1,76 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Text_Template package.
* 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;
/**
* A simple template engine.
*
* @since Class available since Release 1.0.0
*/
class Text_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
*/
protected $template = '';
private $template = '';
/**
* @var string
*/
protected $openDelimiter = '{';
private $openDelimiter;
/**
* @var string
*/
protected $closeDelimiter = '}';
private $closeDelimiter;
/**
* @var array
*/
protected $values = array();
private $values = [];
/**
* Constructor.
*
* @param string $file
* @throws InvalidArgumentException
*/
public function __construct($file = '', $openDelimiter = '{', $closeDelimiter = '}')
public function __construct(string $file = '', string $openDelimiter = '{', string $closeDelimiter = '}')
{
$this->setFile($file);
$this->openDelimiter = $openDelimiter;
$this->closeDelimiter = $closeDelimiter;
}
/**
* Sets the template file.
*
* @param string $file
* @throws InvalidArgumentException
*/
public function setFile($file)
public function setFile(string $file): void
{
$distFile = $file . '.dist';
if (file_exists($file)) {
$this->template = file_get_contents($file);
}
else if (file_exists($distFile)) {
} elseif (file_exists($distFile)) {
$this->template = file_get_contents($distFile);
}
else {
} else {
throw new InvalidArgumentException(
'Template file could not be loaded.'
sprintf(
'Failed to load template "%s"',
$file
)
);
}
}
/**
* Sets one or more template variables.
*
* @param array $values
* @param bool $merge
*/
public function setVar(array $values, $merge = TRUE)
public function setVar(array $values, bool $merge = true): void
{
if (!$merge || empty($this->values)) {
$this->values = $values;
@@ -88,14 +79,9 @@ class Text_Template
}
}
/**
* Renders the template and returns the result.
*
* @return string
*/
public function render()
public function render(): string
{
$keys = array();
$keys = [];
foreach ($this->values as $key => $value) {
$keys[] = $this->openDelimiter . $key . $this->closeDelimiter;
@@ -105,31 +91,17 @@ class Text_Template
}
/**
* Renders the template and writes the result to a file.
*
* @param string $target
* @codeCoverageIgnore
*/
public function renderTo($target)
public function renderTo(string $target): void
{
$fp = @fopen($target, 'wt');
if ($fp) {
fwrite($fp, $this->render());
fclose($fp);
} else {
$error = error_get_last();
if (!file_put_contents($target, $this->render())) {
throw new RuntimeException(
sprintf(
'Could not write to %s: %s',
$target,
substr(
$error['message'],
strpos($error['message'], ':') + 2
sprintf(
'Writing rendered result to "%s" failed',
$target
)
)
);
}
}
}

View File

@@ -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
{
}

View File

@@ -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
{
}

View File

@@ -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
{
}