From b31872e271a86980e31b76046403fe6e62d8d7ed Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Thu, 3 Aug 2023 23:54:50 +0200 Subject: [PATCH] build: Add missing public scope to functions and properties Fix phpcs rules Change-Id: Id7c0effa5859ec7a4bef216afa7570e3118cb137 --- .phpcs.xml | 4 ---- lib/Less/Cache.php | 2 +- lib/Less/Functions.php | 2 +- lib/Less/Parser.php | 16 +++++++------- lib/Less/Tree/Ruleset.php | 10 ++++----- lib/Less/Tree/Unit.php | 4 ++-- lib/Less/Tree/Value.php | 2 +- test/index.php | 46 +++++++++++++++++++-------------------- 8 files changed, 41 insertions(+), 45 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index 751da6da..fcf999a4 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -17,13 +17,9 @@ - - - - diff --git a/lib/Less/Cache.php b/lib/Less/Cache.php index 212bfa6a..d9a8bc55 100644 --- a/lib/Less/Cache.php +++ b/lib/Less/Cache.php @@ -264,7 +264,7 @@ public static function CleanCache() { /** * Get the list of less files and generated css file from a list file */ - static function ListFiles( $list_file, &$list, &$css_file_name ) { + public static function ListFiles( $list_file, &$list, &$css_file_name ) { $list = explode( "\n", file_get_contents( $list_file ) ); // pop the cached name that should match $compiled_name diff --git a/lib/Less/Functions.php b/lib/Less/Functions.php index 50e71aca..e958e77c 100644 --- a/lib/Less/Functions.php +++ b/lib/Less/Functions.php @@ -9,7 +9,7 @@ class Less_Functions { public $env; public $currentFileInfo; - function __construct( $env, array $currentFileInfo = null ) { + public function __construct( $env, array $currentFileInfo = null ) { $this->env = $env; $this->currentFileInfo = $currentFileInfo; } diff --git a/lib/Less/Parser.php b/lib/Less/Parser.php index bc9eb5a7..2b98ab8f 100644 --- a/lib/Less/Parser.php +++ b/lib/Less/Parser.php @@ -710,22 +710,22 @@ public function CacheFile( $file_path ) { } } - static function AddParsedFile( $file ) { + public static function AddParsedFile( $file ) { self::$imports[] = $file; } - static function AllParsedFiles() { + public static function AllParsedFiles() { return self::$imports; } /** * @param string $file */ - static function FileParsed( $file ) { + public static function FileParsed( $file ) { return in_array( $file, self::$imports ); } - function save() { + public function save() { $this->saveStack[] = $this->pos; } @@ -1288,7 +1288,7 @@ private function parseEntitiesDimension() { * * @return Less_Tree_UnicodeDescriptor|null */ - function parseUnicodeDescriptor() { + public function parseUnicodeDescriptor() { // Optimization: Hardcode first char, to avoid MatchReg() cost for common case $char = $this->input[$this->pos] ?? null; if ( $char !== 'U' ) { @@ -1366,7 +1366,7 @@ private function parseRulesetCall() { // // extend syntax - used to extend selectors // - function parseExtend( $isRule = false ) { + public function parseExtend( $isRule = false ) { $index = $this->pos; $extendList = []; @@ -2063,7 +2063,7 @@ private function parseRule( $tryAnonymous = null ) { } } - function parseAnonymousValue() { + public function parseAnonymousValue() { $match = $this->MatchReg( '/\\G([^@+\/\'"*`(;{}-]*);/' ); if ( $match ) { return new Less_Tree_Anonymous( $match[1] ); @@ -2375,7 +2375,7 @@ private function parseSub() { * * @return Less_Tree_Operation|null */ - function parseMultiplication() { + public function parseMultiplication() { $return = $m = $this->parseOperand(); if ( $return ) { while ( true ) { diff --git a/lib/Less/Tree/Ruleset.php b/lib/Less/Tree/Ruleset.php index 94418df5..c3304b35 100644 --- a/lib/Less/Tree/Ruleset.php +++ b/lib/Less/Tree/Ruleset.php @@ -244,7 +244,7 @@ private function PrepareRuleset( $env ) { return $ruleset; } - function evalImports( $env ) { + public function evalImports( $env ) { $rules_len = count( $this->rules ); for ( $i = 0; $i < $rules_len; $i++ ) { $rule = $this->rules[$i]; @@ -265,7 +265,7 @@ function evalImports( $env ) { } } - function makeImportant() { + public function makeImportant() { $important_rules = []; foreach ( $this->rules as $rule ) { if ( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset || $rule instanceof Less_Tree_NameValue ) { @@ -295,7 +295,7 @@ public function matchCondition( $args, $env ) { return true; } - function resetCache() { + public function resetCache() { $this->_rulesets = null; $this->_variables = null; $this->lookups = []; @@ -458,7 +458,7 @@ public function genCSS( $output ) { } } - function markReferenced() { + public function markReferenced() { if ( !$this->selectors ) { return; } @@ -711,7 +711,7 @@ private function addReplacementIntoPath( array $beginningPath, array $addPath, $ return $newSelectorPath; } - function mergeElementsOnToSelectors( $elements, &$selectors ) { + public function mergeElementsOnToSelectors( $elements, &$selectors ) { if ( !$elements ) { return; } diff --git a/lib/Less/Tree/Unit.php b/lib/Less/Tree/Unit.php index 2fd89276..eb0d6980 100644 --- a/lib/Less/Tree/Unit.php +++ b/lib/Less/Tree/Unit.php @@ -4,8 +4,8 @@ */ class Less_Tree_Unit extends Less_Tree { - var $numerator = []; - var $denominator = []; + public $numerator = []; + public $denominator = []; public $backupUnit; public $type = 'Unit'; diff --git a/lib/Less/Tree/Value.php b/lib/Less/Tree/Value.php index bf45caf3..52a62dbb 100644 --- a/lib/Less/Tree/Value.php +++ b/lib/Less/Tree/Value.php @@ -33,7 +33,7 @@ public function compile( $env ) { /** * @see Less_Tree::genCSS */ - function genCSS( $output ) { + public function genCSS( $output ) { $len = count( $this->value ); for ( $i = 0; $i < $len; $i++ ) { $this->value[$i]->genCSS( $output ); diff --git a/test/index.php b/test/index.php index e3bf6536..00ee8130 100644 --- a/test/index.php +++ b/test/index.php @@ -15,15 +15,15 @@ class ParserTest { - var $compress = false; - var $dir; - var $test_dirs = [ 'lessjs','bootstrap3' ]; - var $cache_dir; - var $head; - var $files_tested = 0; - var $matched_count = 0; - - function __construct() { + public $compress = false; + public $dir; + public $test_dirs = [ 'lessjs','bootstrap3' ]; + public $cache_dir; + public $head; + public $files_tested = 0; + public $matched_count = 0; + + public function __construct() { $this->cache_dir = __DIR__ . '/_cache'; if ( !is_writable( $this->cache_dir ) || !is_dir( $this->cache_dir ) ) { @@ -265,12 +265,12 @@ public function testLessJsCssGeneration( $dir, $less, $css, $map ) { return $matched; } - function LessLink( $less ) { + public function LessLink( $less ) { $less = $this->AbsoluteToRelative( $less ); $this->head .= ''; } - function CompareFiles( $generated, $lessjs, $expected ) { + public function CompareFiles( $generated, $lessjs, $expected ) { $generated = trim( $generated ); $lessjs = trim( $lessjs ); @@ -294,7 +294,7 @@ function CompareFiles( $generated, $lessjs, $expected ) { * The contents of these files are used by phpunit tests * */ - function SaveExpected( $file_expected, $compiled ) { + public function SaveExpected( $file_expected, $compiled ) { $name = basename( $file_expected ); $dir = dirname( $file_expected ); if ( !is_dir( $dir ) ) { @@ -313,14 +313,14 @@ function SaveExpected( $file_expected, $compiled ) { * eg: /Fixtures/less.js/css/filename.css -> /Fixtures/less.js/less/filename.less * */ - function TranslateFile( $file_css, $dir = 'less', $type = 'less' ) { + public function TranslateFile( $file_css, $dir = 'less', $type = 'less' ) { $filename = basename( $file_css ); $filename = substr( $filename, 0, -4 ); return dirname( dirname( $file_css ) ) . '/' . $dir . '/' . $filename . '.' . $type; } - function ObjBuffer() { + public function ObjBuffer() { global $obj_buffer; if ( !empty( $obj_buffer ) ) { @@ -331,21 +331,21 @@ function ObjBuffer() { echo '
'; } - function AbsoluteToRelative( $path ) { + public function AbsoluteToRelative( $path ) { if ( strpos( $path, $_SERVER['DOCUMENT_ROOT'] ) === 0 ) { $path = substr( $path, strlen( $_SERVER['DOCUMENT_ROOT'] ) ); } return $path; } - function ComparableSourceMap( $file ) { + public function ComparableSourceMap( $file ) { $content = file_get_contents( $file ); $array = json_decode( $content, true ); $array['mappings'] = explode( ';', $array['mappings'] ); return pre( $array ); } - function LineDiff( $compiled, $css ) { + public function LineDiff( $compiled, $css ) { $compiled = explode( "\n", $compiled ); $css = explode( "\n", $css ); @@ -355,7 +355,7 @@ function LineDiff( $compiled, $css ) { return max( count( $diff1 ), count( $diff2 ) ); } - function Links() { + public function Links() { echo ''; } - function Summary() { + public function Summary() { if ( !$this->files_tested ) { return; } @@ -392,7 +392,7 @@ function Summary() { echo ''; } - function microtime_diff( $a, $b = false, $eff = 6 ) { + public function microtime_diff( $a, $b = false, $eff = 6 ) { if ( !$b ) { $b = microtime(); } @@ -401,14 +401,14 @@ function microtime_diff( $a, $b = false, $eff = 6 ) { return sprintf( '%0.' . $eff . 'f', $b - $a ); } - static function FormatBytes( $size, $precision = 2 ) { + public static function FormatBytes( $size, $precision = 2 ) { $base = log( $size ) / log( 1024 ); $suffixes = [ 'B', 'KB', 'MB', 'GB', 'TB' ]; $floor = max( 0, floor( $base ) ); return round( pow( 1024, $base - $floor ), $precision ) . ' ' . $suffixes[$floor]; } - static function Options() { + public static function Options() { // debugging $request = str_replace( [ 'XDEBUG_PROFILE','XDEBUG_TRACE' ], '', $_SERVER['REQUEST_URI'] ); echo '
'; @@ -423,7 +423,7 @@ static function Options() { * Error Handling * */ - static function showError( $errno, $errmsg, $filename, $linenum ) { + public static function showError( $errno, $errmsg, $filename, $linenum ) { static $reported = []; // readable types