diff --git a/phpstan/stubs/public/ai/classes/aiactions/base.stub b/phpstan/stubs/public/ai/classes/aiactions/base.stub new file mode 100644 index 00000000..2fdbc4b1 --- /dev/null +++ b/phpstan/stubs/public/ai/classes/aiactions/base.stub @@ -0,0 +1,6 @@ +[] + */ + abstract public static function get_action_list(): array; + + /** + * @return array{'action': string}[] + */ + public static function get_actions_available(context $context, bool $checkcontext = true): array { + return []; + } + + /** + * @return array{'action': string}[] + */ + public function get_sub_actions(string $classname): array { + return []; + } +} diff --git a/phpstan/stubs/public/backup/converter/moodle1/handlerlib.stub b/phpstan/stubs/public/backup/converter/moodle1/handlerlib.stub new file mode 100644 index 00000000..564ab55f --- /dev/null +++ b/phpstan/stubs/public/backup/converter/moodle1/handlerlib.stub @@ -0,0 +1,37 @@ +xmlwriter + * @param string $filename + * @return void + */ + protected function open_xml_writer($filename) { + } + + /** + * @phpstan-assert null $this->xmlwriter + * @return void + */ + protected function close_xml_writer() { + } +} + +abstract class moodle1_plugin_handler extends moodle1_xml_handler { +} + +abstract class moodle1_mod_handler extends moodle1_plugin_handler { + /** + * @param int $instance + * @param string $modname + * @return mixed + */ + protected function get_cminfo($instance, $modname = null) { + } +} diff --git a/phpstan/stubs/public/backup/util/interfaces.stub b/phpstan/stubs/public/backup/util/interfaces.stub new file mode 100644 index 00000000..5815fcad --- /dev/null +++ b/phpstan/stubs/public/backup/util/interfaces.stub @@ -0,0 +1,4 @@ + + */ +class core_course_category implements cacheable_object_interface, IteratorAggregate, renderable { + /** + * @param int $id + * @param IGNORE_MISSING|IGNORE_MULTIPLE|MUST_EXIST $strictness + * @param bool $alwaysreturnhidden + * @param int|stdClass|null $user + * @return ($strictness is MUST_EXIST ? self : null|self) + * @throws moodle_exception&Throwable + */ + public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false, $user = null) { + } +} diff --git a/phpstan/stubs/public/course/classes/cm_info.stub b/phpstan/stubs/public/course/classes/cm_info.stub new file mode 100644 index 00000000..73c16f04 --- /dev/null +++ b/phpstan/stubs/public/course/classes/cm_info.stub @@ -0,0 +1,62 @@ + + */ +class cm_info implements IteratorAggregate { +} diff --git a/phpstan/stubs/public/course/classes/modinfo.stub b/phpstan/stubs/public/course/classes/modinfo.stub new file mode 100644 index 00000000..a399e13c --- /dev/null +++ b/phpstan/stubs/public/course/classes/modinfo.stub @@ -0,0 +1,14 @@ + $sections + * @property-read cm_info[] $cms + * @property-read array> $instances + * @property-read array> $groups + */ +class modinfo { +} diff --git a/phpstan/stubs/public/course/moodleform_mod.stub b/phpstan/stubs/public/course/moodleform_mod.stub new file mode 100644 index 00000000..dd701f9d --- /dev/null +++ b/phpstan/stubs/public/course/moodleform_mod.stub @@ -0,0 +1,20 @@ + + */ +abstract class base implements IteratorAggregate { + public const LEVEL_OTHER = 0; + public const LEVEL_TEACHING = 1; + public const LEVEL_PARTICIPATING = 2; + + /** + * @param array{ + * objectid?: int|null, + * context?: \core\context, + * userid?: int, + * courseid?: int|null, + * relateduserid?: int|null, + * anonymous?: bool|1|2, + * other?: mixed|null, + * } $data + * @return static returns instance of new event + * @throws coding_exception&Throwable + */ + final public static function create(?array $data = null) { + } +} diff --git a/phpstan/stubs/public/lib/classes/lang_string.stub b/phpstan/stubs/public/lib/classes/lang_string.stub new file mode 100644 index 00000000..607d498b --- /dev/null +++ b/phpstan/stubs/public/lib/classes/lang_string.stub @@ -0,0 +1,28 @@ + + */ +class lang_string { + /** + * @param string $identifier + * @param string|null $component + * @param get_string_a $a + * @param string|null $lang + * @throws coding_exception&Throwable + */ + public function __construct( + string $identifier, + ?string $component = '', + mixed $a = null, + ?string $lang = null, + ) { + } +} diff --git a/phpstan/stubs/public/lib/classes/lock/lock.stub b/phpstan/stubs/public/lib/classes/lock/lock.stub new file mode 100644 index 00000000..49790372 --- /dev/null +++ b/phpstan/stubs/public/lib/classes/lock/lock.stub @@ -0,0 +1,6 @@ + 'choosedots'], + ?array $attributes = null, + array $disabled = [], + ): string { + } +} diff --git a/phpstan/stubs/public/lib/classes/output/progress_bar.stub b/phpstan/stubs/public/lib/classes/output/progress_bar.stub new file mode 100644 index 00000000..7e807e14 --- /dev/null +++ b/phpstan/stubs/public/lib/classes/output/progress_bar.stub @@ -0,0 +1,6 @@ + + */ + public function export_for_template(renderer_base $output); } diff --git a/phpstan/stubs/public/lib/classes/task/stored_progress_task_trait.stub b/phpstan/stubs/public/lib/classes/task/stored_progress_task_trait.stub new file mode 100644 index 00000000..966eddd0 --- /dev/null +++ b/phpstan/stubs/public/lib/classes/task/stored_progress_task_trait.stub @@ -0,0 +1,16 @@ +progress + */ + protected function start_stored_progress(): void { + } +} diff --git a/phpstan/stubs/public/lib/classes/text.stub b/phpstan/stubs/public/lib/classes/text.stub new file mode 100644 index 00000000..3814c7af --- /dev/null +++ b/phpstan/stubs/public/lib/classes/text.stub @@ -0,0 +1,12 @@ +id + * @param bool $wholecourse + * @param int $userid + * @param mixed $unused + * @return stdClass + */ + public function get_data($cm, $wholecourse = false, $userid = 0, $unused = null) { + } + + /** + * @param string $error + * @return never + * @throws moodle_exception&Throwable + */ + public function internal_systemerror($error) { + } +} diff --git a/phpstan/stubs/public/lib/datalib.stub b/phpstan/stubs/public/lib/datalib.stub new file mode 100644 index 00000000..1cac4f0b --- /dev/null +++ b/phpstan/stubs/public/lib/datalib.stub @@ -0,0 +1,53 @@ + $courses + * @param int|null $userid + * @param int $includeinvisible + * @return stdClass[] + */ +function get_all_instances_in_courses($modulename, $courses, $userid = null, $includeinvisible = false) { +} + +/** + * @param string $modulename + * @param int|stdClass $course + * @param int $userid + * @param int $includeinvisible + * @return stdClass[] + */ +function get_all_instances_in_course($modulename, $course, $userid = null, $includeinvisible = false) { + return get_all_instances_in_courses($modulename, [$course->id => $course], $userid, $includeinvisible); +} diff --git a/phpstan/stubs/public/lib/editor/tiny/classes/editor.stub b/phpstan/stubs/public/lib/editor/tiny/classes/editor.stub new file mode 100644 index 00000000..00c7c481 --- /dev/null +++ b/phpstan/stubs/public/lib/editor/tiny/classes/editor.stub @@ -0,0 +1,6 @@ + $options + * @param array $fpoptions + * @param editor $editor + * @return array + */ + public static function get_plugin_configuration_for_context( + context $context, + array $options, + array $fpoptions, + ?editor $editor = null, + ): array; +} diff --git a/phpstan/stubs/public/lib/editorlib.stub b/phpstan/stubs/public/lib/editorlib.stub new file mode 100644 index 00000000..0ec62085 --- /dev/null +++ b/phpstan/stubs/public/lib/editorlib.stub @@ -0,0 +1,4 @@ + + */ + public function get_directory_files($contextid, $component, $filearea, $itemid, $filepath, $recursive = false, $includedirs = true, $sort = "filepath, filename") { + } + + /** + * @param int $contextid context ID + * @param string $component component + * @param string|false $filearea + * @param int|false $itemid + * @return true + */ + public function delete_area_files($contextid, $component = false, $filearea = false, $itemid = false) { + } } diff --git a/phpstan/stubs/public/lib/filestorage/stored_file.stub b/phpstan/stubs/public/lib/filestorage/stored_file.stub index d06878e1..e7168b6c 100644 --- a/phpstan/stubs/public/lib/filestorage/stored_file.stub +++ b/phpstan/stubs/public/lib/filestorage/stored_file.stub @@ -1,4 +1,18 @@ |null $attributes + * @param bool $editable + * @param array $ajaxformdata + */ + public function __construct( + $action = null, + $customdata = null, + $method = 'post', + $target = '', + $attributes = null, + $editable = true, + $ajaxformdata = null, + ) { + } + + /** + * @param string $elname + * @return string|false + */ + public function save_temp_file($elname) { + } + + /** + * @param string $elname + * @return stored_file[]|false|null + */ + protected function get_draft_files($elname) { + } + + /** + * @param string $elname + * @param int $newcontextid + * @param string $newcomponent + * @param string $newfilearea + * @param int $newitemid + * @param string $newfilepath + * @param string $newfilename + * @param bool $overwrite + * @param int $newuserid + * @return stored_file|false + */ + public function save_stored_file( + $elname, + $newcontextid, + $newcomponent, + $newfilearea, + $newitemid, + $newfilepath = '/', + $newfilename = null, + $overwrite = false, + $newuserid = null, + ) { + } + + /** + * @param string $elname + * @return string|false + */ + public function get_file_content($elname) { + } + + /** + * @return void + */ + abstract protected function definition(); + + /** + * @return void + */ + public function definition_after_data() { + } + + /** + * @param array $data + * @param array $files + * @return array + */ + public function validation($data, $files) { + } +} + class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { } diff --git a/phpstan/stubs/public/lib/grade/constants.stub b/phpstan/stubs/public/lib/grade/constants.stub new file mode 100644 index 00000000..44be05d2 --- /dev/null +++ b/phpstan/stubs/public/lib/grade/constants.stub @@ -0,0 +1,6 @@ + + */ + public static function fetch_users_grades($grade_item, $userids, $include_missing = true) { + } +} diff --git a/phpstan/stubs/public/lib/grade/grade_item.stub b/phpstan/stubs/public/lib/grade/grade_item.stub new file mode 100644 index 00000000..24d9fd76 --- /dev/null +++ b/phpstan/stubs/public/lib/grade/grade_item.stub @@ -0,0 +1,25 @@ + $params + * @return grade_item|false + */ + public static function fetch($params) { + } + + /** + * @param array $params + * @return grade_item[]|false + */ + public static function fetch_all($params) { + } +} diff --git a/phpstan/stubs/public/lib/grade/grade_object.stub b/phpstan/stubs/public/lib/grade/grade_object.stub new file mode 100644 index 00000000..2e230ea0 --- /dev/null +++ b/phpstan/stubs/public/lib/grade/grade_object.stub @@ -0,0 +1,4 @@ +|null $param the variable array we are cleaning + * @param PARAM_ALPHA|PARAM_ALPHAEXT|PARAM_ALPHANUM|PARAM_ALPHANUMEXT|PARAM_AUTH|PARAM_BASE64|PARAM_BOOL|PARAM_CAPABILITY|PARAM_CLEANHTML|PARAM_EMAIL|PARAM_FILE|PARAM_FLOAT|PARAM_LOCALISEDFLOAT|PARAM_HOST|PARAM_INT|PARAM_LANG|PARAM_LOCALURL|PARAM_NOTAGS|PARAM_PATH|PARAM_PEM|PARAM_PERMISSION|PARAM_RAW|PARAM_RAW_TRIMMED|PARAM_SAFEDIR|PARAM_SAFEPATH|PARAM_SEQUENCE|PARAM_TAG|PARAM_TAGLIST|PARAM_TEXT|PARAM_THEME|PARAM_URL|PARAM_USERNAME|PARAM_STRINGID|PARAM_TIMEZONE|PARAM_COMPONENT|PARAM_AREA|PARAM_PLUGIN $type + * @param bool $recursive clean recursive arrays + * @return ( + * $type is PARAM_ALPHA ? string|null : + * $type is PARAM_ALPHAEXT ? string|null : + * $type is PARAM_ALPHANUM ? string|null : + * $type is PARAM_ALPHANUMEXT ? string|null : + * $type is PARAM_AUTH ? string : + * $type is PARAM_BASE64 ? string : + * $type is PARAM_BOOL ? 0|1 : + * $type is PARAM_CAPABILITY ? string : + * $type is PARAM_CLEANHTML ? string : + * $type is PARAM_EMAIL ? string : + * $type is PARAM_FILE ? string : + * $type is PARAM_FLOAT ? float : + * $type is PARAM_LOCALISEDFLOAT ? float|false : + * $type is PARAM_HOST ? string : + * $type is PARAM_INT ? int : + * $type is PARAM_LANG ? string : + * $type is PARAM_LOCALURL ? string : + * $type is PARAM_NOTAGS ? string : + * $type is PARAM_PATH ? string : + * $type is PARAM_PEM ? string : + * $type is PARAM_PERMISSION ? CAP_INHERIT|CAP_ALLOW|CAP_PREVENT|CAP_PROHIBIT : + * $type is PARAM_RAW ? mixed : + * $type is PARAM_RAW_TRIMMED ? string : + * $type is PARAM_SAFEDIR ? string : + * $type is PARAM_SAFEPATH ? string : + * $type is PARAM_SEQUENCE ? string|null : + * $type is PARAM_TAG ? string : + * $type is PARAM_TAGLIST ? string : + * $type is PARAM_TEXT ? string : + * $type is PARAM_THEME ? string : + * $type is PARAM_URL ? string : + * $type is PARAM_USERNAME ? string : + * $type is PARAM_STRINGID ? string : + * $type is PARAM_TIMEZONE ? string : + * $type is PARAM_COMPONENT ? string : + * $type is PARAM_AREA ? string : + * $type is PARAM_PLUGIN ? string : + * mixed + * )[] + * @throws coding_exception&Throwable + */ +function clean_param_array(?array $param, $type, $recursive = false) { +} + +/** + * @param mixed $param + * @param PARAM_ALPHA|PARAM_ALPHAEXT|PARAM_ALPHANUM|PARAM_ALPHANUMEXT|PARAM_AUTH|PARAM_BASE64|PARAM_BOOL|PARAM_CAPABILITY|PARAM_CLEANHTML|PARAM_EMAIL|PARAM_FILE|PARAM_FLOAT|PARAM_LOCALISEDFLOAT|PARAM_HOST|PARAM_INT|PARAM_LANG|PARAM_LOCALURL|PARAM_NOTAGS|PARAM_PATH|PARAM_PEM|PARAM_PERMISSION|PARAM_RAW|PARAM_RAW_TRIMMED|PARAM_SAFEDIR|PARAM_SAFEPATH|PARAM_SEQUENCE|PARAM_TAG|PARAM_TAGLIST|PARAM_TEXT|PARAM_THEME|PARAM_URL|PARAM_USERNAME|PARAM_STRINGID|PARAM_TIMEZONE|PARAM_COMPONENT|PARAM_AREA|PARAM_PLUGIN $type + * @return ( + * $type is PARAM_ALPHA ? string|null : + * $type is PARAM_ALPHAEXT ? string|null : + * $type is PARAM_ALPHANUM ? string|null : + * $type is PARAM_ALPHANUMEXT ? string|null : + * $type is PARAM_AUTH ? string : + * $type is PARAM_BASE64 ? string : + * $type is PARAM_BOOL ? 0|1 : + * $type is PARAM_CAPABILITY ? string : + * $type is PARAM_CLEANHTML ? string : + * $type is PARAM_EMAIL ? string : + * $type is PARAM_FILE ? string : + * $type is PARAM_FLOAT ? float : + * $type is PARAM_LOCALISEDFLOAT ? float|false : + * $type is PARAM_HOST ? string : + * $type is PARAM_INT ? int : + * $type is PARAM_LANG ? string : + * $type is PARAM_LOCALURL ? string : + * $type is PARAM_NOTAGS ? string : + * $type is PARAM_PATH ? string : + * $type is PARAM_PEM ? string : + * $type is PARAM_PERMISSION ? CAP_INHERIT|CAP_ALLOW|CAP_PREVENT|CAP_PROHIBIT : + * $type is PARAM_RAW ? mixed : + * $type is PARAM_RAW_TRIMMED ? string : + * $type is PARAM_SAFEDIR ? string : + * $type is PARAM_SAFEPATH ? string : + * $type is PARAM_SEQUENCE ? string|null : + * $type is PARAM_TAG ? string : + * $type is PARAM_TAGLIST ? string : + * $type is PARAM_TEXT ? string : + * $type is PARAM_THEME ? string : + * $type is PARAM_URL ? string : + * $type is PARAM_USERNAME ? string : + * $type is PARAM_STRINGID ? string : + * $type is PARAM_TIMEZONE ? string : + * $type is PARAM_COMPONENT ? string : + * $type is PARAM_AREA ? string : + * $type is PARAM_PLUGIN ? string : + * mixed + * ) + * @throws coding_exception&Throwable + */ +function clean_param($param, $type) { +} + /** * @param string $name * @param string|int|bool|null $value @@ -265,7 +365,7 @@ function unset_all_config_for_plugin($plugin) { * @param string|null $plugin * @param string|null $name * @return ($name is null ? stdClass : string|false) - * @throws dml_exception&\Throwable + * @throws dml_exception&Throwable */ function get_config($plugin, $name = null) { } @@ -282,7 +382,7 @@ function get_file_storage($reset = false) { * @param string|int|bool|null $value * @param stdClass|int|null $user * @return true - * @throws coding_exception&\Throwable + * @throws coding_exception&Throwable */ function set_user_preference($name, $value, $user = null) { } @@ -299,7 +399,7 @@ function set_user_preferences(array $prefarray, $user = null) { * @param string $name * @param stdClass|int|null $user * @return true - * @throws coding_exception&\Throwable + * @throws coding_exception&Throwable */ function unset_user_preference($name, $user = null) { } @@ -310,7 +410,82 @@ function unset_user_preference($name, $user = null) { * @param T $default * @param stdClass|int|null $user * @return ($name is null ? array : string|T|null) - * @throws coding_exception&\Throwable + * @throws coding_exception&Throwable */ function get_user_preferences($name = null, $default = null, $user = null) { } + +/** + * @param stdClass|null|false $user + * @param bool $override + * @return ($user is object ? string : '') + */ +function fullname($user, $override = false) { +} + +/** + * @param 'get'|'buffer'|'close'|'flush' $action + * @return ($action is 'get' ? moodle_phpmailer : null) + */ +function get_mailer($action = 'get') { +} + +/** + * @param stdClass $user + * @param stdClass|string $from + * @param string $subject + * @param string $messagetext + * @param string $messagehtml + * @param string $attachment + * @param string $attachname + * @param bool $usetrueaddress + * @param string $replyto + * @param string $replytoname + * @param int $wordwrapwidth + * @return bool + */ +function email_to_user( + $user, + $from, + $subject, + $messagetext, + $messagehtml = '', + $attachment = '', + $attachname = '', + $usetrueaddress = true, + $replyto = '', + $replytoname = '', + $wordwrapwidth = 79, +) { +} + +/** + * @phpstan-import-type get_string_a from lang_string + * @param string $identifier + * @param string $component + * @param ( + * string|object|int|float|bool|Stringable + * |array< + * string, + * string|object|int|float|bool|Stringable + * > + * ) $a + * @param bool $lazyload + * @return ($lazyload is false ? string : lang_string) + * @throws coding_exception&Throwable + */ +function get_string($identifier, $component = '', $a = null, $lazyload = false) { +} + +/** + * @param string[] $array + * @param string $component + * @return stdClass + */ +function get_strings($array, $component = '') { + $string = new stdClass(); + foreach ($array as $item) { + $string->$item = get_string($item, $component); + } + return $string; +} diff --git a/phpstan/stubs/public/lib/pear/HTML/QuickForm.stub b/phpstan/stubs/public/lib/pear/HTML/QuickForm.stub index 2b4dd7b9..04bd721c 100644 --- a/phpstan/stubs/public/lib/pear/HTML/QuickForm.stub +++ b/phpstan/stubs/public/lib/pear/HTML/QuickForm.stub @@ -52,4 +52,56 @@ class HTML_QuickForm extends HTML_Common { */ public function &addElement($element, ...$args) { } + + /** + * @param string $elementType + * @param mixed[] $args + * @return ( + * $elementType is 'advcheckbox' ? MoodleQuickForm_advcheckbox : + * $elementType is 'autocomplete' ? MoodleQuickForm_autocomplete : + * $elementType is 'button' ? MoodleQuickForm_button : + * $elementType is 'cancel' ? MoodleQuickForm_cancel : + * $elementType is 'course' ? MoodleQuickForm_course : + * $elementType is 'cohort' ? MoodleQuickForm_cohort : + * $elementType is 'searchableselector' ? MoodleQuickForm_searchableselector : + * $elementType is 'checkbox' ? MoodleQuickForm_checkbox : + * $elementType is 'choicedropdown' ? MoodleQuickForm_choicedropdown : + * $elementType is 'date_selector' ? MoodleQuickForm_date_selector : + * $elementType is 'date_time_selector' ? MoodleQuickForm_date_time_selector : + * $elementType is 'duration' ? MoodleQuickForm_duration : + * $elementType is 'editor' ? MoodleQuickForm_editor : + * $elementType is 'filemanager' ? MoodleQuickForm_filemanager : + * $elementType is 'filepicker' ? MoodleQuickForm_filepicker : + * $elementType is 'filetypes' ? MoodleQuickForm_filetypes : + * $elementType is 'float' ? MoodleQuickForm_float : + * $elementType is 'grading' ? MoodleQuickForm_grading : + * $elementType is 'group' ? MoodleQuickForm_group : + * $elementType is 'header' ? MoodleQuickForm_header : + * $elementType is 'hidden' ? MoodleQuickForm_hidden : + * $elementType is 'listing' ? MoodleQuickForm_listing : + * $elementType is 'defaultcustom' ? MoodleQuickForm_defaultcustom : + * $elementType is 'modgrade' ? MoodleQuickForm_modgrade : + * $elementType is 'modvisible' ? MoodleQuickForm_modvisible : + * $elementType is 'password' ? MoodleQuickForm_password : + * $elementType is 'passwordunmask' ? MoodleQuickForm_passwordunmask : + * $elementType is 'questioncategory' ? MoodleQuickForm_questioncategory : + * $elementType is 'radio' ? MoodleQuickForm_radio : + * $elementType is 'recaptcha' ? MoodleQuickForm_recaptcha : + * $elementType is 'select' ? MoodleQuickForm_select : + * $elementType is 'selectgroups' ? MoodleQuickForm_selectgroups : + * $elementType is 'selectwithlink' ? MoodleQuickForm_selectwithlink : + * $elementType is 'selectyesno' ? MoodleQuickForm_selectyesno : + * $elementType is 'static' ? MoodleQuickForm_static : + * $elementType is 'submit' ? MoodleQuickForm_submit : + * $elementType is 'tags' ? MoodleQuickForm_tags : + * $elementType is 'text' ? MoodleQuickForm_text : + * $elementType is 'textarea' ? MoodleQuickForm_textarea : + * $elementType is 'url' ? MoodleQuickForm_url : + * $elementType is 'warning' ? MoodleQuickForm_warning : + * HTML_QuickForm_element + * ) + * @throws HTML_QuickForm_Error&Throwable + */ + public function &createElement($elementType, ...$args) { + } } diff --git a/phpstan/stubs/public/lib/phpmailer/moodle_phpmailer.stub b/phpstan/stubs/public/lib/phpmailer/moodle_phpmailer.stub new file mode 100644 index 00000000..36b1f549 --- /dev/null +++ b/phpstan/stubs/public/lib/phpmailer/moodle_phpmailer.stub @@ -0,0 +1,4 @@ +&2 + exit 1 + ;; +esac + +status=0 + +set +e find phpstan/stubs -type f -name '*.stub' -print0 | -while IFS= read -r -d '' stub; do - ./vendor/bin/pint "$stub" -done + xargs -0 -n "$BATCH_SIZE" ./vendor/bin/pint "${pint_args[@]}" +xargs_status=$? +set -e + +# xargs returns 123 if any invocation exited with status 1-125. +if [ "$xargs_status" -ne 0 ]; then + status=1 +fi + +exit "$status"