« first day (4900 days earlier)      last day (53 days later) » 

12:58 PM
I wish there was a cleaner way to extend a __construct in a inherited class without importing the trillion upstream dependencies
I'm using DI, that's why my constructors have so many dependencies on some parts of the code, like REST API endpoints, I have an abstract REST API endpoint class with dependencies like auth, logging, etc, and whenever I need a new dependency in a concrete instance I need to explicitly re-import everything and call parent::__construct() with all the dependencies...
I also have sub-types of endpoints, like "abstract class UploadEndpoint", that a few concrete REST API endpoints that handle upload extend, and the upload endpoint has things like ZipValidator, so when I need to inject a new dependency in a concrete class of UploadEndpoint, the constructor gets very verbose
my alternative is using the DI as a service locator... not seeing too much hope there
On one hand, it's nice because it's exposing the relationships, on the other, I just want to add a new dependency without adding 15 lines of upstream code to my class
abstract class ParentClass {
    public function __construct(protected Dep1 $dep1, protected Dep2 $dep2) {}
}

class ChildClass extends ParentClass {
    public function __construct_extend(protected Dep3 $additionalDep) {
    }
}
$child = new ChildClass(new Dep1(), new Dep2(), new Dep3());
 
1:42 PM
@LucasBustamante The way I usually handle this if I expect to repeatedly extend it is to bundle the dependencies into a parent class and then inject that instead
 
 
3 hours later…
5:06 PM
Or not have a base class for the controllers at all. Single-method controllers make the DI stupid simple, and you can just toss the dependencies you need into the constructor, with promotion, and the DI Container sorts it out for you.
 
5:17 PM
They have their advantages but they're also a PITA when you've got a thousand of them
We built our own middleware stack that, amongst other things, allows injecting services at method level using a #[UseService] attribute, although it certainly ends up with a lot more boilerplate args and using private helper functions with their own services is no-go
 
 
5 hours later…
10:16 PM
TIL that mmap() can create mappings on NULL with MAP_FIXED. Sadly find_preferred_mmap_base may return NULL … and checks against the returned pointer … end up failing because NULL. ugh.
 

« first day (4900 days earlier)      last day (53 days later) »