Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/phpunit.xml.dist export-ignore
/phpunit.7.5.xml export-ignore
/tests/ export-ignore
/phpstan.neon.dist export-ignore
/.github/ export-ignore
/Docs/ export-ignore
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand All @@ -32,3 +32,8 @@ jobs:
else
vendor/bin/phpunit
fi
- name: Phpstan
run: |
if [ 1 -eq "$(echo "${{ matrix.php-versions }} > 7.1" | bc)" ]; then
vendor/bin/phpstan
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nbproject*
/phpunit.xml
/.phpunit.cache/
.unlock_css_optimiser
/phpstan.neon
18 changes: 13 additions & 5 deletions class.csstidy.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class csstidy {
* @access private
*/
public $from = array();
/**

/**
* =true if in invalid at-rule
* @var bool
Expand Down Expand Up @@ -254,8 +254,10 @@ class csstidy {
/**
* Various CSS Data for CSSTidy
* @var array
*
* @todo array{csstidy:array<string,mixed>}
*/
public $data = array();
public $data;

public $template;

Expand All @@ -266,6 +268,7 @@ class csstidy {
*/
public function __construct() {
$data = array();
// $data = ['csstidy' => []];
include(__DIR__ . DIRECTORY_SEPARATOR . 'data.inc.php');
$this->data = $data;

Expand Down Expand Up @@ -309,6 +312,7 @@ public function __construct() {
$this->set_cfg('template','default'); // call load_template
$this->optimise = new csstidy_optimise($this);

// @phpstan-ignore-next-line
$this->tokens_list = & $this->data['csstidy']['tokens'];
}

Expand Down Expand Up @@ -358,7 +362,7 @@ public function _load_template($template) {

/**
* Set the value of a setting.
* @param string $setting
* @param array|string $setting
* @param mixed $value
* @access public
* @return bool
Expand Down Expand Up @@ -575,6 +579,8 @@ public function is_token(&$string, $i) {
*/
public function parse($string) {
// Temporarily set locale to en_US in order to handle floats properly
// @todo Something $old = @setlocale(LC_ALL, '0');
// @see https://www.php.net/manual/en/function.setlocale.php#locales
$old = @setlocale(LC_ALL, 0);
@setlocale(LC_ALL, 'C');

Expand Down Expand Up @@ -1091,6 +1097,7 @@ public function css_add_property($media, $selector, $property, $new_val) {
*/
public function css_check_last_media_section_or_inc($media) {
// are we starting?
// @phpstan-ignore-next-line
if (!$this->css || !is_array($this->css) || empty($this->css)) {
return $media;
}
Expand Down Expand Up @@ -1119,7 +1126,7 @@ public function css_check_last_media_section_or_inc($media) {
* to avoid merging
*
* @param string $current_media
* @param string $media
* @param string $new_media
* @param bool $at_root
* @return string
*/
Expand Down Expand Up @@ -1233,6 +1240,7 @@ public function css_new_property($media, $selector, $property) {
*/
public function merge_css_blocks($media, $selector, $css_add) {
foreach ($css_add as $property => $value) {
// @phpstan-ignore-next-line
$this->css_add_property($media, $selector, $property, $value, false);
}
}
Expand Down Expand Up @@ -1321,7 +1329,7 @@ public function property_is_valid($property) {
* format("abc",'def') => format("abc","def")
* format("abc, def, ghi") => format("abc, def, ghi")
*
* @param string
* @param string $value
* @return array
*/
public function parse_string_list($value) {
Expand Down
11 changes: 6 additions & 5 deletions class.csstidy_optimise.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class csstidy_optimise {

/**
* Constructor
* @param array $css contains the class csstidy
* @param csstidy $css contains the class csstidy
* @access private
* @version 1.0
*/
Expand Down Expand Up @@ -473,7 +473,7 @@ public function compress_numbers($subvalue) {
* Checks if a given string is a CSS valid number. If it is,
* an array containing the value and unit is returned
* @param string $string
* @return array ('unit' if unit is found or '' if no unit exists, number value) or false if no number
* @return array|false ('unit' if unit is found or '' if no unit exists, number value) or false if no number
*/
public function AnalyseCssNumber($string) {
// most simple checks first
Expand Down Expand Up @@ -516,7 +516,7 @@ public function AnalyseCssNumber($string) {
* Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red}
* Very basic and has at least one bug. Hopefully there is a replacement soon.
* @param array $array
* @return array
* @return void
* @access public
* @version 1.2
*/
Expand Down Expand Up @@ -637,7 +637,7 @@ public function dissolve_4value_shorthands($property, $value, $shorthands = null
* @param string $value
* @return array
* @version 1.0
* @use dissolve_4value_shorthands()
* @uses dissolve_4value_shorthands()
* @see merge_4value_radius_shorthands()
*/
public function dissolve_4value_radius_shorthands($property, $value) {
Expand Down Expand Up @@ -750,7 +750,7 @@ public function merge_4value_shorthands($array, $shorthands = null) {
* @param array $array
* @return array
* @version 1.2
* @use merge_4value_shorthands()
* @uses merge_4value_shorthands()
* @see dissolve_4value_radius_shorthands()
*/
public function merge_4value_radius_shorthands($array) {
Expand Down Expand Up @@ -1043,6 +1043,7 @@ public function merge_font($input_css) {
// Skip if not font-family and font-size set
if (isset($input_css['font-family']) && isset($input_css['font-size']) && $input_css['font-family'] != 'inherit') {
// fix several words in font-family - add quotes
// @phpstan-ignore-next-line
if (isset($input_css['font-family'])) {
$families = explode(',', $input_css['font-family']);
$result_families = array();
Expand Down
4 changes: 2 additions & 2 deletions class.csstidy_print.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class csstidy_print {

/**
* Constructor
* @param array $css contains the class csstidy
* @param csstidy $css contains the class csstidy
* @access private
* @version 1.0
*/
Expand Down Expand Up @@ -446,7 +446,7 @@ public function get_ratio() {
/**
* Get difference between the old and new code in bytes and prints the code if necessary.
* @access public
* @return string
* @return int|string
* @version 1.1
*/
public function get_diff() {
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"php": "^7.1 || ^8"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5 || ^10.5"
},
"autoload": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:
phpVersion: 70100
paths:
- class.csstidy.php
- class.csstidy_optimise.php
- class.csstidy_print.php
level: 4
Loading