1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

MDL-76415 lib: Fixed ${var} string interpolation deprecations in php-ml

Since PHP 8.2, placing the dollar sign outside the curly brace is deprecated when
the expression inside the braces resolves to a variable or an expression.
This commit is contained in:
Meirza 2023-01-26 06:12:54 +07:00
parent 1ea152c99a
commit 89131a73c2
6 changed files with 15 additions and 10 deletions
lib/mlbackend/php/phpml
readme_moodle.txt
src/Phpml
Classification
FeatureExtraction
Helper

@ -1,8 +1,13 @@
Current version is 0.8.0
# Download latest stable version from https://github.com/php-ai/php-ml
# Download latest stable version from https://github.com/jorgecasas/php-ml
# Remove all files but:
* src/
* LICENSE
# Copy content of src/ to /path/to/moodle/lib/mlbackend/php/phpml/src/Phpml
# Copy LICENSE file to /path/to/moodle/lib/mlbackend/php/phpml
# Applied patch https://github.com/jorgecasas/php-ml/pull/5
2023/01/26
----------
- Changing the repository URL to https://github.com/jorgecasas/php-ml

@ -386,9 +386,9 @@ class DecisionTree implements Classifier
$median = Mean::median($values);
foreach ($values as &$value) {
if ($value <= $median) {
$value = "<= ${median}";
$value = "<= {$median}";
} else {
$value = "> ${median}";
$value = "> {$median}";
}
}
}

@ -122,7 +122,7 @@ class DecisionTreeLeaf
public function getHTML(?array $columnNames = null): string
{
if ($this->isTerminal) {
$value = "<b>${this}->classValue</b>";
$value = "<b>{$this}->classValue</b>";
} else {
$value = $this->value;
if ($columnNames !== null) {
@ -132,13 +132,13 @@ class DecisionTreeLeaf
}
if ((bool) preg_match('/^[<>=]{1,2}/', (string) $value) === false) {
$value = "=${value}";
$value = "={$value}";
}
$value = "<b>${col} ${value}</b><br>Gini: ".number_format($this->giniIndex, 2);
$value = "<b>{$col} {$value}</b><br>Gini: ".number_format($this->giniIndex, 2);
}
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>${value}</td></tr>";
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>{$value}</td></tr>";
if ($this->leftLeaf !== null || $this->rightLeaf !== null) {
$str .= '<tr>';

@ -87,7 +87,7 @@ class DecisionStump extends WeightedClassifier
public function __toString(): string
{
return "IF ${this}->column ${this}->operator ${this}->value ".
return "IF {$this->column} {$this->operator} {$this->value} ".
'THEN '.$this->binaryLabels[0].' '.
'ELSE '.$this->binaryLabels[1];
}

@ -25,7 +25,7 @@ class StopWords
public static function factory(string $language = 'English'): self
{
$className = __NAMESPACE__."\\StopWords\\${language}";
$className = __NAMESPACE__."\\StopWords\\{$language}";
if (!class_exists($className)) {
throw new InvalidArgumentException(sprintf('Can\'t find "%s" language for StopWords', $language));

@ -157,7 +157,7 @@ trait OneVsRest
*/
private function binarizeTargets(array $targets, $label): array
{
$notLabel = "not_${label}";
$notLabel = "not_{$label}";
foreach ($targets as $key => $target) {
$targets[$key] = $target == $label ? $label : $notLabel;
}