Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
m1r0 committed Nov 4, 2024
1 parent c286e5c commit b951a2c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 42 deletions.
87 changes: 59 additions & 28 deletions config/psalm/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1789,9 +1789,8 @@
<code>$user_id</code>
<code>$which</code>
</MissingParamType>
<MissingPropertyType occurrences="3">
<MissingPropertyType occurrences="2">
<code>$file</code>
<code>$name</code>
<code>$page_slug</code>
</MissingPropertyType>
<PossiblyFalseArgument occurrences="1">
Expand Down Expand Up @@ -2403,6 +2402,13 @@
<InvalidStringClass occurrences="1">
<code>new $class_name()</code>
</InvalidStringClass>
<MissingConstructor occurrences="5">
<code>$course</code>
<code>$lesson</code>
<code>$messages</code>
<code>$question</code>
<code>$quiz</code>
</MissingConstructor>
<MissingPropertyType occurrences="3">
<code>$role_caps</code>
<code>$slider_labels</code>
Expand All @@ -2422,17 +2428,12 @@
<code>get_queried_object()-&gt;ID</code>
<code>get_queried_object()-&gt;post_type</code>
</PossiblyNullPropertyFetch>
<PropertyNotSetInConstructor occurrences="10">
<PropertyNotSetInConstructor occurrences="5">
<code>$course</code>
<code>$lesson</code>
<code>$messages</code>
<code>$question</code>
<code>$quiz</code>
<code>WooThemes_Sensei_PostTypes</code>
<code>WooThemes_Sensei_PostTypes</code>
<code>WooThemes_Sensei_PostTypes</code>
<code>WooThemes_Sensei_PostTypes</code>
<code>WooThemes_Sensei_PostTypes</code>
</PropertyNotSetInConstructor>
<RedundantConditionGivenDocblockType occurrences="1">
<code>$post instanceof WP_Post</code>
Expand Down Expand Up @@ -2504,6 +2505,10 @@
<code>$question_id</code>
<code>Sensei()-&gt;lesson-&gt;get_course_id( $lesson_id )</code>
</InvalidScalarArgument>
<MissingConstructor occurrences="2">
<code>$meta_fields</code>
<code>$token</code>
</MissingConstructor>
<MissingParamType occurrences="18">
<code>$post</code>
<code>$post_id</code>
Expand Down Expand Up @@ -2695,6 +2700,19 @@
<code>string</code>
<code>string</code>
</InvalidReturnType>
<MissingConstructor occurrences="11">
<code>$errors</code>
<code>$fields</code>
<code>$has_imageselector</code>
<code>$has_range</code>
<code>$has_tabs</code>
<code>$page_slug</code>
<code>$sections</code>
<code>$settings</code>
<code>$settings_version</code>
<code>$token</code>
<code>$token_legacy</code>
</MissingConstructor>
<MissingParamType occurrences="2">
<code>$section</code>
<code>$type</code>
Expand Down Expand Up @@ -2736,6 +2754,30 @@
<PossiblyNullPropertyFetch occurrences="1">
<code>get_current_screen()-&gt;id</code>
</PossiblyNullPropertyFetch>
<PropertyNotSetInConstructor occurrences="22">
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
<code>WooThemes_Sensei_Settings</code>
</PropertyNotSetInConstructor>
<RedundantCondition occurrences="1">
<code>empty( $template-&gt;title )</code>
</RedundantCondition>
Expand Down Expand Up @@ -4181,11 +4223,9 @@
<InvalidGlobal occurrences="1">
<code>global $sensei_email_data;</code>
</InvalidGlobal>
<MissingPropertyType occurrences="6">
<code>$heading</code>
<MissingPropertyType occurrences="4">
<code>$learner</code>
<code>$recipient</code>
<code>$subject</code>
<code>$teacher</code>
<code>$template</code>
</MissingPropertyType>
Expand Down Expand Up @@ -4364,6 +4404,9 @@
<DocblockTypeContradiction occurrences="1">
<code>is_wp_error( $result )</code>
</DocblockTypeContradiction>
<InvalidAttribute occurrences="1">
<code>\ReturnTypeWillChange</code>
</InvalidAttribute>
<InvalidScalarArgument occurrences="1">
<code>$timestamp</code>
</InvalidScalarArgument>
Expand All @@ -4377,6 +4420,9 @@
<code>false</code>
<code>false</code>
</FalsableReturnStatement>
<InvalidAttribute occurrences="1">
<code>\ReturnTypeWillChange</code>
</InvalidAttribute>
<InvalidFalsableReturnType occurrences="1">
<code>array</code>
</InvalidFalsableReturnType>
Expand Down Expand Up @@ -4432,8 +4478,7 @@
<code>$post</code>
<code>$post</code>
</ParamNameMismatch>
<PossiblyNullArgument occurrences="2">
<code>get_edit_post_link( $post )</code>
<PossiblyNullArgument occurrences="1">
<code>get_edit_post_link( $post-&gt;ID )</code>
</PossiblyNullArgument>
<PropertyNotSetInConstructor occurrences="4">
Expand Down Expand Up @@ -4970,13 +5015,6 @@
</TypeDoesNotContainType>
</file>
<file src="includes/rest-api/class-sensei-rest-api-course-progress-controller.php">
<InvalidClass occurrences="1">
<code>WP_HTTP</code>
</InvalidClass>
<PossiblyInvalidArrayAssignment occurrences="2">
<code>$result[ $student_id ][ $course_id ]</code>
<code>$result[ $student_id ][ $course_id ]</code>
</PossiblyInvalidArrayAssignment>
<PossiblyNullArgument occurrences="1">
<code>$edit_course_cap</code>
</PossiblyNullArgument>
Expand Down Expand Up @@ -5013,8 +5051,7 @@
<code>WP_HTTP</code>
<code>WP_HTTP</code>
</InvalidClass>
<PossiblyInvalidArrayAssignment occurrences="2">
<code>$result[ $user_id ][ $course_id ]</code>
<PossiblyInvalidArrayAssignment occurrences="1">
<code>$result[ $user_id ][ $course_id ]</code>
</PossiblyInvalidArrayAssignment>
<PossiblyNullArgument occurrences="1">
Expand Down Expand Up @@ -5249,12 +5286,6 @@
</UndefinedPropertyFetch>
</file>
<file src="includes/rest-api/class-sensei-rest-api-question-helpers-trait.php">
<ArgumentTypeCoercion occurrences="1">
<code>$post_args</code>
</ArgumentTypeCoercion>
<InvalidArgument occurrences="1">
<code>$post_args</code>
</InvalidArgument>
<PossibleRawObjectIteration occurrences="1">
<code>$question_categories</code>
</PossibleRawObjectIteration>
Expand Down
11 changes: 1 addition & 10 deletions includes/class-sensei-lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ class Sensei_Lesson {
*/
private $lesson_id_updating;

/**
* Message to display on the legacy quiz meta boxes.
*
* @since 3.9.1
*
* @var string
*/
private $legacy_quiz_message;

/**
* Constructor.
*
Expand Down Expand Up @@ -1245,7 +1236,7 @@ public function lesson_course_meta_box_content() {
}

/**
* Get the legazy quiz message.
* Get the message to display on the legacy quiz meta boxes.
*
* @return string
*/
Expand Down
8 changes: 4 additions & 4 deletions includes/class-sensei-posttypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -910,11 +910,11 @@ public function setup_lesson_tag_taxonomy() {
/**
* Get the singular, plural and menu label names for the post types.
*
* @param string $post_type The post type.
* @param string|null $post_type The post type.
*
* @return string[]
* @return array
*/
private function get_main_post_type_labels( $post_type ) {
private function get_main_post_type_labels( $post_type = null ) {
$labels = array(
'course' => array(
'singular' => __( 'Course', 'sensei-lms' ),
Expand Down Expand Up @@ -948,7 +948,7 @@ private function get_main_post_type_labels( $post_type ) {
),
);

return $labels[ $post_type ];
return $post_type ? $labels[ $post_type ] : $labels;
}

/**
Expand Down

0 comments on commit b951a2c

Please sign in to comment.