Merge pull request #5 from meirzamoodle/fix_str_interpolation_deprecated

Fixed ${var} string interpolation deprecations in PHP 8.1
This commit is contained in:
Jorge Casas 2023-01-26 09:29:08 +01:00 committed by GitHub
commit de9b3a6d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View File

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

View File

@ -122,7 +122,7 @@ class DecisionTreeLeaf
public function getHTML(?array $columnNames = null): string public function getHTML(?array $columnNames = null): string
{ {
if ($this->isTerminal) { if ($this->isTerminal) {
$value = "<b>${this}->classValue</b>"; $value = "<b>{$this}->classValue</b>";
} else { } else {
$value = $this->value; $value = $this->value;
if ($columnNames !== null) { if ($columnNames !== null) {
@ -132,13 +132,13 @@ class DecisionTreeLeaf
} }
if ((bool) preg_match('/^[<>=]{1,2}/', (string) $value) === false) { 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) { if ($this->leftLeaf !== null || $this->rightLeaf !== null) {
$str .= '<tr>'; $str .= '<tr>';

View File

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

View File

@ -25,7 +25,7 @@ class StopWords
public static function factory(string $language = 'English'): self public static function factory(string $language = 'English'): self
{ {
$className = __NAMESPACE__."\\StopWords\\${language}"; $className = __NAMESPACE__."\\StopWords\\{$language}";
if (!class_exists($className)) { if (!class_exists($className)) {
throw new InvalidArgumentException(sprintf('Can\'t find "%s" language for StopWords', $language)); 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 private function binarizeTargets(array $targets, $label): array
{ {
$notLabel = "not_${label}"; $notLabel = "not_{$label}";
foreach ($targets as $key => $target) { foreach ($targets as $key => $target) {
$targets[$key] = $target == $label ? $label : $notLabel; $targets[$key] = $target == $label ? $label : $notLabel;
} }