MDL-65292 style: Fix all function declarations white space

This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing

All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.

Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
This commit is contained in:
Eloy Lafuente (stronk7)
2024-02-28 23:33:26 +01:00
parent e567c21d6e
commit ba1f804ffa
972 changed files with 2098 additions and 2094 deletions
+31 -31
View File
@@ -100,7 +100,7 @@ abstract class handler {
* @param int $itemid
* @return handler
*/
public static function create(int $itemid = 0) : handler {
public static function create(int $itemid = 0): handler {
return new static($itemid);
}
@@ -112,7 +112,7 @@ abstract class handler {
* @param int $itemid item id if the area uses them (usually not used)
* @return handler
*/
public static function get_handler(string $component, string $area, int $itemid = 0) : handler {
public static function get_handler(string $component, string $area, int $itemid = 0): handler {
$classname = $component . '\\customfield\\' . $area . '_handler';
if (class_exists($classname) && is_subclass_of($classname, self::class)) {
return $classname::create($itemid);
@@ -126,7 +126,7 @@ abstract class handler {
*
* @return string
*/
public function get_component() : string {
public function get_component(): string {
return $this->component;
}
@@ -135,7 +135,7 @@ abstract class handler {
*
* @return string
*/
public function get_area() : string {
public function get_area(): string {
return $this->area;
}
@@ -144,14 +144,14 @@ abstract class handler {
*
* @return \context
*/
abstract public function get_configuration_context() : \context;
abstract public function get_configuration_context(): \context;
/**
* URL for configuration of the fields on this handler.
*
* @return \moodle_url
*/
abstract public function get_configuration_url() : \moodle_url;
abstract public function get_configuration_url(): \moodle_url;
/**
* Context that should be used for data stored for the given record
@@ -159,14 +159,14 @@ abstract class handler {
* @param int $instanceid id of the instance or 0 if the instance is being created
* @return \context
*/
abstract public function get_instance_context(int $instanceid = 0) : \context;
abstract public function get_instance_context(int $instanceid = 0): \context;
/**
* Get itemid
*
* @return int|null
*/
public function get_itemid() : int {
public function get_itemid(): int {
return $this->itemid;
}
@@ -175,7 +175,7 @@ abstract class handler {
*
* @return bool
*/
public function uses_categories() : bool {
public function uses_categories(): bool {
return true;
}
@@ -185,7 +185,7 @@ abstract class handler {
* @param int $suffix
* @return string
*/
protected function generate_category_name($suffix = 0) : string {
protected function generate_category_name($suffix = 0): string {
if ($suffix) {
return get_string('otherfieldsn', 'core_customfield', $suffix);
} else {
@@ -199,7 +199,7 @@ abstract class handler {
* @param string $name name of the category, null to generate automatically
* @return int id of the new category
*/
public function create_category(string $name = null) : int {
public function create_category(string $name = null): int {
global $DB;
$params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()];
@@ -225,7 +225,7 @@ abstract class handler {
* @return category_controller
* @throws \moodle_exception
*/
protected function validate_category(category_controller $category) : category_controller {
protected function validate_category(category_controller $category): category_controller {
$categories = $this->get_categories_with_fields();
if (!array_key_exists($category->get('id'), $categories)) {
throw new \moodle_exception('categorynotfound', 'core_customfield');
@@ -240,7 +240,7 @@ abstract class handler {
* @return field_controller
* @throws \moodle_exception
*/
protected function validate_field(field_controller $field) : field_controller {
protected function validate_field(field_controller $field): field_controller {
if (!array_key_exists($field->get('categoryid'), $this->get_categories_with_fields())) {
throw new \moodle_exception('fieldnotfound', 'core_customfield');
}
@@ -282,7 +282,7 @@ abstract class handler {
* @param category_controller $category
* @return bool
*/
public function delete_category(category_controller $category) : bool {
public function delete_category(category_controller $category): bool {
$category = $this->validate_category($category);
$result = api::delete_category($category);
$this->clear_configuration_cache();
@@ -306,7 +306,7 @@ abstract class handler {
* @param field_controller $field
* @return bool
*/
public function delete_field_configuration(field_controller $field) : bool {
public function delete_field_configuration(field_controller $field): bool {
$field = $this->validate_field($field);
$result = api::delete_field_configuration($field);
$this->clear_configuration_cache();
@@ -331,7 +331,7 @@ abstract class handler {
*
* @return bool
*/
abstract public function can_configure() : bool;
abstract public function can_configure(): bool;
/**
* The current user can edit given custom fields on the given instance
@@ -344,7 +344,7 @@ abstract class handler {
* @param int $instanceid id of the instance or 0 if the instance is being created
* @return bool
*/
abstract public function can_edit(field_controller $field, int $instanceid = 0) : bool;
abstract public function can_edit(field_controller $field, int $instanceid = 0): bool;
/**
* The current user can view the value of the custom field for a given custom field and instance
@@ -358,7 +358,7 @@ abstract class handler {
* @param int $instanceid
* @return bool
*/
abstract public function can_view(field_controller $field, int $instanceid) : bool;
abstract public function can_view(field_controller $field, int $instanceid): bool;
/**
* Returns the custom field values for an individual instance
@@ -373,7 +373,7 @@ abstract class handler {
* some data_controller objects may have 'id', some not
* In the last case data_controller::get_value() and export_value() functions will return default values.
*/
public function get_instance_data(int $instanceid, bool $returnall = false) : array {
public function get_instance_data(int $instanceid, bool $returnall = false): array {
$fields = $returnall ? $this->get_fields() : $this->get_visible_fields($instanceid);
return api::get_instance_fields_data($fields, $instanceid);
}
@@ -391,7 +391,7 @@ abstract class handler {
* All instanceids and all fieldids are present, some data_controller objects may have 'id', some not.
* In the last case data_controller::get_value() and export_value() functions will return default values.
*/
public function get_instances_data(array $instanceids, bool $returnall = false) : array {
public function get_instances_data(array $instanceids, bool $returnall = false): array {
$result = api::get_instances_fields_data($this->get_fields(), $instanceids);
if (!$returnall) {
@@ -417,7 +417,7 @@ abstract class handler {
* @param bool $returnall
* @return \core_customfield\output\field_data[]
*/
public function export_instance_data(int $instanceid, bool $returnall = false) : array {
public function export_instance_data(int $instanceid, bool $returnall = false): array {
return array_map(function($d) {
return new field_data($d);
}, $this->get_instance_data($instanceid, $returnall));
@@ -434,7 +434,7 @@ abstract class handler {
* @param bool $returnall
* @return stdClass
*/
public function export_instance_data_object(int $instanceid, bool $returnall = false) : stdClass {
public function export_instance_data_object(int $instanceid, bool $returnall = false): stdClass {
$rv = new stdClass();
foreach ($this->export_instance_data($instanceid, $returnall) as $d) {
$rv->{$d->get_shortname()} = $d->get_value();
@@ -449,7 +449,7 @@ abstract class handler {
* @param data_controller[] $fieldsdata
* @return string
*/
public function display_custom_fields_data(array $fieldsdata) : string {
public function display_custom_fields_data(array $fieldsdata): string {
global $PAGE;
$output = $PAGE->get_renderer('core_customfield');
$content = '';
@@ -466,7 +466,7 @@ abstract class handler {
*
* @return category_controller[]
*/
public function get_categories_with_fields() : array {
public function get_categories_with_fields(): array {
if ($this->categories === null) {
$this->categories = api::get_categories_with_fields($this->get_component(), $this->get_area(), $this->get_itemid());
}
@@ -493,7 +493,7 @@ abstract class handler {
* @param int $instanceid
* @return bool
*/
protected function can_backup(field_controller $field, int $instanceid) : bool {
protected function can_backup(field_controller $field, int $instanceid): bool {
return $this->can_view($field, $instanceid) || $this->can_edit($field, $instanceid);
}
@@ -534,7 +534,7 @@ abstract class handler {
* @param int $instanceid
* @return array
*/
public function get_instance_data_for_backup(int $instanceid) : array {
public function get_instance_data_for_backup(int $instanceid): array {
$finalfields = [];
$data = $this->get_instance_data($instanceid, true);
foreach ($data as $d) {
@@ -700,7 +700,7 @@ abstract class handler {
*
* @return array
*/
public function get_available_field_types() :array {
public function get_available_field_types(): array {
return api::get_available_field_types();
}
@@ -712,7 +712,7 @@ abstract class handler {
*
* @return array
*/
public function get_description_text_options() : array {
public function get_description_text_options(): array {
global $CFG;
require_once($CFG->libdir.'/formslib.php');
return [
@@ -761,7 +761,7 @@ abstract class handler {
*
* @return field_controller[]
*/
public function get_fields() : array {
public function get_fields(): array {
$categories = $this->get_categories_with_fields();
$fields = [];
foreach ($categories as $category) {
@@ -778,7 +778,7 @@ abstract class handler {
* @param int $instanceid
* @return field_controller[]
*/
protected function get_visible_fields(int $instanceid) : array {
protected function get_visible_fields(int $instanceid): array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {
@@ -793,7 +793,7 @@ abstract class handler {
* @param int $instanceid
* @return field_controller[]
*/
public function get_editable_fields(int $instanceid) : array {
public function get_editable_fields(int $instanceid): array {
$handler = $this;
return array_filter($this->get_fields(),
function($field) use($handler, $instanceid) {