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 511f63a commit 7cc134a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 48 deletions.
38 changes: 4 additions & 34 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 @@ -2422,18 +2421,6 @@
<code>get_queried_object()-&gt;ID</code>
<code>get_queried_object()-&gt;post_type</code>
</PossiblyNullPropertyFetch>
<PropertyNotSetInConstructor occurrences="10">
<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>
</RedundantConditionGivenDocblockType>
Expand Down Expand Up @@ -4181,11 +4168,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 @@ -4432,8 +4417,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 +4954,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 +4990,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 +5225,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
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<referencedProperty name="Sensei_Main::$lesson_progress_repository_factory" />
<referencedProperty name="Sensei_Main::$quiz_progress_repository_factory" />
<referencedProperty name="Sensei_REST_API_Lesson_Actions_Controller::$schema" />
<referencedProperty name="Sensei_PostTypes::$course" />
<referencedProperty name="Sensei_PostTypes::$lesson" />
<referencedProperty name="Sensei_PostTypes::$question" />
<referencedProperty name="Sensei_PostTypes::$quiz" />
<referencedProperty name="Sensei_PostTypes::$messages" />
</errorLevel>
</PropertyNotSetInConstructor>
<UndefinedClass>
Expand Down

0 comments on commit 7cc134a

Please sign in to comment.