Skip to content

Commit

Permalink
Merge pull request #42 from bfh/codingstyle
Browse files Browse the repository at this point in the history
Respect latest Moodle coding guidelines.
  • Loading branch information
lucaboesch authored Jul 13, 2024
2 parents 0bf38a7 + 8ccd145 commit 7f91ea5
Show file tree
Hide file tree
Showing 57 changed files with 275 additions and 263 deletions.
4 changes: 2 additions & 2 deletions classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ public static function get_instance_by_categoryid($categoryid) {
/**
* Check whether only active users in course should be shown.
*
* @param context_module $context context the verbal feedback belongs to.
* @param ?context_module $context context the verbal feedback belongs to.
* @return bool true if only active users should be shown.
*/
public static function show_only_active_users(context_module $context = null) {
public static function show_only_active_users(?context_module $context = null) {
global $CFG;

$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
Expand Down
14 changes: 7 additions & 7 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ public static function prepare_items_view($categories) {

/**
* Wrapper for the Yaml::parseFile() function.
* @param string $someYaml
*
* @param string $someyaml
* @param int|null $options
* @param int|null $debug
* @return array|\Dallgoot\Yaml\Types\YamlObject|\Dallgoot\Yaml\YamlObject|null
* @throws Exception
*/
public static function parseYamlFile(string $someYaml, ?int $options = null, ?int $debug = null)
{
public static function parseyamlfile(string $someyaml, ?int $options = null, ?int $debug = null) {
if (version_compare(PHP_VERSION, '8.1.14') >= 0) {
require_once implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '81x', 'autoload.php']);
return \Dallgoot\Yaml\Yaml::parseFile($someYaml, $options, $debug);
require_once(implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '81x', 'autoload.php']));
return \Dallgoot\Yaml\Yaml::parseFile($someyaml, $options, $debug);
}
require_once implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '74x', 'autoload.php']);
return \Dallgoot\Yaml::parseFile($someYaml, $options, $debug);
require_once(implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '74x', 'autoload.php']));
return \Dallgoot\Yaml::parseFile($someyaml, $options, $debug);
}
}
36 changes: 18 additions & 18 deletions classes/model/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function __construct(int $course, int $id = 0, string $name = "", string
public static function from_template(int $course, template $template, int $id = 0, string $name = "", string $intro = "",
int $introformat = 0, int $gradecat = 0, int $grade = 0, float $gradepass = 0,
int $status = instance_status::NOT_READY, int $timeopen = 0, int $timeclose = 0, int $timemodified = 0,
int $releasetype = instance_release_type::NONE, int $released = 0) : instance {
int $releasetype = instance_release_type::NONE, int $released = 0): instance {

$instance = new instance($course, $id, $name, $intro, $introformat, $grade, $gradecat, $gradepass,
$status, $timeopen, $timeclose, $timemodified, $releasetype, $released);
Expand All @@ -181,7 +181,7 @@ public static function from_template(int $course, template $template, int $id =
*
* @return int The id.
*/
public function get_id() : int {
public function get_id(): int {
return $this->id;
}

Expand All @@ -199,7 +199,7 @@ public function set_id(int $id) {
*
* @return int|null The template id.
*/
public function get_template_id() : ?int {
public function get_template_id(): ?int {
return $this->templateid;
}

Expand All @@ -217,7 +217,7 @@ public function set_template_id(?int $templateid) {
*
* @return int The course id.
*/
public function get_course() : int {
public function get_course(): int {
return $this->course;
}

Expand All @@ -235,7 +235,7 @@ public function set_course(int $course) {
*
* @return string The instance name.
*/
public function get_name() : string {
public function get_name(): string {
return $this->name;
}

Expand All @@ -253,7 +253,7 @@ public function set_name(string $name) {
*
* @return string The intro.
*/
public function get_intro() : string {
public function get_intro(): string {
return $this->intro;
}

Expand All @@ -271,7 +271,7 @@ public function set_intro(string $intro) {
*
* @return int The introformat.
*/
public function get_introformat() : int {
public function get_introformat(): int {
return $this->introformat;
}

Expand All @@ -289,7 +289,7 @@ public function set_introformat(int $introformat) {
*
* @return int The max grade.
*/
public function get_grade() : int {
public function get_grade(): int {
global $DB;
return $DB->get_field('verbalfeedback', 'grade', ['id' => $this->id]);
}
Expand All @@ -308,7 +308,7 @@ public function set_grade(int $grade) {
*
* @return int The grade category.
*/
public function get_gradecat() : int {
public function get_gradecat(): int {
return $this->gradecat;
}

Expand All @@ -326,7 +326,7 @@ public function set_gradecat(int $gradecat) {
*
* @return float The pass grade.
*/
public function get_gradepass() : float {
public function get_gradepass(): float {
return $this->gradepass;
}

Expand All @@ -344,7 +344,7 @@ public function set_gradepass(float $gradepass) {
*
* @return int The grade scale.
*/
public function get_gradescale() : int {
public function get_gradescale(): int {
return $this->gradescale;
}

Expand All @@ -362,7 +362,7 @@ public function set_gradescale(int $gradescale) {
*
* @return int The instance status.
*/
public function get_status() : int {
public function get_status(): int {
return $this->status;
}

Expand All @@ -380,7 +380,7 @@ public function set_status(int $status) {
*
* @return int The opening time.
*/
public function get_timeopen() : int {
public function get_timeopen(): int {
return $this->timeopen;
}

Expand All @@ -398,7 +398,7 @@ public function set_timeopen(int $timeopen) {
*
* @return int The closing time.
*/
public function get_timeclose() : int {
public function get_timeclose(): int {
return $this->timeclose;
}

Expand All @@ -416,7 +416,7 @@ public function set_timeclose(int $timeclose) {
*
* @return int The time of the last modification.
*/
public function get_timemodified() : int {
public function get_timemodified(): int {
return $this->timemodified;
}

Expand All @@ -439,7 +439,7 @@ public function set_timemodified(int $timemodified) {
*
* @return int The releasetype property value.
*/
public function get_release_type() : int {
public function get_release_type(): int {
return $this->releasetype;
}

Expand All @@ -462,7 +462,7 @@ public function set_release_type(int $releasetype) {
*
* @return int The released property value.
*/
public function get_released() : int {
public function get_released(): int {
return $this->released;
}

Expand All @@ -480,7 +480,7 @@ public function set_released(int $released) {
*
* @return array<int, instance_category> The categories.
*/
public function get_categories() : array {
public function get_categories(): array {
return $this->categories;
}

Expand Down
16 changes: 8 additions & 8 deletions classes/model/instance_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(int $id = 0, ?int $paramtemplatecategoryid = null, i
* @param parametrized_template_category $paramtemplatecategory The parametrized template category id
* @return instance_category
*/
public static function from_template(parametrized_template_category $paramtemplatecategory) : instance_category {
public static function from_template(parametrized_template_category $paramtemplatecategory): instance_category {
$instancecategory = new instance_category();
$instancecategory->set_parametrized_template_category_id($paramtemplatecategory->get_id());
$instancecategory->set_position($paramtemplatecategory->get_position());
Expand Down Expand Up @@ -107,7 +107,7 @@ public function set_id(int $id) {
*
* @return int
*/
public function get_id() : int {
public function get_id(): int {
return $this->id;
}

Expand All @@ -125,7 +125,7 @@ public function set_parametrized_template_category_id(?int $paramtemplatecategor
*
* @return int|null The parametrized template category id
*/
public function get_parametrized_template_category_id() : ?int {
public function get_parametrized_template_category_id(): ?int {
return $this->paramtemplatecategoryid;
}

Expand All @@ -143,7 +143,7 @@ public function set_position(int $position) {
*
* @return int The template category position
*/
public function get_position() : int {
public function get_position(): int {
return $this->position;
}

Expand All @@ -161,7 +161,7 @@ public function set_weight(float $weight) {
*
* @return float The category weight
*/
public function get_weight() : float {
public function get_weight(): float {
return $this->weight;
}

Expand All @@ -170,7 +170,7 @@ public function get_weight() : float {
*
* @return array<int, localized_string> The localized instance category headers.
*/
public function get_headers() : array {
public function get_headers(): array {
return $this->localizedheaders;
}

Expand All @@ -180,7 +180,7 @@ public function get_headers() : array {
* @param string $languagestr The given language string
* @return \mod_verbalfeedback\model\localized_string
*/
public function get_header(string $languagestr) : localized_string {
public function get_header(string $languagestr): localized_string {
$langrepo = new language_repository();

// Select the language string matching the current language.
Expand All @@ -207,7 +207,7 @@ public function add_header(localized_string $header) {
*
* @return array<int, instance_criterion> The criteria
*/
public function get_criteria() : array {
public function get_criteria(): array {
return $this->instancecriteria;
}

Expand Down
14 changes: 7 additions & 7 deletions classes/model/instance_criterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function set_id(int $id) {
*
* @return int
*/
public function get_id() : int {
public function get_id(): int {
return $this->id;
}

Expand All @@ -142,7 +142,7 @@ public function set_parametrized_template_criterion_id(?int $parametrizedtemplat
*
* @return int|null
*/
public function get_parametrized_template_criterion_id() : ?int {
public function get_parametrized_template_criterion_id(): ?int {
return $this->parametrizedtemplatecriterionid;
}

Expand All @@ -160,7 +160,7 @@ public function set_position(int $position) {
*
* @return int The instance criterion position
*/
public function get_position() : int {
public function get_position(): int {
return $this->position;
}

Expand All @@ -178,7 +178,7 @@ public function set_weight(float $weight) {
*
* @return float
*/
public function get_weight() : float {
public function get_weight(): float {
return $this->weight;
}

Expand All @@ -187,7 +187,7 @@ public function get_weight() : float {
*
* @return array<int, localized_string> The localized strings.
*/
public function get_descriptions() : array {
public function get_descriptions(): array {
return $this->descriptions;
}

Expand All @@ -197,7 +197,7 @@ public function get_descriptions() : array {
* @param string $languagestr The given language string
* @return \mod_verbalfeedback\model\localized_string|null
*/
public function get_description(string $languagestr) : ?localized_string {
public function get_description(string $languagestr): ?localized_string {
$languagerepository = new language_repository();

// Select the language string matching the current language.
Expand Down Expand Up @@ -242,7 +242,7 @@ public function add_subrating(subrating $subrating) {
*
* @return array
*/
public function get_subratings() : array {
public function get_subratings(): array {
return $this->subratings;
}
}
8 changes: 4 additions & 4 deletions classes/model/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function __construct(?int $id = null, string $language = '') {
/**
* Sets the id.
*
* @param int|null $id The id.
* @param ?int|null $id The id.
*/
public function set_id(int $id = null) {
public function set_id(?int $id = null) {
$this->id = $id;
}

Expand All @@ -57,7 +57,7 @@ public function set_id(int $id = null) {
*
* @return int The id.
*/
public function get_id() : ?int {
public function get_id(): ?int {
return $this->id;
}

Expand All @@ -75,7 +75,7 @@ public function set_language(string $language) {
*
* @return string The language
*/
public function get_language() : string {
public function get_language(): string {
return $this->language;
}
}
6 changes: 3 additions & 3 deletions classes/model/localized_string.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function set_id(int $id) {
*
* @return int The id.
*/
public function get_id() : int {
public function get_id(): int {
return $this->id;
}

Expand All @@ -79,7 +79,7 @@ public function set_language_id(int $languageid) {
*
* @return language The language.
*/
public function get_language_id() : int {
public function get_language_id(): int {
return $this->languageid;
}

Expand All @@ -97,7 +97,7 @@ public function set_string(string $string) {
*
* @return string The string.
*/
public function get_string() : string {
public function get_string(): string {
return $this->string;
}
}
Loading

0 comments on commit 7f91ea5

Please sign in to comment.