Skip to content

Commit

Permalink
style: have phpcbf replace string double-quotes with single-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Nov 19, 2024
1 parent b9a5d85 commit c87a889
Show file tree
Hide file tree
Showing 77 changed files with 498 additions and 498 deletions.
4 changes: 2 additions & 2 deletions classes/api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function extract_package_info(stored_file $file): package_raw {
'package' => curl_file_create($filepath),
];

$response = $connector->post("/package-extract-info", $data);
$response = $connector->post('/package-extract-info', $data);
$response->assert_2xx();
return array_converter::from_array(package_raw::class, $response->get_data());
}
Expand All @@ -122,7 +122,7 @@ public static function extract_package_info(stored_file $file): package_raw {
*/
public static function get_server_status(): status {
$connector = connector::default();
$response = $connector->get("/status");
$response = $connector->get('/status');
$response->assert_2xx();
return array_converter::from_array(status::class, $response->get_data());
}
Expand Down
2 changes: 1 addition & 1 deletion classes/api/attempt_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class attempt_file {
public string $name;

/** @var string|null */
#[array_key("mime_type")]
#[array_key('mime_type')]
public ?string $mimetype = null;

/** @var string $data */
Expand Down
4 changes: 2 additions & 2 deletions classes/api/attempt_scored.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
*/
class attempt_scored extends attempt {
/** @var string|null */
#[array_key("scoring_state")]
#[array_key('scoring_state')]
public ?string $scoringstate;

/** @var scoring_code */
#[array_key("scoring_code")]
#[array_key('scoring_code')]
public scoring_code $scoringcode;

/** @var float|null */
Expand Down
2 changes: 1 addition & 1 deletion classes/api/attempt_started.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
class attempt_started extends attempt {
/** @var string */
#[array_key("attempt_state")]
#[array_key('attempt_state')]
public string $attemptstate;

/**
Expand Down
12 changes: 6 additions & 6 deletions classes/api/attempt_ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ class attempt_ui {
public string $formulation;

/** @var string|null */
#[array_key("general_feedback")]
#[array_key('general_feedback')]
public ?string $generalfeedback = null;

/** @var string|null */
#[array_key("specific_feedback")]
#[array_key('specific_feedback')]
public ?string $specificfeedback = null;

/** @var string|null */
#[array_key("right_answer")]
#[array_key('right_answer')]
public ?string $rightanswer = null;

/** @var array<string, string> string to string mapping of placeholder names to the values (to be replaced in the content) */
public array $placeholders = [];

/** @var string[]|null */
#[array_key("css_files")]
#[array_key('css_files')]
public ?array $cssfiles = null;

/** @var array<string, attempt_file> specifics TBD */
#[array_element_class(attempt_file::class)]
public array $files = [];

/** @var string specifics TBD */
#[array_key("cache_control")]
public string $cachecontrol = "PRIVATE_CACHE";
#[array_key('cache_control')]
public string $cachecontrol = 'PRIVATE_CACHE';

/**
* Initializes a new instance.
Expand Down
18 changes: 9 additions & 9 deletions classes/api/package_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ private function guzzle_post_and_maybe_retry(string $uri, array $options = [], b

$fd = $this->file->get_content_file_handle();
try {
$options["multipart"][] = [
"name" => "package",
"contents" => $fd,
$options['multipart'][] = [
'name' => 'package',
'contents' => $fd,
];

return $this->guzzle_post_and_maybe_retry($uri, $options, allowretry: false);
} finally {
@fclose($fd);
}
} catch (GuzzleException $e) {
throw new coding_exception("Request to QPy server failed: " . $e->getMessage());
throw new coding_exception('Request to QPy server failed: ' . $e->getMessage());
}
}

Expand All @@ -226,7 +226,7 @@ public function download_static_file(string $namespace, string $shortname, strin
try {
$res = $this->guzzle_post_and_maybe_retry(
"/packages/$this->hash/file/$namespace/$shortname/$kind/$path",
["sink" => $targetpath]
['sink' => $targetpath]
);
} catch (BadResponseException $e) {
if ($e->getResponse()->getStatusCode() == 404) {
Expand All @@ -239,11 +239,11 @@ public function download_static_file(string $namespace, string $shortname, strin
);
}

if ($res->hasHeader("Content-Type")) {
return $res->getHeader("Content-Type")[0];
if ($res->hasHeader('Content-Type')) {
return $res->getHeader('Content-Type')[0];
} else {
debugging("Server did not send Content-Type header, falling back to application/octet-stream");
return "application/octet-stream";
debugging('Server did not send Content-Type header, falling back to application/octet-stream');
return 'application/octet-stream';
}
}

Expand Down
6 changes: 3 additions & 3 deletions classes/api/qpy_http_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class qpy_http_client extends http_client {
* @throws dml_exception
*/
public function __construct(array $config = []) {
$config["base_uri"] = rtrim(get_config('qtype_questionpy', 'server_url'), "/") . "/";
$config["timeout"] = get_config('qtype_questionpy', 'server_timeout');
$config['base_uri'] = rtrim(get_config('qtype_questionpy', 'server_url'), '/') . '/';
$config['timeout'] = get_config('qtype_questionpy', 'server_timeout');
parent::__construct($config);
}

Expand All @@ -53,7 +53,7 @@ protected function get_handlers(array $settings): HandlerStack {
/* This checks requests against Moodle's curlsecurityblockedhosts, which we don't want, since admins would need
to ensure their QPy server isn't in this list otherwise. There may be ways to granularly allow the
server_url, but this will do for now. */
$handlerstack->remove("moodle_check_initial_request");
$handlerstack->remove('moodle_check_initial_request');
return $handlerstack;
}
}
2 changes: 1 addition & 1 deletion classes/api/question_edit_form_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class question_edit_form_response {
public qpy_form $definition;

/** @var array */
#[array_key("form_data")]
#[array_key('form_data')]
public array $formdata;

/**
Expand Down
14 changes: 7 additions & 7 deletions classes/api/question_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@
*/
class question_response {
/** @var string */
#[array_key("question_state")]
#[array_key('question_state')]
public string $state;

/** @var string */
#[array_key("scoring_method")]
#[array_key('scoring_method')]
public string $scoringmethod;

/** @var float|int */
#[array_key("score_min")]
#[array_key('score_min')]
public float $scoremin = 0;

/** @var float|int */
#[array_key("score_max")]
#[array_key('score_max')]
public float $scoremax = 1;

/** @var float|null */
public ?float $penalty = null;

/** @var float|null */
#[array_key("random_guess_score")]
#[array_key('random_guess_score')]
public ?float $randomguessscore = null;

/** @var bool */
#[array_key("render_every_view")]
#[array_key('render_every_view')]
public bool $rendereveryview = false;

/** @var string|null */
#[array_key("general_feedback")]
#[array_key('general_feedback')]
public ?string $generalfeedback = null;

/**
Expand Down
8 changes: 4 additions & 4 deletions classes/api/scoring_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
enum scoring_code: string {
case automatically_scored = "AUTOMATICALLY_SCORED";
case needs_manual_scoring = "NEEDS_MANUAL_SCORING";
case response_not_scorable = "RESPONSE_NOT_SCORABLE";
case invalid_response = "INVALID_RESPONSE";
case automatically_scored = 'AUTOMATICALLY_SCORED';
case needs_manual_scoring = 'NEEDS_MANUAL_SCORING';
case response_not_scorable = 'RESPONSE_NOT_SCORABLE';
case invalid_response = 'INVALID_RESPONSE';
}
4 changes: 2 additions & 2 deletions classes/api/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class status {
public string $version;

/** @var bool */
#[array_key("allow_lms_packages")]
#[array_key('allow_lms_packages')]
public bool $allowlmspackages = false;

/** @var string */
#[array_key("max_package_size")]
#[array_key('max_package_size')]
public string $maxpackagesize;

/** @var usage|null */
Expand Down
4 changes: 2 additions & 2 deletions classes/api/usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
*/
class usage {
/** @var int */
#[array_key("requests_in_process")]
#[array_key('requests_in_process')]
public int $requestsinprocess;

/** @var int */
#[array_key("requests_in_queue")]
#[array_key('requests_in_queue')]
public int $requestsinqueue;

/**
Expand Down
28 changes: 14 additions & 14 deletions classes/array_converter/array_converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public static function from_array(string $class, array $raw): object {
if ($discriminator !== null && $discriminator !== $expected) {
// If the wrong discriminator is given, it is an error.
throw new moodle_exception(
"cannotgetdata",
"error",
'cannotgetdata',
'error',
debuginfo: "Expected '$config->discriminator' value '$expected', but got '$discriminator'"
);
}
Expand All @@ -80,7 +80,7 @@ public static function from_array(string $class, array $raw): object {
debugging($message . " Using fallback variant '$config->fallbackvariant'.");
$class = $config->fallbackvariant;
} else {
throw new moodle_exception("cannotgetdata", "error", debuginfo: $message);
throw new moodle_exception('cannotgetdata', 'error', debuginfo: $message);
}
}

Expand Down Expand Up @@ -112,13 +112,13 @@ public static function to_array($instance) {
return $instance->value;
}
if ($instance instanceof \UnitEnum) {
throw new coding_exception("Only backed enums are supported.");
throw new coding_exception('Only backed enums are supported.');
}
if (is_scalar($instance) || $instance === null) {
return $instance;
}
if (is_array($instance)) {
return array_map([self::class, "to_array"], $instance);
return array_map([self::class, 'to_array'], $instance);
}
if (!is_object($instance)) {
return (array)$instance;
Expand Down Expand Up @@ -184,8 +184,8 @@ private static function instantiate(ReflectionClass $reflect, converter_config $
$args[] = $parameter->getDefaultValue();
} else if (!$parameter->isVariadic()) {
throw new moodle_exception(
"cannotgetdata",
"error",
'cannotgetdata',
'error',
debuginfo: "No value provided for required field '$parameter->name' of '{$reflect->getName()}'"
);
}
Expand Down Expand Up @@ -282,14 +282,14 @@ private static function convert_to_required_type(?ReflectionNamedType $type, con
if (enum_exists($typehint)) {
$enum = new \ReflectionEnum($typehint);
if (!$enum->isBacked()) {
throw new coding_exception("Only backed enums are supported.");
throw new coding_exception('Only backed enums are supported.');
}
try {
return call_user_func([$typehint, "from"], $value);
return call_user_func([$typehint, 'from'], $value);
} catch (\TypeError | \ValueError) {
throw new moodle_exception(
"cannotgetdata",
"error",
'cannotgetdata',
'error',
debuginfo: "The value is not a valid member of enum '$typehint'"
);
}
Expand All @@ -300,7 +300,7 @@ private static function convert_to_required_type(?ReflectionNamedType $type, con
return $value;
}

if ($typehint === "array") {
if ($typehint === 'array') {
$elementclass = $config->elementclasses[$propname] ?? null;
if ($elementclass) {
// Convert each element to the required class.
Expand All @@ -319,8 +319,8 @@ private static function convert_to_required_type(?ReflectionNamedType $type, con

$actualtype = gettype($value);
throw new moodle_exception(
"cannotgetdata",
"error",
'cannotgetdata',
'error',
debuginfo: "Cannot convert value of type '$actualtype' to type '$typehint'"
);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class constants {
public const NAMESPACE_QPY = 'http://questionpy.org/ns/question';

/** @var string */
public const QT_VAR_ATTEMPT_STATE = "_attemptstate";
public const QT_VAR_ATTEMPT_STATE = '_attemptstate';
/** @var string */
public const QT_VAR_SCORING_STATE = "_scoringstate";
public const QT_VAR_SCORING_STATE = '_scoringstate';
}
2 changes: 1 addition & 1 deletion classes/external/favourite_package.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
defined('MOODLE_INTERNAL') || die;

global $CFG;
require_once($CFG->libdir . "/externallib.php");
require_once($CFG->libdir . '/externallib.php');

use context;
use context_system;
Expand Down
2 changes: 1 addition & 1 deletion classes/external/get_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
defined('MOODLE_INTERNAL') || die;

global $CFG;
require_once($CFG->libdir . "/externallib.php");
require_once($CFG->libdir . '/externallib.php');

use context_system;
use external_api;
Expand Down
2 changes: 1 addition & 1 deletion classes/external/load_packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
defined('MOODLE_INTERNAL') || die;

global $CFG;
require_once($CFG->libdir . "/externallib.php");
require_once($CFG->libdir . '/externallib.php');

use core\di;
use external_api;
Expand Down
2 changes: 1 addition & 1 deletion classes/external/remove_packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
defined('MOODLE_INTERNAL') || die;

global $CFG;
require_once($CFG->libdir . "/externallib.php");
require_once($CFG->libdir . '/externallib.php');

use external_api;
use external_function_parameters;
Expand Down
Loading

0 comments on commit c87a889

Please sign in to comment.