Skip to content

Commit

Permalink
build: Add missing public scope to functions and properties
Browse files Browse the repository at this point in the history
Fix phpcs rules

Change-Id: Id7c0effa5859ec7a4bef216afa7570e3118cb137
  • Loading branch information
umherirrender committed Aug 3, 2023
1 parent 9a960cb commit b31872e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 45 deletions.
4 changes: 0 additions & 4 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="PSR2.Classes.PropertyDeclaration.ScopeMissing" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="PSR2.Classes.PropertyDeclaration.VarUsed" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Squiz.Scope.MemberVarScope.Missing" />
<exclude name="Squiz.Scope.MethodScope.Missing" />
</rule>
<rule ref="Generic.Files.LineLength">
<properties>
Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/Less/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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' ) {
Expand Down Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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] );
Expand Down Expand Up @@ -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 ) {
Expand Down
10 changes: 5 additions & 5 deletions lib/Less/Tree/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 ) {
Expand Down Expand Up @@ -295,7 +295,7 @@ public function matchCondition( $args, $env ) {
return true;
}

function resetCache() {
public function resetCache() {
$this->_rulesets = null;
$this->_variables = null;
$this->lookups = [];
Expand Down Expand Up @@ -458,7 +458,7 @@ public function genCSS( $output ) {
}
}

function markReferenced() {
public function markReferenced() {
if ( !$this->selectors ) {
return;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Less/Tree/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/
class Less_Tree_Unit extends Less_Tree {

var $numerator = [];
var $denominator = [];
public $numerator = [];
public $denominator = [];
public $backupUnit;
public $type = 'Unit';

Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Tree/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
46 changes: 23 additions & 23 deletions test/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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 .= '<link rel="stylesheet/less" type="text/css" href="' . $less . '" />';
}

function CompareFiles( $generated, $lessjs, $expected ) {
public function CompareFiles( $generated, $lessjs, $expected ) {
$generated = trim( $generated );
$lessjs = trim( $lessjs );

Expand All @@ -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 ) ) {
Expand All @@ -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 ) ) {
Expand All @@ -331,21 +331,21 @@ function ObjBuffer() {
echo '<div id="diffoutput"></div>';
}

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 );

Expand All @@ -355,7 +355,7 @@ function LineDiff( $compiled, $css ) {
return max( count( $diff1 ), count( $diff2 ) );
}

function Links() {
public function Links() {
echo '<ul id="links">';
foreach ( $this->test_dirs as $dir ) {
$class = '';
Expand All @@ -367,7 +367,7 @@ function Links() {
echo '</ul>';
}

function Summary() {
public function Summary() {
if ( !$this->files_tested ) {
return;
}
Expand All @@ -392,7 +392,7 @@ function Summary() {
echo '</div>';
}

function microtime_diff( $a, $b = false, $eff = 6 ) {
public function microtime_diff( $a, $b = false, $eff = 6 ) {
if ( !$b ) {
$b = microtime();
}
Expand All @@ -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 '<div style="float:right">';
Expand All @@ -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
Expand Down

0 comments on commit b31872e

Please sign in to comment.