Skip to content

Commit

Permalink
Apply some changes from latest upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Dec 15, 2022
1 parent b47b131 commit dd65eaa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 62 deletions.
1 change: 0 additions & 1 deletion .github/workflows/unittests.yml
Expand Up @@ -13,7 +13,6 @@ jobs:
matrix:
os: ['ubuntu-latest']
php: ['8.1', '8.2']
continue-on-error: ${{ matrix.php == '8.2' }}
steps:
- name: Set locales
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -18,7 +18,7 @@ Compatibility
| PHPTAL-Version | PHP-Version(s) |
|----------------|----------------|
| 3.x | 7.3, 7.4, 8.0 |
| master | 8.1 |
| master | 8.1, 8.2 |

Composer install (recommended)
==============================
Expand All @@ -45,4 +45,4 @@ If you would like to generate the offical html/text handbook by calling
your operating systems package manager to install it.

If you'd like to create the sourcecode documentation, you need the `phpDocumentor.phar` executable
in your `$PATH`.
in your `$PATH`.
14 changes: 6 additions & 8 deletions src/Dom/Element.php
Expand Up @@ -89,11 +89,6 @@ class Element extends Node
*/
public $childNodes = [];

/**
* @var XmlnsState
*/
private $xmlns;

/**
* @param string $qname qualified name of the element, e.g. "tal:block"
* @param string $namespace_uri namespace of this element
Expand All @@ -103,12 +98,15 @@ class Element extends Node
* @throws ParserException
* @throws TemplateException
*/
public function __construct(string $qname, string $namespace_uri, array $attribute_nodes, XmlnsState $xmlns)
{
public function __construct(
string $qname,
string $namespace_uri,
array $attribute_nodes,
private readonly XmlnsState $xmlns,
) {
$this->qualifiedName = $qname;
$this->attribute_nodes = $attribute_nodes;
$this->namespace_uri = $namespace_uri;
$this->xmlns = $xmlns;

// implements inheritance of element's namespace to tal attributes (<metal: use-macro>)
foreach ($attribute_nodes as $index => $attr) {
Expand Down
5 changes: 1 addition & 4 deletions src/Dom/PHPTALDocumentBuilder.php
Expand Up @@ -36,10 +36,7 @@ class PHPTALDocumentBuilder extends DocumentBuilder
*/
private $encoding;

/**
* @var Element
*/
private $documentElement;
private ?Element $documentElement = null;

/**
* PHPTALDocumentBuilder constructor.
Expand Down
10 changes: 2 additions & 8 deletions src/Php/Attribute/TAL/Attributes.php
Expand Up @@ -61,15 +61,9 @@ class Attributes extends Attribute implements TalesChainReaderInterface
*/
private $default_escaped;

/**
* @var string
*/
private $attribute;
private string $attribute = '';

/**
* @var string
*/
private $attkey;
private string $attkey = '';

/**
* Called before element printing.
Expand Down
26 changes: 5 additions & 21 deletions src/Php/TalesChainExecutor.php
Expand Up @@ -29,40 +29,24 @@ class TalesChainExecutor
*/
private $state = 0;

/**
* @var array<int, string>
*/
private $chain;

/**
* @var bool
*/
private $chainStarted = false;

/**
* @var CodeWriter
*/
private $codewriter;

/**
* @var TalesChainReaderInterface
*/
private $reader;

/**
* TalesChainExecutor constructor.
*
* @param CodeWriter $codewriter
* @param array<int, string> $chain
* @param TalesChainReaderInterface $reader
*
* @throws PhpTalException
*/
public function __construct(CodeWriter $codewriter, array $chain, TalesChainReaderInterface $reader)
{
public function __construct(
private readonly CodeWriter $codewriter,
private array $chain,
private readonly TalesChainReaderInterface $reader,
) {
$this->chain = $chain;
$this->codewriter = $codewriter;
$this->reader = $reader;
$this->executeChain();
}

Expand Down
23 changes: 5 additions & 18 deletions src/StringSource.php
Expand Up @@ -23,25 +23,12 @@ class StringSource implements SourceInterface
{
public const NO_PATH_PREFIX = '<string ';

/**
* @var string
*/
private $data;

/**
* @var string|null
*/
private $realpath;
private string $realpath;

/**
* StringSource constructor.
*
* @param string $data
* @param string $realpath
*/
public function __construct($data, ?string $realpath = null)
{
$this->data = $data;
public function __construct(
private string $data,
?string $realpath = null
) {
$this->realpath = $realpath ?? self::NO_PATH_PREFIX . md5($data) . '>';
}

Expand Down

0 comments on commit dd65eaa

Please sign in to comment.