Fixed ${var} string interpolation deprecations in PHP 8.1

This commit is contained in:
Meirza 2023-01-26 06:06:46 +07:00
parent 67f2c30ad4
commit c91a5b730e
5 changed files with 9 additions and 9 deletions

View File

@ -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}";
}
}
}

View File

@ -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>';

View File

@ -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];
}

View File

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

View File

@ -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;
}