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 Oct 28, 2024
1 parent d0f1053 commit cb9dfaa
Show file tree
Hide file tree
Showing 72 changed files with 482 additions and 482 deletions.
4 changes: 2 additions & 2 deletions classes/api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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 @@ -107,7 +107,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 string */
#[array_key("scoring_code")]
#[array_key('scoring_code')]
public string $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
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
24 changes: 12 additions & 12 deletions classes/array_converter/array_converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ 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',
'',
null,
"Expected '$config->discriminator' value '$expected', but got '$discriminator'"
);
Expand All @@ -83,7 +83,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", "", null, $message);
throw new moodle_exception('cannotgetdata', 'error', '', null, $message);
}
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public static function to_array($instance) {
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 @@ -181,9 +181,9 @@ private static function instantiate(ReflectionClass $reflect, converter_config $
$args[] = $parameter->getDefaultValue();
} else if (!$parameter->isVariadic()) {
throw new moodle_exception(
"cannotgetdata",
"error",
"",
'cannotgetdata',
'error',
'',
null,
"No value provided for required field '$parameter->name' of '{$reflect->getName()}'"
);
Expand Down Expand Up @@ -276,7 +276,7 @@ private static function convert_to_required_type(?ReflectionNamedType $type, con
return $value;
}

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

$actualtype = gettype($value);
throw new moodle_exception(
"cannotgetdata",
"error",
"",
'cannotgetdata',
'error',
'',
null,
"Cannot convert value of type '$actualtype' to type '{$type->getName()}'"
);
Expand Down
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
10 changes: 5 additions & 5 deletions classes/external/search_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 context;
use context_system;
Expand Down Expand Up @@ -92,10 +92,10 @@ private static function validate_parameter_values($params): void {
throw new invalid_parameter_exception("Unknown order. Valid parameters are: $validparameters");
}
if ($params['limit'] <= 0 || $params['limit'] > 100) {
throw new invalid_parameter_exception("The limit can only be a value from 1 to 100.");
throw new invalid_parameter_exception('The limit can only be a value from 1 to 100.');
}
if ($params['page'] < 0) {
throw new invalid_parameter_exception("The page can not be negative.");
throw new invalid_parameter_exception('The page can not be negative.');
}
}

Expand Down Expand Up @@ -285,10 +285,10 @@ private static function create_best_language_sql(): array {
*/
private static function create_recently_used_sql(int $contextid): array {
// Create relevant sql fragment.
$joinlastusedsql = "
$joinlastusedsql = '
JOIN {qtype_questionpy_lastused} lu
ON lu.packageid = p.id AND lu.contextid = :contextid
";
';

return [$joinlastusedsql, ['contextid' => $contextid]];
}
Expand Down
12 changes: 6 additions & 6 deletions classes/form/conditions/condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
* @copyright 2022 TU Berlin, innoCampus {@link https://www.questionpy.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[array_polymorphic("kind", variants: [
"is_checked" => is_checked::class,
"is_not_checked" => is_not_checked::class,
"equals" => equals::class,
"does_not_equal" => does_not_equal::class,
"in" => in::class,
#[array_polymorphic('kind', variants: [
'is_checked' => is_checked::class,
'is_not_checked' => is_not_checked::class,
'equals' => equals::class,
'does_not_equal' => does_not_equal::class,
'in' => in::class,
])]
abstract class condition {
/** @var string $name name of the target element */
Expand Down
2 changes: 1 addition & 1 deletion classes/form/conditions/does_not_equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class does_not_equal extends condition_with_value {
* @return string
*/
public static function mform_type(): string {
return "neq";
return 'neq';
}
}
Loading

0 comments on commit cb9dfaa

Please sign in to comment.