-
Notifications
You must be signed in to change notification settings - Fork 2
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
Stricter Typesystem #25
Comments
Hey @Jubeki, First of all, thanks for your offer to help out. Really appreciated! While I'm personally not a huge fan of the With that said, let me just ramble out a few thoughts / considerations that I've had on the past, so that you can see/have an idea of why certain decisions were made and how they influenced the current code. Feel free to disagree / change my mind on these, especially if there's a compelling argument (like the strict types one you mentioned). Anyway, here goes: First and foremost, it was important to me that the package provided a fully customizable experience. The idea was that by having controllers published into the user's app, and those controllers only exposing intended-to-be-overwritten methods, the user "inherits" full control over the library. For example, if they decide they want to add magic links or remove the Google Authenticator TOTP method, they can override certain package-internal methods, and change this "core" behaviour. Another example is if the user decides to use a model other than the Now, this will obviously bring significant risk, as there's a good chance of breakage, and that's where the tests come in: By having the tests written as traits that eventually all end up being included in the It's through this exact system, that security updates to the library itself bring "automatic" fixes to the user's authentication system: Since the tests are mostly traits included from the library, and both the "base" controllers in the library AND those tests are updated as part of the same release, their tests will keep passing, unless they've customized something & breakage occurs. Those are more or less the pillars that I built on when developing this package. With that said, my understanding is that by having strict types in the base controllers/core, or even in some places strict method attributes, it limits what the user can overwrite. For example, if I'd strictly hint Finally, for some last thoughts, and this is mostly unrelated, but just to explain what my current goals are (in order of planning): While the library is overall in a good shape (especially after this monorepo merge), there's still a few bugs / issues / limits that I'd like to address (in order):
Once these are done, my plan was to pick up and work on more adapter packages (e.g. the Inertia one), and see what problems we'll run into then. If that works out fairly smoothly, then that's a good sign that the library is in a good shape for 1.0, and if not then we clearly have to do some more tweaking but at least we'll have an idea of what needs tweaking. Anyway, that's pretty much the picture I have in my head regarding the library, feel free to ask if I missed something or if something's unclear (I am on Telegram as well if that's easier). In either case, I'm totally OK with the types being stricter, as long as we can kind of meet these thoughts/goals. Especially if we can only limit the I also think it makes sense to do a small PoC first with one controller or so, to kind of see/explore how it works in practice, and at that point if we decide it's a good direction I'm completely OK if you go all-out with it. Might just be easier to do smaller PR's anyway at that point, as to not end up with merge conflicts if we're both changing the same files. Let me know what you think! |
Thank you for all the plans you shared. Then I would say we leave the stricter type system open for now. (Maybe use larastan on level 0 for now to already find smaller problems and then later on improve incrementally the type system.) For now I will take a look at the Custom Interface and the Tests. |
Sounds good. Adding Larastan also isn't a bad idea! |
Hey @claudiodekker,
I'd like to help a little bit with the package and thought about how I could contribute the best for now.
So I'd like to propose to use a stricter type system which would mean:
declare(strict_types=1)
at the top of all filesWhy is that change important in my opinion?
A stricter type system would mean catching more unexpected bugs / type conversions. There are a lot of cases were an integer is passed but a string is expected. Because for Authentication Security is an important aspect this should be an explicit instead of an implicit type conversion.
If you want I would work on these things in multiple smaller iterations so that it would be better to review:
declare(strict_types=1)
to all files (maybe 10 - 20 files per iteration) and fix the type conversionsWhat is your opinion on this?
(I could also work on this in one large PR, but this would make it quite hard to review)
The text was updated successfully, but these errors were encountered: