-
Notifications
You must be signed in to change notification settings - Fork 187
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
Split assertions to traits #223
base: master
Are you sure you want to change the base?
Conversation
The docblocks for the traits should not contain the |
This will also be a major version upgrade due to a drop in support of PHP 5.3. |
Yes, but that's poor maintainability. I defined abstract __callStatic method in traits and I hold to leave magic docblocks with code. |
If the trait docblock is going to retain the I would still say that they shouldn't be present at all, but if they are, they need to be auto generated to reduce the maintenance overhead. |
Oh, I didn't realize they are generated by script. Ok, it would be simplier to bring them back to Assertion class. |
@rquadling moved them back and removed abstract method. |
Nice. Can the 1xxxx = Type related (11xx Array, 12xx Boolean, etc.) |
Traits can't have constants.
…On Apr 18, 2017 21:33, "Richard Quadling" ***@***.***> wrote:
Nice.
Can the const's be moved too? I'd go with a renumbering also so use a
value that is composed to represent the some logical grouping.
1xxxx = Type related (11xx Array, 12xx Boolean, etc.)
2xxxx = Class related (property, method, etc).
etc.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#223 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATGF3Aj4wjPu5sk8k2T9kS8_nYU2UoSks5rxJ-fgaJpZM4M-_cj>
.
|
Ah. Yes. Odd that PHP can have static members, and properties, but not constants. We should have all the things in all the places. So. Things look good. Dropping support for PHP < 5.4 is fine by me. I've no intention of really supporting something that EOL'd just for the sake of it. |
I think I'd like the traits in their own sub-directory of Assert. That way the traits are a subordinate of the Assertion class. |
Ok I moved traits to namespace Assert\Assertion. namespace Assert\Assertion;
const INVALID_SUBCLASS_OF = 29;
const INVALID_CLASS = 105;
const INVALID_INTERFACE = 106;
const INTERFACE_NOT_IMPLEMENTED = 202;
trait ClassTrait
{
} Then we can use them in trait as follows: And in other classes: |
I like the idea of the traits having their constants locally. Go with the renumbering also. Maybe if you can draw up the renumbering to first. I can review that prior to committing. Good work so far! |
Moving constants out from |
This is going to be a major release as we are dropping support for PHP 5.3. But namespaced constants vs class constants ... hmmmm. I'm happy with the BC. An To maintain BC, pulling the namespaced constants into the Assertion class is also a possibility for 3.0 and then drop them in 4.0. That can be done using a fairly simple update to the doc generator or probably better to rename the doc generator to something more generic (updating the |
bump required php version remove php 5.3 travis add abstract __callStatic move docblocks back move traits to namespace wip const links generator add upgrade notes split assertions to traits bump required php version add abstract __callStatic remove php 5.3 travis move docblocks back move traits to namespace
Had some merge/force push bug, now all is fixed. |
Any chance the scalar assertion could move to its own trait? That way all the assertions are in traits. MAYBE, a scalar trait uses the boolean, string, number, etc. traits? I'm really liking the segmentation. Good work!!! |
Renumbering the constants would be a nice touch. |
OK, I moved Also for renumbering: I'm not sure how to do that best, so I leave it for somebody else. |
The unit tests need to have the corrected class constant. You should be able to use the regular expression |
Can you also update the UPGRADE_3.0.md doc to use that regex as the one you have will replace all the static calls also. |
Also, take a read of https://thephp.cc/news/2016/02/questioning-phpunit-best-practices regarding the unit tests. |
Done. |
Care to split the unit tests into 1 file per trait? |
Done. |
Excellent!!! Final review tomorrow!! Hopefully. |
/** | ||
* @covers \Assert\Assertion\ArrayTrait | ||
*/ | ||
class ArrayTraitTest extends \PHPUnit_Framework_TestCase |
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.
Please use PHPUnit\Framework\TestCase
instead of PHPUnit_Framework_TestCase
as #238
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.
@carusogabriel I have no time for this. You are free to open PR against my fork.
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.
Gonna do it so 👍
Yes, I changed it.
15 дек. 2017 г. 3:30 ДП пользователь "Richard Quadling" <
notifications@github.com> написал:
*@rquadling* commented on this pull request.
------------------------------
In CONTRIBUTING.md
<#223 (comment)>:
@@ -4,6 +4,5 @@ Thanks for contributing to assert! Just follow these single guidelines:
- You must use [feature / topic
branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows)
to ease the merge of contributions.
- Coding standard compliance must be ensured before committing or
opening pull requests by running `composer assert:cs-fix` or `composer
assert:cs-lint` in the root directory of this repository.
-- After adding new assertions regenerate the [README.md](README.md)
and the docblocks by running `composer assert:generate-docs` on the
command line.
+- After adding new assertions regenerate the [README.md](README.md)
and the docblocks by running `composer assert:generate` on the command
line.
It is composer assert:generate-docs, unless you've changed it in this
branch.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#223 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AATGF1F_7e96PozXGpFZY_nOlV4vpgtaks5tAVsXgaJpZM4M-_cj>
.
|
@carusogabriel you broke the tests 🤔 see https://travis-ci.org/beberlei/assert/builds/316258002?utm_source=github_status&utm_medium=notification for details. |
/** | ||
* @covers \Assert\Assertion\CallableTrait | ||
*/ | ||
class CallableTraitTest extends TestCase |
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.
@b1rdex Forget to use PHPUnit\Framework\TestCase
here. I'm sorry
/** | ||
* @covers \Assert\Assertion\ClassTrait | ||
*/ | ||
class ClassTraitTest extends TestCase |
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.
@b1rdex Forget to use PHPUnit\Framework\TestCase
here. I'm sorry
/** | ||
* @covers \Assert\Assertion\CompareTrait | ||
*/ | ||
class CompareTraitTest extends TestCase |
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.
@b1rdex Forget to use PHPUnit\Framework\TestCase
here. I'm sorry
No description provided.