Skip to content

Commit

Permalink
Merge branch 'MDL-76415-master' of https://github.com/meirzamoodle/mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Feb 16, 2023
2 parents 6b05cf7 + 5265300 commit 4fa300b
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 62 deletions.
2 changes: 1 addition & 1 deletion admin/tool/componentlibrary/jsdocspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$jsdocdir = "{$CFG->dirroot}/jsdoc";
if (file_exists($jsdocdir) && is_dir($jsdocdir)) {
$relativepath = get_file_argument();
redirect(new moodle_url("/jsdoc/${relativepath}"));
redirect(new moodle_url("/jsdoc/{$relativepath}"));
}

$PAGE->set_pagelayout('base');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function i_click_on_in_the_activity_in_site_main_menu_block($element, $se
protected function get_site_menu_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_site_menu_activity_node($activityname);

$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function i_click_on_in_the_activity_in_social_activities_block($element,
protected function get_social_block_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_social_block_activity_node($activityname);

$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}

Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/behat_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ public function i_click_on_in_the_activity($element, $selectortype, $activitynam
protected function get_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_activity_node($activityname);

$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}

Expand Down
2 changes: 1 addition & 1 deletion grade/report/singleview/classes/local/screen/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function html(): string {
$types = gradereport_singleview\report\singleview::valid_screens();

foreach ($types as $type) {
$classname = "gradereport_singleview\\local\\screen\\${type}";
$classname = "gradereport_singleview\\local\\screen\\{$type}";

$screen = new $classname($this->courseid, null, $this->groupid);

Expand Down
2 changes: 1 addition & 1 deletion grade/report/singleview/classes/report/singleview.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function __construct(

$this->setup_item_selector($itemtype, $itemid);

$screenclass = "\\gradereport_singleview\\local\\screen\\${itemtype}";
$screenclass = "\\gradereport_singleview\\local\\screen\\{$itemtype}";

$this->screen = new $screenclass($courseid, $itemid, $this->currentgroup);

Expand Down
2 changes: 1 addition & 1 deletion lib/classes/lock/lock_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function get_lock_factory_class(): string {
$dbtype = clean_param($DB->get_dbfamily(), PARAM_ALPHA);

// DB Specific lock factory is preferred - should support auto-release.
$lockfactoryclass = "\\core\\lock\\${dbtype}_lock_factory";
$lockfactoryclass = "\\core\\lock\\{$dbtype}_lock_factory";
if (!class_exists($lockfactoryclass)) {
$lockfactoryclass = '\core\lock\file_lock_factory';
}
Expand Down
8 changes: 4 additions & 4 deletions lib/dml/tests/dml_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6292,10 +6292,10 @@ public function test_get_server_info_dbfamily_mysql() {
['description' => $description, 'version' => $version] = $DB->get_server_info();
// MariaDB RPL_VERSION_HACK sanity check: "5.5.5" has never been released!
$this->assertNotSame('5.5.5', $version,
"Found invalid DB server version i.e. RPL_VERSION_HACK: '${version}' (${description}).");
"Found invalid DB server version i.e. RPL_VERSION_HACK: '{$version}' ({$description}).");
// DB version format is: "X.Y.Z".
$this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version,
"Found invalid DB server version format: '${version}' (${description}).");
"Found invalid DB server version format: '{$version}' ({$description}).");

// Alter the DB options to force the read from DB and check for the same assertions above.
$cfg->dboptions['versionfromdb'] = true;
Expand All @@ -6309,9 +6309,9 @@ public function test_get_server_info_dbfamily_mysql() {
$this->assertTrue($rcm->invokeArgs($db2, []), 'Invalid test state!');
['description' => $description, 'version' => $version] = $db2->get_server_info();
$this->assertNotSame('5.5.5', $version,
"Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '${version}' (${description}).");
"Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '{$version}' ({$description}).");
$this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version,
"Found invalid DB server version format when reading version from DB: '${version}' (${description}).");
"Found invalid DB server version format when reading version from DB: '{$version}' ({$description}).");
$db2->dispose();
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/editor/atto/tests/behat/behat_editor_atto.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class behat_editor_atto extends behat_base implements \core_behat\settable_edito
public function set_editor_value(string $editorid, string $value): void {
$js = <<<EOF
(function() {
const editableEditor = document.getElementById("${editorid}editable");
const editableEditor = document.getElementById("{$editorid}editable");
if (editableEditor && editableEditor.classList.contains('editor_atto_content')) {
editableEditor.innerHTML = "${value}";
editableEditor.innerHTML = "{$value}";
}
const editor = document.getElementById("${editorid}");
const editor = document.getElementById("{$editorid}");
if (editor) {
editor.value = "${value}";
editor.value = "{$value}";
}
})();
EOF;
Expand Down
4 changes: 2 additions & 2 deletions lib/editor/textarea/tests/behat/behat_editor_textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class behat_editor_textarea extends behat_base implements \core_behat\settable_e
public function set_editor_value(string $editorid, string $value): void {
$js = <<<EOF
(function() {
const editor = document.getElementById("${editorid}");
const editor = document.getElementById("{$editorid}");
if (editor && editor.tagName.toLowerCase() === 'textarea') {
editor.value = "${value}";
editor.value = "{$value}";
}
})();
EOF;
Expand Down
4 changes: 2 additions & 2 deletions lib/editor/tiny/classes/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public function use_editor($elementid, array $options = null, $fpoptions = null)
M.util.js_pending('editor_tiny/editor');
require(['editor_tiny/editor'], (Tiny) => {
Tiny.setupForElementId({
elementId: "${elementid}",
options: ${configoptions},
elementId: "{$elementid}",
options: {$configoptions},
});
M.util.js_complete('editor_tiny/editor');
});
Expand Down
16 changes: 8 additions & 8 deletions lib/editor/tiny/tests/behat/behat_editor_tiny.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
protected function execute_javascript_for_editor(string $editorid, string $code): void {
$js = <<<EOF
require(['editor_tiny/editor'], (editor) => {
const instance = editor.getInstanceForElementId('${editorid}');
const instance = editor.getInstanceForElementId('{$editorid}');
{$code}
});
EOF;
Expand All @@ -72,9 +72,9 @@ protected function evaluate_javascript_for_editor(string $editorid, string $code
$js = <<<EOF
return new Promise((resolve, reject) => {
require(['editor_tiny/editor'], (editor) => {
const instance = editor.getInstanceForElementId('${editorid}');
const instance = editor.getInstanceForElementId('{$editorid}');
if (!instance) {
reject("Instance '${editorid}' not found");
reject("Instance '{$editorid}' not found");
}
{$code}
Expand All @@ -101,7 +101,7 @@ public function set_editor_value(string $editorid, string $value): void {
}

$this->execute_javascript_for_editor($editorid, <<<EOF
instance.setContent('${value}');
instance.setContent('{$value}');
instance.undoManager.add();
EOF);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ protected function get_editor_container_for_locator(string $locator): NodeElemen
$js = <<<EOF
const container = instance.getContainer();
if (!container.id) {
container.id = '${targetid}';
container.id = '{$targetid}';
}
resolve(container.id);
EOF;
Expand Down Expand Up @@ -228,7 +228,7 @@ protected function get_editor_iframe_name_for_element(NodeElement $editor): stri
// Ensure that a name is set on the iframe relating to the editorid.
$js = <<<EOF
if (!instance.iframeElement.name) {
instance.iframeElement.name = '${editorid}';
instance.iframeElement.name = '{$editorid}';
}
resolve(instance.iframeElement.name);
EOF;
Expand Down Expand Up @@ -327,7 +327,7 @@ public function select_text(string $textlocator, int $position, string $locator)

// Ensure that a name is set on the iframe relating to the editorid.
$js = <<<EOF
const element = instance.dom.select("${textlocator}")[${position}];
const element = instance.dom.select("{$textlocator}")[{$position}];
instance.selection.select(element);
EOF;

Expand Down Expand Up @@ -427,7 +427,7 @@ public function select_in_editor(string $locator, string $type, string $editorlo
$js = <<<EOF
const editorDocument = instance.getDoc();
const element = editorDocument.evaluate(
"${xpath}",
"{$xpath}",
editorDocument,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
Expand Down
7 changes: 6 additions & 1 deletion lib/mlbackend/php/phpml/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ protected function preprocess(array $samples): array
$median = Mean::median($values);
foreach ($values as &$value) {
if ($value <= $median) {
$value = "<= ${median}";
$value = "<= {$median}";
} else {
$value = "> ${median}";
$value = "> {$median}";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getNodeImpurityDecrease(int $parentRecordCount): float
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) {
Expand All @@ -132,13 +132,13 @@ public function getHTML(?array $columnNames = null): string
}

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>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(int $columnIndex = self::AUTO_SELECT)

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];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function isStopWord(string $token): bool

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));
Expand Down
2 changes: 1 addition & 1 deletion lib/mlbackend/php/phpml/src/Phpml/Helper/OneVsRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ abstract protected function predictSampleBinary(array $sample);
*/
private function binarizeTargets(array $targets, $label): array
{
$notLabel = "not_${label}";
$notLabel = "not_{$label}";
foreach ($targets as $key => $target) {
$targets[$key] = $target == $label ? $label : $notLabel;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/php-jwt/readme_moodle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Instructions
4. Download the latest release.
5. Unzip it in lib as php-jwt.
6. Update entry for this library in lib/thirdpartylibs.xml.

2023/01/26
----------
- src/JWT.php file has minor changes for PHP 8.2 compatibility. See MDL-76415 for more details.
Since version v6.3.1, the php-jwt already has the fix, so if someone executing the upgrading version and
it has the patch, please ignore this note.
2 changes: 1 addition & 1 deletion lib/php-jwt/src/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function decode(
// OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
$sig = self::signatureToDER($sig);
}
if (!self::verify("${headb64}.${bodyb64}", $sig, $key->getKeyMaterial(), $header->alg)) {
if (!self::verify("{$headb64}.{$bodyb64}", $sig, $key->getKeyMaterial(), $header->alg)) { // TODO: Remove this modification in MDL-76415.
throw new SignatureInvalidException('Signature verification failed');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/phpminimumversionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function moodle_minimum_php_version_is_met($haltexecution = false) {

if (version_compare(PHP_VERSION, $minimumversion) < 0) {
if ($haltexecution) {
$error = "Moodle ${moodlerequirementchanged} or later requires at least PHP ${minimumversion} "
$error = "Moodle {$moodlerequirementchanged} or later requires at least PHP {$minimumversion} "
. "(currently using version " . PHP_VERSION .").\n"
. "Some servers may have multiple PHP versions installed, are you using the correct executable?\n";

Expand Down
8 changes: 4 additions & 4 deletions lib/phpxmlrpc/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ protected function verifySignature($in, $sigs)
}
}
if (isset($wanted)) {
return array(0, "Wanted ${wanted}, got ${got} at param ${pno}");
return array(0, "Wanted {$wanted}, got {$got} at param {$pno}"); // TODO: Remove this modification in MDL-76415.
} else {
return array(0, "No method signature matches number of parameters");
}
Expand Down Expand Up @@ -669,7 +669,7 @@ protected function execute($req, $params = null, $paramTypes = null)
return new Response(
0,
PhpXmlRpc::$xmlrpcerr['incorrect_params'],
PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": ${errStr}"
PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}" // TODO: Remove this modification in MDL-76415.
);
}
}
Expand Down Expand Up @@ -1020,8 +1020,8 @@ public static function _xmlrpcs_methodHelp($server, $req)
public static function _xmlrpcs_multicall_error($err)
{
if (is_string($err)) {
$str = PhpXmlRpc::$xmlrpcstr["multicall_${err}"];
$code = PhpXmlRpc::$xmlrpcerr["multicall_${err}"];
$str = PhpXmlRpc::$xmlrpcstr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
$code = PhpXmlRpc::$xmlrpcerr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
} else {
$code = $err->faultCode();
$str = $err->faultString();
Expand Down
Loading

0 comments on commit 4fa300b

Please sign in to comment.