
Originally Posted by
DrByte
I'm assuming that SBA is passing the extra $attributes parameter? But if the function doesn't declare that parameter in its function signature, the function won't do anything with it (hence I guess why you're trying to do backflips to read it?).
And newer PHP versions will soon begin actively rejecting the function call if it doesn't match the signature.
Perhaps there's an opportunity to improve core code.
By no means shying away from the opportunity to improve core code, I haven't found anything that suggests that the following will become a problem. Perhaps I don't have all of the tea leaves though:
Code:
function thisFunction($param1) {
// Evaluate parameters provided, if there are extra parameters, then do something with them.
// This evaluation and additional action could be before, after or during the normal action on $param1.
// Do something with $param1
}
$data = 'Data';
$extra_parameter = 'use also';
thisFunction($data, $extra_parameter);
Where even if some sort of data type is forced for $param1 that if the original/expected data type is provided then it seems from my review of php requirements that the call to the function will still be accepted. What I have seen is issues that could occur based on some of the php 8 chosen directions and more specifically on the use or potential use of optional values within the original function (if not accounted for properly downstream), Variable Arguments or possibly use of Named Arguments. My thought though in this particular code section is that the use/operation is so "limited" that changes made to the parameters of the functions would be relatively easy to see/address with the code being changed/updated as necessary to interface properly with the core code.
That all said, the follow on question to address potential core code is where such modification may be best considered... The function as a class method, additional data collected/passed in the function call, the observer class making more information available about the code surrounding the notifier (parameters of the call to the outer function?)?
In part it seems that a lot of the data possibly to be sent could be captured within the associated orders/cart classes. My issue is/was that I wanted to have the exact information that is being attempted to be used not what was at some point determined. In other words potentially the current data from the associated object, or in the case of wanting to "test" the ability to take an action the value(s) being tested... At the same time I wanted to try to use as much of the default/core code as possible rather than generating alternative code. This would appear to make it easier to make changes that apply across the board rather than having to possibly make the same change in multiple places. Further, where might be a good place to further capture this discussion? I'm aware that changes made will likely impact many.
As for use of the hashed attribute information, pretty much all is well and good when looking at possibly generating/regenerating the possible hash value from the known attribute(s) assigned to a product except when text/a file is involved... The hash is specifically modified by the content of the associated text so it is not feasible to "guess" the hash from the possible attributes when either of those two attribute types are present. The only thing that could be done at that point is to capture/borrow the associated text from the applicable order/cart object and relate it to the associated file/text so that the potential hash values could be generated by sequencing/resequencing them in a mash up to see if the provided/identified hash is feasible within the variants assigned within SBA...
Anyways, although I saw this a good number of hours ago, I wanted to at least provide my feedback on what looks like a "scare" to upcoming coding standards... I'm thinking in my limited view that in relation to the function signature that there may have been a little extra concern than what currently is described as proposed...
I got a lot of the above from: https://www.php.net/manual/en/functions.arguments.php
Bookmarks