-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Added support for Laravel 7 custom casts #913
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just had one problem with this: if return type of
get
metod is not defined, but it has@returns
tag, then returned type is not namespaced properly. i couldn't find a way to provide necessary context toDocBlock
object. if anyone knows how to do it, that would be really cool to implement
The whole library has this limitations on get*Attribute
methods so IMHO nothing which needs to be fixed specifically for this feature (but sure, a general solution would be "nice").
I like the PR, implementation LGTM and 👍 for tests!!
|
||
$this->assertSame(0, $tester->getStatusCode()); | ||
$this->assertEmpty($tester->getDisplay()); | ||
//dd($actualContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug stuff 💥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix
|
||
if (version_compare(Application::VERSION, '7.0', '<')) { | ||
$this->markTestSkipped('This test requires Laravel 7.0 or higher'); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, markTestSkipped
works through exception bubbling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found it only in AbstractModelsCommand
but it checks for 6 version
if (version_compare(Application::VERSION, '6.0', '<')) {
$this->markTestSkipped('This test requires Laravel 6.0 or higher');
return;
}
are you sure i can safely remove it? where is this exception debugging you are talking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markTestSkipped
throws a special exception recognized by PHPUnit, that's why a return (read: code afterwards) doesn't execute => https://github.com/sebastianbergmann/phpunit/blob/cb6b2d8cb5865b9576adcd9c595a8b4d005361b3/src/Framework/Assert.php#L2645-L2655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but to be honest, i cant see why i can drop this code
parent class check for 6 version, but my test should run only in 7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can/should be removed in the parent as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but i don't follow why
travis runs test on multiple laravel versions, how else this test would be skipped without this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, you talking only about line 20, we can remove return statement, agreed, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly; apologies for being not more specific upfront!
refactored tests and added some additional test cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing more to add, awesome; hope @barryvdh soon finds time for this!
Thanks! Unfortunately this has merge conflicts. Would it be possible to fix those, then I'll merge this. |
done, replaced my code with @mfn's |
Thanks! |
this pr adresses #904
the idea of improvement is simple:
now we get cast object as property's return type
we just check if this cast object implements laravel's
Illuminate\Contracts\Database\Eloquent\CastsAttributes
interface and if so then we return it'sget
method return typejust had one problem with this: if return type of
get
metod is not defined, but it has@returns
tag, then returned type is not namespaced properly. i couldn't find a way to provide necessary context toDocBlock
object. if anyone knows how to do it, that would be really cool to implement