-
Notifications
You must be signed in to change notification settings - Fork 185
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
Update parameter and property types for version 2 #76
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.
At what point can we get rid of the redundant @param
and @return
docs? Having both types and doc'd types means there is a higher chance that the two will get out of sync and cause confusion.
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.
Can we remove docblock types as part of this PR?
As the docblock types are directly in the spec, I'd say no. We didn't on the other type updates for other specs, IIRC. I totally get the argument that they're redundant at this point, but it's not like the file is going to change often enough for them to get out of sync. |
I agree with @Crell for the PHPDoc. Also, we could enforce correctness by introducing a static check with Psalm or PHPStan if we want, now! Since we're ditching the test classes, do we want to split them into an |
If someone wants those test classes to still exist, a |
Inquiry. As long as we're doing this, should we also restructure the package to use PSR-4 instead of rooted PSR-0? I'm leaning toward yes. |
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.
Looks good to me, thanks @Crell for getting it done. However one question remains for me: What's the point of having a 2.0 and 3.0 if both anyway require PHP 8? Does it really provide a better upgrade path for libraries? I guess only implementers already requiring PHP 8 would benefit, which is probably not a lot, if any.
Anyway I'm fine still merging as is to keep it by the book.
As for test classes yes it would be good to keep them IMO so implementers can verify they adhere to the spec. @Jean85 please create it, I'd say it's not so urgent as I doubt anyone can upgrade to v2 here any time soon due to the PHP 8 req, but if nobody else does it I'll eventually get the test classes back in that util lib so I can upgrade monolog to it. |
that's fine to me. The behavior of AbstractLogger is still the same, even if it uses the trait to implement it internally. The usage of the trait is an implementation detail here.
It allows implementers to support |
Yeah we should IMHO. Since we're requiring such a newer PHP version, requiring PSR-4 should be so harsh on end users. |
Switched to an |
Repo created: https://github.com/php-fig/log-util @XedinUnknown you expressed interest with #75, are you willing to submit a PR there porting the classes? I'm up for reviewing and improving that if you want. |
@Jean85, absolutely. I'll let you know shortly, probably going to work on this over the weekend. One thing, though. I don't actually have PHP installed on my host machine, because I work with Docker, and this is where all dev things reside - like in https://github.com/Dhii/php-project. I also add tests for interfaces to make sure that implementations can actually be instantiated. Would you accept also a Docker setup, static analysis tools, maybe a PHPStorm config as well in the repo? |
@XedinUnknown no I don't think it would belong there. I was thinking about putting up Github actions as CI (separate PR maybe?), but other stuff would be too specific IMHO. |
Ok. I also use GH Actions. What would it do though, if there aren't any tools? |
This way, we can version the package against the moving target of PHPUnit versions. |
Ok, so I guess it's mostly about proving that deps are installable, than proving that the code works, in this case. I kinda do something similar in #75. 👍 |
If I may suggest something, since this is going to be a BC-breaking release anyway. At the same time, it could require a A standard is a standard, and IMO it should exist separately from any implemenatation, since implementation is about the "how", and a standard is not. Therefore, from that perspective, perhaps it could make sense to:
I absolutely do not mean to annoy anyone by the above, and if I didn't manage to avoid that, then I take it back, and please let's pretend I never wrote it 😅. |
This begins porting as per php-fig/log#76 (comment)
Independent of the value of any of the suggestions above, I think most of them would be breaking changes requiring a new PSR anyway. So these responses are largely academic.
In general, yeah, not bad ideas, but they'd all require a new PSR given the level of change they are. The whole point of the type additions is that, thanks to variance rules, the two-step process allows us to not actually have any hard breaks. There's always an overlap that allows people to upgrade gradually. |
Switching to an interface does not make sense IMO. This LogLevel class is semantically an enum (but requiring PHP 8.1 to make it an actual enum is too bleeding edge for now) |
@stof, I agree with that. My only problem is that classes are implementation, while enums are actual contracts (even if not formally an interface perhaps). |
@Crell, thanks for the detailed response, much appreciated!
The thing is, nothing right now seems to declare If such breaking changes are not possible (although I thought they are, as long as there is a gradual upgrade path), then perhaps changing the
This way, implementors and consumers should know that any subtype of In addition to that, no other method except That dependency on concretion is furthered by any consumers of |
@XedinUnknown if psr/log was created in the PHP 8.1+ era, LogLevel would be an enum. But it must live with its requirements, and so use an implementation that works on existing PHP versions. This means using a class with constants. |
@stof, yes, of course I understand that. My suggestion was to make it an interface, with the same class constants, etc. Regarding |
Class has been removed in php-fig/log#76.
|
We split that away into https://github.com/php-fig/log-util so it would make it easier to handle PHPUnit upgrades and the like. |
But there is not relation to phpunit at all. I don't understand |
I'm sorry, I made a mistake and read it wrongly, I was thinking about the TestCase. @Crell any reason? |
The psr package should include those symbols defined in the PSR; no more, no less. Putting anything else in this package in the first place was a mistake. (Honestly the traits and abstract classes here are also a mistake and should have been in a util package rather than the spec itself, but this was before we did util packages.) Anything not listed in the spec itself belongs in a util package, regardless of whether it relates to testing. I fully agree that a mock logger for testing is something the util package should have. |
As per the upgrade bylaw.
string|Stringable
, so this requires PHP 8.0.AbstractLogger
andLoggerTrait
together, since they're identical and there's no reason to support PHP 5.3 anymore. I am not certain if this should be considered kosher sinceAbstractLogger
is specified in the spec. It's in its own commit so easy to undo if we decide to.