even worse, var_dump(+INF!=+INF); //false - like they're exact values (physically, they are, INF is just a bit, which is set in float numeric - but from math sense it's crap)
the problem is in "leaky abstractions". So we let physical structure to influence on logical result. I think math behavior would be much clearer (example, NULL for DBMS which is truly non-comparable)
well, I know why it's so (even without looking into PHP source) - since PHP will use some standard way to compare floats, no matter what they are (inf or nan or regular values)
public function TestController {
function __construct(Request $request, ServiceFactory $serviceFactory) {
//copy the params to internal
}
public function indexAction() {
$value = $request->getValue('foo');
$service = $serviceFactory->create($value); // $value is decided right here in this controller method
}
}
The scalar value comes from the request, but in order to keep this "service", or library separate from the application, typehinting for a Request object in it is out of the question
@Danack in this context, a "Service" is a component that is holistically responsible for a single ability or behavior of your app, it sits in the model layer.
It could be from the result of an API call, but I don't want the API to be anything to do with my library, so I'm not typehinting for the api object in my thing. They're just separate
So the point is, I'm trying to use Auryn DiC to typehint for the MyObject with the above constructor
Of course, the $userSuppliedValue which is retrieved from elsewhere doesn't exist on automatic object instantiation
Hence, a factory is required, but all it's doing really is passing through variables
I have a query that i want to pick employee pin no,Employees SurName,Basic_Pay,House_Allowance and transport where the payrollcode matches code say 'P137' for our example.
Select distinct Employees.PINNo,
Employees.SurName + ' ' + Employees.OtherNames,
tblEmploye...
@SecondRikudo You mean you need to have some code that knows about the request object, extract the var from it and is then able to pass that param into the constructor of the object that requires it?
I have a directory Clients containing two other directories for torrent downloads: Transmission, Azureus or whatever the latest clients are called. Depending on a value provided by a user in their 'dashboard', let's say they provide Transmission in a form - the DiC will use this as a directory path before going through the common interfaces to get the data from the respective torrent client
@SecondRikudo (this is for you and the above post :P) Of course it's all secure and only one of the two can be provided, maybe a dropdown etc, but it's possible. Polymorphism via a user-defined variable, client-side, with all the validation etc of course
Router is the one that deals with strings on the one end, on the other end, there's the smallest parts of the Model, and then eventually, obviously the Model selecting templates.
@Jimbo Yes. I need to get my arse into gear and finish up a massive PR I have outstanding for Auryn, to split the huge and fugly provider class into the actual injector and plugins that store information about what should be instantiated where.
Doing the delegateParam stuff would be trivial once that is done.....so I ought to get that done.
@Danack Please do, I've given three talks now and they've involved the awesomeness that Auryn can provide - so hopefully it should steadily be gaining interest
I can't see any real reason not to support delegateParam() or more likely delegateScalar() - although they are close to (effectively) being global variables it sounds rather useful.
Out of interest - can people tell me downsides of using an autowiring dic like Auryn? I haven't seen any. The reflection issue is a non-issue as the reflections are cached. I thought that in a massive application it might cause problems but someone said it would make it easier. Are there any downsides?
@Fabien Meh, it's better than trying to remember all of the passwords yourself, and sure as hell better than using the same 3 passwords for everything.
Hello, I am half-way through writing a question about class design, but I'm worried it's a duplicate and was hoping I could get some advice here. Basically I'm sure this question will have been asked before, but I don't know the correct terms to search this question out.
Thanks :) I'm trying to figure out the best way of implementing meta-data in classes, e.g. class CarPart has property weight, but I want to specify that weight is a required value, has a maximum allowable value, must be a float value, will accept values to two decimal places, etc. Is there a term to describe this?
@LeviMorrison Apart from the obvious, 'no-one wants to touch it' do you know of any reason why someone hasn't added a bind_param replacement that doesn't use references?
in a way I agree with @ircmaxell's concept: there's no pure OOP. It's always somwehere in the middle (after all, no matter how many abstraction layers do you have - you'll have to start from somewhere, so entering point will be "procedural" part at least)
@Jimbo thank you very much for your help :) I take it that something like that is generally considered 'good practice'? (i.e. are there any hidden pitfalls to look out for/plan for?)