Skip to content

[Refactor:Developer] PHPStan typing on magic methods#11726

Merged
williamjallen merged 6 commits into
mainfrom
magic_method_typing
Jun 13, 2025
Merged

[Refactor:Developer] PHPStan typing on magic methods#11726
williamjallen merged 6 commits into
mainfrom
magic_method_typing

Conversation

@cjreed121

Copy link
Copy Markdown
Member

Please check if the PR fulfills these requirements:

  • Tests for the changes have been added/updated (if possible)
  • Documentation has been updated/added if relevant
  • Screenshots are attached to Github PR if visual/UI changes were made

What is the current behavior?

PHPStan collects no typing information off of magic methods. Due to our high usage of magic methods, this significantly hurts the type static analysis.

What is the new behavior?

PHPStan now collects typing information from magic methods.

Other information?

I ignored some of the newer more complex phpstan errors. Some of them are a bit concerning and should be addressed ASAP but don't belong in this PR. The ones that were simple I did fix.

@cjreed121

Copy link
Copy Markdown
Member Author

Please do not push on my branch without asking me first

@cjreed121 cjreed121 mentioned this pull request Jun 8, 2025
43 tasks
@codecov

codecov Bot commented Jun 8, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 21.04%. Comparing base (33231f8) to head (5a35498).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #11726      +/-   ##
============================================
+ Coverage     19.99%   21.04%   +1.04%     
  Complexity     9077     9077              
============================================
  Files           249      258       +9     
  Lines         34335    34866     +531     
  Branches        461      461              
============================================
+ Hits           6865     7337     +472     
- Misses        27013    27072      +59     
  Partials        457      457              
Flag Coverage Δ
autograder 21.44% <ø> (ø)
js 4.65% <ø> (ø)
migrator 100.00% <ø> (ø)
php 19.57% <20.00%> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 88.88% <ø> (?)

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.

@williamjallen williamjallen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks pretty good overall. I'd be fine merging it as-is, but I'd like to get some answers to the inline questions I left first.

Comment thread site/tests/phpstan/SubmittyMagicMethodReflection.php
Comment thread site/tests/phpstan/SubmittyMagicMethodReflection.php Outdated
Comment thread site/tests/phpstan/SubmittyMagicVariant.php
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Awaiting Maintainer Review in Submitty Development Jun 13, 2025
@williamjallen
williamjallen merged commit 65320e2 into main Jun 13, 2025
24 checks passed
@williamjallen
williamjallen deleted the magic_method_typing branch June 13, 2025 01:21
@github-project-automation github-project-automation Bot moved this from Awaiting Maintainer Review to Done in Submitty Development Jun 13, 2025
bmcutler pushed a commit that referenced this pull request Aug 1, 2025
### 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. -->

Gradeable.php previously relied on magic methods.

This caused challenges for upgrading PHPUnit and and continuing to
support PHPStan for static type analysis.
PR #11726 mostly addressed these concerns.

However magic methods have caused confusion for junior Submitty
developers.
AND the code still contained typos/errors in the types of these methods.

### What is the New Behavior?
<!-- Include before & after screenshots/videos if the user interface has
changed. -->

This PR removes the magic methods usage in one file.  
The getters and setters are manually created.

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

### Automated Testing & Documentation
<!-- Is this feature sufficiently tested by unit tests and end-to-end
tests?
If this PR does not add/update the necessary automated tests, write a
new GitHub issue and link it below.
Is this feature sufficiently documented on submitty.org?
Link related PRs or new GitHub issue to update documentation. -->

### Other information
<!-- Is this a breaking change?  
Does this PR include migrations to update existing installations?  
Are there security concerns with this PR? -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants