Skip to content

[Refactor:CourseMaterials] Phpstan 2.1.32 compatibility#12150

Merged
bmcutler merged 7 commits intomainfrom
phpstan-prep
Dec 15, 2025
Merged

[Refactor:CourseMaterials] Phpstan 2.1.32 compatibility#12150
bmcutler merged 7 commits intomainfrom
phpstan-prep

Conversation

@lavalleeale
Copy link
Contributor

@lavalleeale lavalleeale commented Oct 21, 2025

Why is this Change Important & Necessary?

Before we can merge #12093 (superseded by #12260), we need to make sure that all of our code is compatible with the new version of phpstan, and this was the one place that our code has started failing.

What is the New Behavior?

Phpstan 2.1.32 now passes after this change.

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Checkout [DevDependency] Bump phpstan/phpstan from 2.1.22 to 2.1.32 in /site #12260 and run composer install and then phpstan and view that 1 error is detected
  2. Run git diff main phpstan-prep | git apply to get the changes from this branch
  3. Run phpstan again and it shall pass

Automated Testing & Documentation

Other information

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.69%. Comparing base (7d24f40) to head (e7c3c47).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #12150   +/-   ##
=========================================
  Coverage     21.69%   21.69%           
  Complexity     9618     9618           
=========================================
  Files           268      268           
  Lines         36113    36113           
  Branches        478      478           
=========================================
  Hits           7835     7835           
  Misses        27804    27804           
  Partials        474      474           
Flag Coverage Δ
autograder 21.39% <ø> (ø)
js 2.07% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.69% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 90.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lavalleeale lavalleeale changed the title [Refactor:CourseMaterials] Phpstan 2.1.31 compatability [Refactor:CourseMaterials] Phpstan 2.1.31 compatibility Oct 21, 2025
*
* @param array<mixed> $course_materials - Dictionary: path name => CourseMaterial.
* @param array<string> $folder_paths - List we append
* @param array<int|string, int|string> $folder_paths - List we append
Copy link
Contributor

@skara9 skara9 Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to allow integers in folder_paths?
And why are you changing it from a string array to a map?

@github-project-automation github-project-automation bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Oct 21, 2025
@github-actions github-actions bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Nov 5, 2025
@RyanStyron RyanStyron closed this Nov 14, 2025
@github-project-automation github-project-automation bot moved this from Work in Progress to Done in Submitty Development Nov 14, 2025
@RyanStyron RyanStyron reopened this Nov 14, 2025
@RyanStyron RyanStyron changed the title [Refactor:CourseMaterials] Phpstan 2.1.31 compatibility [Refactor:CourseMaterials] Phpstan 2.1.32 compatibility Dec 2, 2025
@RyanStyron RyanStyron requested a review from skara9 December 2, 2025 21:42
@RyanStyron RyanStyron moved this from Done to Seeking Reviewer in Submitty Development Dec 2, 2025
@RyanStyron RyanStyron moved this from Seeking Reviewer to In Review in Submitty Development Dec 2, 2025
* @param array<mixed> $course_materials - Dictionary: path name => CourseMaterial.
* @return array<string> List of folders paths.
* @param array<string, CourseMaterial|array<string, CourseMaterial>> $course_materials - Dictionary: path name => CourseMaterial.
* @return array<int, string> List of folders paths.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return array<int, string> List of folders paths.
* @return array<string> List of folders paths.

Is there a reason this was changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileAllFolderPaths returns $folder_paths, which is assigned by reference in compileAllFolderPathsR. In compileAllFolderPathsR, $folder_paths is assigned via invocation of array_push, which adds string elements (folder paths) to the array using int keys, which results in a sequential indexed array of strings (array<int, string>). This is the doc type expected by PHPStan, so that's why the change had to be made.

@RyanStyron RyanStyron self-assigned this Dec 11, 2025
@RyanStyron RyanStyron requested a review from skara9 December 15, 2025 16:13
@github-project-automation github-project-automation bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Dec 15, 2025
@skara9 skara9 moved this from Awaiting Maintainer Review to Ready to Merge in Submitty Development Dec 15, 2025
@bmcutler bmcutler merged commit 905706f into main Dec 15, 2025
48 of 49 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Merge to Done in Submitty Development Dec 15, 2025
@bmcutler bmcutler deleted the phpstan-prep branch December 15, 2025 18:43
williamjallen added a commit that referenced this pull request Jan 3, 2026
)

### Why is this Change Important & Necessary?
<!-- Include any GitHub issue that is fixed/closed using "Fixes
#<number>" or "Closes #<number>" syntax.
Alternately write "Partially addresses #<number>" or "Related to
#<number>" as appropriate. -->
As a continuation of #12150, before merging
#12260, it is necessary to
ensure that all of the code is compatible with the new version of
PHPStan.

### What is the New Behavior?
<!-- Include before & after screenshots/videos if the user interface has
changed. -->
PHPStan 2.1.32 check now passes after this change.

### What steps should a reviewer take to reproduce or test the bug or
new feature?
1. Checkout #12260 and then
PHPStan
([documentation](https://submitty.org/developer/testing/linting_static_analysis))
2. Run `git diff main phpstan-upgrade-prep-2 | git apply` to apply the
changes from
this branch
3. Run PHPStan again and the test will pass

---------

Co-authored-by: William Allen <william.j.allen24@gmail.com>
Aaditya-2407 pushed a commit to Aaditya-2407/Submitty that referenced this pull request Jan 5, 2026
…mitty#12284)

### Why is this Change Important & Necessary?
<!-- Include any GitHub issue that is fixed/closed using "Fixes
#<number>" or "Closes #<number>" syntax.
Alternately write "Partially addresses #<number>" or "Related to
#<number>" as appropriate. -->
As a continuation of Submitty#12150, before merging
Submitty#12260, it is necessary to
ensure that all of the code is compatible with the new version of
PHPStan.

### What is the New Behavior?
<!-- Include before & after screenshots/videos if the user interface has
changed. -->
PHPStan 2.1.32 check now passes after this change.

### What steps should a reviewer take to reproduce or test the bug or
new feature?
1. Checkout Submitty#12260 and then
PHPStan
([documentation](https://submitty.org/developer/testing/linting_static_analysis))
2. Run `git diff main phpstan-upgrade-prep-2 | git apply` to apply the
changes from
this branch
3. Run PHPStan again and the test will pass

---------

Co-authored-by: William Allen <william.j.allen24@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants