-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code analysis for Laravel 9 branch #64
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LukeTowers
reviewed
Dec 17, 2021
- Enforce only the "$attributes" parameter to be available to the constructor via an Interface. - Build Pivot models using a static "fromAttributes" / "fromRawAttributes" method as opposed to a custom constructor.
This should hint that extensions to the User framework should have an "is_superuser" field available for super-user functionality that is expected in Winter.
- Also added the "getMany" method that Laravel now contains. While we have customised our own Config repository implementation, we still follow Laravel in many aspects, so we should extend their class to allow classes which resolve to Laravel's Config repository directly (as opposed to the contract) to still work.
Our Auth Manager implementation clashes a lot with Illuminate's Authenticable implementation. We'll need to revisit this at some point.
LukeTowers
reviewed
Jul 1, 2022
LukeTowers
reviewed
Jul 1, 2022
LukeTowers
reviewed
Jul 1, 2022
LukeTowers
reviewed
Jul 1, 2022
LukeTowers
reviewed
Jul 1, 2022
Co-authored-by: Luke Towers <[email protected]>
Co-authored-by: Luke Towers <[email protected]>
LukeTowers
approved these changes
Jul 3, 2022
bennothommo
added a commit
to wintercms/winter
that referenced
this pull request
Jul 4, 2022
Implements fixes to some breaking changes introduced in wintercms/storm#64.
bennothommo
added a commit
to wintercms/wn-system-module
that referenced
this pull request
Jul 4, 2022
Implements fixes to some breaking changes introduced in wintercms/storm#64.
bennothommo
added a commit
to wintercms/wn-cms-module
that referenced
this pull request
Jul 4, 2022
Implements fixes to some breaking changes introduced in wintercms/storm#64.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thought I would try installing Larastan/PHPStan and run some code analysis to look for some invalid PHP docblocks and dead code and the like. So far, it's picked up about 1100 errors - not sure if it's a bridge too far to cross, but interesting nonetheless.
We're testing against Level 5 so far, which seems to be a good compromise between ensuring all docblocks and signatures are correct whilst not having PHPStan being pedantic about everything.
Modules
Breaking changes introduced
We will need to discuss these before merging.
Database
$attributes
parameter via an interface (\Winter\Storm\Database\ModelInterface
and\Winter\Storm\Halcyon\ModelInterface
). This will ensure that calls likeModel::make()
orModel::create()
will execute correctly. It is possible that some people might have used additional parameters for their model constructors - these will no longer work and must be moved to another method.$attributes
parameter as per the Model class. Construction now happens more closely to Laravel's format of calling aPivot::fromAttributes()
static method. If you previously usednew Pivot()
to create a pivot model, switch to usingPivot::fromAttributes()
instead.MorphToMany
class now extends theMorphToMany
class from Laravel, as opposed to theBelongsToMany
class in Winter. This prevents repeated code in the WinterMorphToMany
class and maintains covariance with Laravel. This will mean that it will no longer inherit from the WinterBelongsToMany
class. To allow for this, we have converted most of the overriddenBelongsToMany
functionality in Winter into a trait (Concerns\BelongsOrMorphsToMany
). TheBelongsToMany
class now also uses this trait.src/Database/Relations
have been moved tosrc/Database/Relations/Concerns
, in order to keep just the actual relation classes within this directory. In the unlikely event that you are using a relation trait directly, please rename the trait classes to the following:Winter\Storm\Database\Relations\AttachOneOrMany
toWinter\Storm\Database\Relations\Concerns\AttachOneOrMany
Winter\Storm\Database\Relations\DeferOneOrMany
toWinter\Storm\Database\Relations\Concerns\DeferOneOrMany
Winter\Storm\Database\Relations\DefinedConstraints
toWinter\Storm\Database\Relations\Concerns\DefinedConstraints
Winter\Storm\Database\Relations\HasOneOrMany
toWinter\Storm\Database\Relations\Concerns\HasOneOrMany
Winter\Storm\Database\Relations\MorphOneOrMany
toWinter\Storm\Database\Relations\Concerns\MorphOneOrMany
Extension
Winter\Storm\Extension\Extendable::extendClassWith()
method returned the current class if the extension name provided was an empty string. This appears to be a code smell, so this has been changed to throw an Exception.Filesystem
Filesystem::symbolizePath
method's$default
parameter now accepts astring
,bool
ornull
. Only in the case ofnull
will the method return the original path - the given$default
will be used in all other cases. This is the same as the original functionality, but we're documenting it in case you have customised this method in some fashion.Filesystem::isPathSymbol
method previously returned the path symbol used, as a string, if one was found andfalse
if not found. However, the docblock stipulated, as well as the method name itself implied, that this is a boolean check function, so we have converted this to a straight boolean response -true
if a path symbol is used, otherwisefalse
.Filesystem
namespace have had type hinting and return types added to enforce functionality and clarify documentation. If you extend any of these classes in your plugins, you may need to update your method signatures.Foundation
Application
class callback methodsbefore
andafter
were documented asvoid
methods, but returned a value. These no longer return a value.Halcyon
$attributes
parameter via an interface (\Winter\Storm\Database\ModelInterface
and\Winter\Storm\Halcyon\ModelInterface
). This will ensure that calls likeModel::make()
orModel::create()
will execute correctly. It is possible that some people might have used additional parameters for their model constructors - these will no longer work and must be moved to another method.insert
method now returns anint
representing the created model's filesize, not abool
.insert
method requires the$values
parameter to actually contain variables and will throw an Exception if an empty array is provided. Previously, this was silently discarded and returnedtrue
(although this would not actually save the file).HTML
Winter\Storm\Html\FormBuilder
class has had type hinting and return types added to enforce functionality and clarify documentation. If you extend this class in your plugin, you may need to make changes to your method signatures if you overwrite the base functionality.Parse
Bracket
class constructor is nowfinal
to prevent unsafe static calls to theparse
static method.Bracket::parseString()
method previously returnedfalse
if a string was not provided for parsing, or the string was empty after trimming. Since the signature calls for a string, we won't check for this anymore. If the string is empty, an empty string will be returned.markdown.beforeParse
event in theMarkdown
class sent a singleMarkdownData
instance as a parameter to the listeners. It now sends an array with theMarkdownData
instance as the only value, to meet the signature requirements for events.Syntax\FieldParser
class constructor has been madefinal
to prevent unsafe static calls to theparse
statuc method.$template
parameter for theSyntax\FieldParser
class constructor was originally optional. Since there is no purpose for this, and no way to populate the template after the fact, this has been made required.Syntax\Parser
class constructor has been madefinal
to prevent unsafe static calss to theparse
static method.$template
parameter for theSyntax\Parser
class constructor was originally optional. Since there is no purpose for this, and no way to populate the template after the fact, this has been made required.Testing
Winter\Storm\Support\Testing\Fakes\MailFake::queue()
method has had its signature re-arranged to remain compatible with Laravel'sMailFake
class, with the$queue
parameter being moved to the second parameter. The new signature is($view, $queue, $data, $callback)
.