| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @author Florian Schmitz, Brett Zamir, Nikolay Matsievsky, Cedric Morin, Christopher Finke, Mark Scherer, Tobias Bäthge |
| 8 | 8 | * @since 1.0.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +declare(strict_types=1); | |
| 12 | + | |
| 11 | 13 | // Prohibit direct script loading. |
| 12 | 14 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 13 | 15 | |
| 14 | 16 | /** |
| @@ -24,83 +26,73 @@ | ||
| 24 | 26 | /** |
| 25 | 27 | * TablePress_CSSTidy instance. |
| 26 | 28 | * |
| 27 | 29 | * @since 1.0.0 |
| 28 | - * @var TablePress_CSSTidy | |
| 29 | 30 | */ |
| 30 | - public $parser; | |
| 31 | + public \TablePress_CSSTidy $parser; | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * The parsed CSS. |
| 34 | 35 | * |
| 35 | 36 | * @since 1.0.0 |
| 36 | - * @var array | |
| 37 | 37 | */ |
| 38 | - public $css = array(); | |
| 38 | + public array $css = array(); | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * The output templates. |
| 42 | 42 | * |
| 43 | 43 | * @since 1.0.0 |
| 44 | - * @var array | |
| 45 | 44 | */ |
| 46 | - public $template = array(); | |
| 45 | + public array $template = array(); | |
| 47 | 46 | |
| 48 | 47 | /** |
| 49 | 48 | * The raw parsed CSS. |
| 50 | 49 | * |
| 51 | 50 | * @since 1.0.0 |
| 52 | - * @var array | |
| 53 | 51 | */ |
| 54 | - public $tokens = array(); | |
| 52 | + public array $tokens = array(); | |
| 55 | 53 | |
| 56 | 54 | /** |
| 57 | 55 | * The CSS charset. |
| 58 | 56 | * |
| 59 | 57 | * @since 1.0.0 |
| 60 | - * @var string | |
| 61 | 58 | */ |
| 62 | - public $charset = ''; | |
| 59 | + public string $charset = ''; | |
| 63 | 60 | |
| 64 | 61 | /** |
| 65 | 62 | * All @import URLs. |
| 66 | 63 | * |
| 67 | 64 | * @since 1.0.0 |
| 68 | - * @var array | |
| 69 | 65 | */ |
| 70 | - public $import = array(); | |
| 66 | + public array $import = array(); | |
| 71 | 67 | |
| 72 | 68 | /** |
| 73 | 69 | * The namespace. |
| 74 | 70 | * |
| 75 | 71 | * @since 1.0.0 |
| 76 | - * @var string | |
| 77 | 72 | */ |
| 78 | - public $namespace = ''; | |
| 73 | + public string $namespace = ''; | |
| 79 | 74 | |
| 80 | 75 | /** |
| 81 | 76 | * Saves the input CSS string. |
| 82 | 77 | * |
| 83 | 78 | * @since 1.0.0 |
| 84 | - * @var string | |
| 85 | 79 | */ |
| 86 | - public $input_css = ''; | |
| 80 | + public string $input_css = ''; | |
| 87 | 81 | |
| 88 | 82 | /** |
| 89 | 83 | * Saves the formatted CSS string. |
| 90 | 84 | * |
| 91 | 85 | * @since 1.0.0 |
| 92 | - * @var string | |
| 93 | 86 | */ |
| 94 | - public $output_css = ''; | |
| 87 | + public string $output_css = ''; | |
| 95 | 88 | |
| 96 | 89 | /** |
| 97 | 90 | * Saves the formatted CSS string (plain text). |
| 98 | 91 | * |
| 99 | 92 | * @since 1.0.0 |
| 100 | - * @var string | |
| 101 | 93 | */ |
| 102 | - public $output_css_plain = ''; | |
| 94 | + public string $output_css_plain = ''; | |
| 103 | 95 | |
| 104 | 96 | /** |
| 105 | 97 | * Constructor. |
| 106 | 98 | * |
| @@ -221,9 +213,9 @@ | ||
| 221 | 213 | } |
| 222 | 214 | if ( $this->parser->get_cfg( 'preserve_css' ) ) { |
| 223 | 215 | $token[1] = str_replace( ',', ",\n", $token[1] ); |
| 224 | 216 | } |
| 225 | - $out .= ( '@' !== $token[1][0] ) ? $template[2] . $this->_htmlsp( $token[1], $plain ) : $template[0] . $this->_htmlsp( $token[1], $plain ); | |
| 217 | + $out .= ( '' !== $token[1] && '@' !== $token[1][0] ) ? $template[2] . $this->_htmlsp( $token[1], $plain ) : $template[0] . $this->_htmlsp( $token[1], $plain ); | |
| 226 | 218 | $out .= $template[3]; |
| 227 | 219 | break; |
| 228 | 220 | case TablePress_CSSTidy::PROPERTY: |
| 229 | 221 | if ( 2 === $this->parser->get_cfg( 'case_properties' ) ) { |
| @@ -261,9 +253,12 @@ | ||
| 261 | 253 | $out = &$in_at_out[ $indent_level - 1 ]; |
| 262 | 254 | } else { |
| 263 | 255 | $out = &$output; |
| 264 | 256 | } |
| 265 | - $out .= $template[10] . $in_at_out[ $indent_level ]; | |
| 257 | + $out .= $template[10]; | |
| 258 | + if ( isset( $in_at_out[ $indent_level ] ) ) { | |
| 259 | + $out .= $in_at_out[ $indent_level ]; | |
| 260 | + } | |
| 266 | 261 | if ( TablePress_CSSTidy::AT_END !== $this->_seeknocomment( $key, 1 ) ) { |
| 267 | 262 | $out .= $template[9]; |
| 268 | 263 | } else { |
| 269 | 264 | $out .= rtrim( $template[9] ); |