Skip to content

Commit

Permalink
Added typed properties.
Browse files Browse the repository at this point in the history
Removed support for PHP 7.3.
Updated dependencies.
  • Loading branch information
hexydec committed Mar 4, 2022
1 parent 090d6dd commit 34622a7
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 76 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
],
"minimum-stability": "stable",
"require": {
"php": ">=7.3",
"hexydec/tokenise": "0.4.2",
"hexydec/cssdoc": "0.5.3",
"hexydec/jslite": "0.5.5"
"php": ">=7.4",
"hexydec/tokenise": "1.0.0",
"hexydec/cssdoc": "1.0.1",
"hexydec/jslite": "0.5.6"
},
"autoload": {
"classmap": ["src/"]
Expand Down
89 changes: 45 additions & 44 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/htmldoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
/**
* @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML
*/
protected static $tokens = [
protected static array $tokens = [
'textnode' => '(?<=>|^)[^<]++(?=<|$)',
'attributevalue' => '\\s*+=\\s*+(?:"[^"]*+"++|\'[^\']*+\'++|[^\\s>]*+)',
'attribute' => '\\s*+[^<>"\'\\/=\\s]++',
Expand All @@ -26,7 +26,7 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
/**
* @var array $selectors Regexp components keyed by their corresponding codename for tokenising CSS selectors
*/
protected static $selectors = [
protected static array $selectors = [
'quotes' => '(?<!\\\\)"(?:[^"\\\\]++|\\\\.)*+"',
'join' => '\\s*[>+~]\\s*',
'comparison' => '[\\^*$<>]?=', // comparison operators for media queries or attribute selectors
Expand All @@ -45,17 +45,17 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
/**
* @var array $children Stores the regexp components keyed by their corresponding codename for tokenising CSS selectors
*/
protected $children = [];
protected array $children = [];

/**
* @var int $pointer The current pointer position for the array iterator
*/
protected $pointer = 0;
protected int $pointer = 0;

/**
* @var array A cache of attribute and class names for sorting
*/
protected $cache = [];
protected array $cache = [];

/**
* Calculates the length property
Expand Down Expand Up @@ -88,8 +88,11 @@ public function toArray() : array {
* @param mixed $value The value of the array key in the children array to be updated
*/
public function offsetSet($i, $value) : void {
if (\is_null($i)) $this->children[] = $value;
else $this->children[$i] = $value;
if (\is_null($i)) {
$this->children[] = $value;
} else {
$this->children[$i] = $value;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class comment implements token {
/**
* @var string The text content of this object
*/
protected $content = null;
protected ?string $content = null;

/**
* Constructs the comment object
Expand Down
8 changes: 4 additions & 4 deletions src/tokens/custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ class custom implements token {
/**
* @var array The custom configuration
*/
protected $config = [];
protected array $config = [];

/**
* @var array The name of the tag
* @var string The name of the tag
*/
protected $tagName;
protected string $tagName;

/**
* @var string A string containing javascript
*/
protected $content = '';
protected string $content = '';

/**
* Constructs the script object
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/doctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class doctype implements token {
/**
* @var array The text content of this object
*/
protected $content = [];
protected array $content = [];

/**
* Constructs the script object
Expand Down
Loading

0 comments on commit 34622a7

Please sign in to comment.