Skip to content

Commit 80fa33e

Browse files
committed
build: Upgrade mediawiki-phan-config for PHP 8.5 support
Bug: T406326 Change-Id: I90a2fd1aa8fd1a644ef831e19d0cea67687a44e8
1 parent 6bf62d5 commit 80fa33e

11 files changed

Lines changed: 18 additions & 21 deletions

File tree

.phan/config.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<?php
22

3-
// NOTE: Automatically re-enable after each update unless someone updates
4-
// this str_contains check, to avoid forgetting and losing Phan coverage.
5-
$composerJson = file_get_contents( __DIR__ . '/../composer.json' );
6-
if (
7-
version_compare( PHP_VERSION, '8.5.0' ) >= 0
8-
&& str_contains( $composerJson, '"mediawiki/mediawiki-phan-config": "0.18.0"' )
9-
) {
10-
print "Skipping Phan on PHP 8.5. https://phabricator.wikimedia.org/T406326\n\n";
11-
exit( 0 );
12-
}
13-
143
return [
154

165
'target_php_version' => '8.1',

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"require-dev": {
4747
"mediawiki/mediawiki-codesniffer": "48.0.0",
48-
"mediawiki/mediawiki-phan-config": "0.18.0",
48+
"mediawiki/mediawiki-phan-config": "0.19.0",
4949
"mediawiki/minus-x": "1.1.3",
5050
"php-parallel-lint/php-console-highlighter": "1.0.0",
5151
"php-parallel-lint/php-parallel-lint": "1.4.0",

lib/Less/ImportVisitor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function processImportNode( $importNode, $env, &$importParent ) {
122122
}
123123

124124
$e = null;
125+
$root = null;
125126
try {
126127
if ( $importNode->options['inline'] ) {
127128
if ( !file_exists( $fullPath ) ) {

lib/Less/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ public function getCss() {
226226
$locale = setlocale( LC_NUMERIC, 0 );
227227
setlocale( LC_NUMERIC, "C" );
228228

229+
$css = '';
229230
try {
230231
$root = new Less_Tree_Ruleset( null, $this->rules );
231232
$root->root = true;
@@ -340,7 +341,6 @@ private function getVariableValue( Less_Tree $var ) {
340341
$return = [];
341342
if ( is_array( $var->value ) ) {
342343
// in compilation phase, Less_Tree_Anonymous::$val can be a Less_Tree[]
343-
// @phan-suppress-next-line PhanTypeMismatchForeach
344344
foreach ( $var->value as $value ) {
345345
/** @var Less_Tree $value */
346346
$return[ $value->name ] = $this->getVariableValue( $value );

lib/Less/Tree.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public static function nodeCompare( $a, $b ) {
140140
) {
141141
// for "symmetric results" force toCSS-based comparison via b.compare()
142142
// of Quoted or Anonymous if either value is one of those
143-
// @phan-suppress-next-line PhanUndeclaredMethod
144143
return $a->compare( $b );
145144
} elseif ( $bHasCompare ) {
146145
$res = $b->compare( $a );
@@ -153,7 +152,6 @@ public static function nodeCompare( $a, $b ) {
153152
}
154153

155154
// Less_Tree subclasses that have an array value: Less_Tree_Expression, Less_Tree_Value
156-
// @phan-suppress-next-line PhanUndeclaredProperty
157155
$aval = $a->value ?? [];
158156
$bval = $b->value ?? [];
159157
if ( !( $a instanceof Less_Tree_Expression || $a instanceof Less_Tree_Value ) ) {

lib/Less/Tree/Attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* @see less-2.5.3.js#Attribute.prototype
55
*/
66
class Less_Tree_Attribute extends Less_Tree implements Less_Tree_HasValueProperty {
7-
/** @var string */
7+
/** @var string|Less_Tree */
88
public $key;
99
/** @var null|string */
1010
public $op;
1111
/** @var null|string|Less_Tree */
1212
public $value;
1313

1414
/**
15-
* @param string $key
15+
* @param string|Less_Tree $key
1616
* @param null|string $op
1717
* @param null|string|Less_Tree $value
1818
*/

lib/Less/Tree/Declaration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Less_Tree_Declaration extends Less_Tree implements Less_Tree_HasValuePrope
88

99
/** @var string|array<Less_Tree_Keyword|Less_Tree_Variable> */
1010
public $name;
11-
/** @var Less_Tree[]|Less_Tree_Anonymous */
11+
/** @var Less_Tree */
1212
public $value;
1313
/** @var string */
1414
public $important;
@@ -171,6 +171,7 @@ public function mark( $value ) {
171171
if ( !is_array( $this->value ) ) {
172172

173173
if ( method_exists( $value, 'markReferenced' ) ) {
174+
// @phan-suppress-next-line PhanUndeclaredMethod
174175
$value->markReferenced();
175176
}
176177
} else {

lib/Less/Tree/Expression.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Less_Tree_Expression extends Less_Tree implements Less_Tree_HasValueProper
1212
/** @var true|null */
1313
public $parens = null;
1414

15+
/**
16+
* @param Less_Tree[] $value
17+
* @param bool $noSpacing
18+
*/
1519
public function __construct( $value, $noSpacing = false ) {
1620
$this->value = $value;
1721
$this->noSpacing = $noSpacing;
@@ -71,8 +75,10 @@ public function genCSS( $output ) {
7175
$this->value[$i]->genCSS( $output );
7276
if ( !$this->noSpacing && ( $i + 1 < $val_len ) ) {
7377
// NOTE: Comma handling backported from Less.js 4.2.1 (T386077)
74-
if ( !( $this->value[$i + 1] instanceof Less_Tree_Anonymous )
75-
|| ( $this->value[$i + 1] instanceof Less_Tree_Anonymous && $this->value[$i + 1]->value !== ',' )
78+
// Local variable helps phan to infer types on this condition
79+
$nextVal = $this->value[$i + 1];
80+
if ( !$nextVal instanceof Less_Tree_Anonymous
81+
|| $nextVal->value !== ','
7682
) {
7783
$output->add( ' ' );
7884
}

lib/Less/Tree/Mixin/Definition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function compileParams( $env, $mixinFrames, $args = [], &$evaldArguments
106106
$expression = new Less_Tree_Expression( $varargs );
107107
array_unshift( $frame->rules, new Less_Tree_Declaration( $name, $expression->compile( $env ) ) );
108108
} else {
109+
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
109110
$val = ( $arg && $arg['value'] ) ? $arg['value'] : false;
110111

111112
if ( $val ) {

lib/Less/Tree/Operation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Less_Tree_Operation extends Less_Tree {
1414

1515
/**
1616
* @param string $op
17+
* @param Less_Tree[] $operands
18+
* @param bool $isSpaced
1719
*/
1820
public function __construct( $op, $operands, $isSpaced = false ) {
1921
$this->op = trim( $op );

0 commit comments

Comments
 (0)