I am using the etrade api which is built upon a lot of classes that call a lot of the functions statically. Hence if I change it to "public static function" I will just keep getting these errors. Here is the full error message:
Non-static method RequestParamsMain::buildFullURL() should not be called statically, assuming $this from incompatible context in /home/detroitclicks/public_html/etrade/Market/MarketClient.class.php on line 72
Here is the code to that function under the class Market. The class RequestParamsMain is in a separate php file that is included in this file:
public function productLookup($param_obj)
{
self::validateParamObj($param_obj,false);
$resourceURL = RequestParamsMain::buildFullURL(URL_PRODUCTLOOKUP,null,$param_obj);
return $this->getMarketResponse($resourceURL);
}
here is the code I am trying to execute:
$request_params = new productLookupParams();
$request_params->__set('company', 'cisco'); // company = "cisco" for example
$request_params->__set('type', 'eq'); // type = equity for example
$out= $mc_obj->productLookup($request_params);
The problem in not in your code, rather in the API you are using, because it calls non-static methods (namely RequestParamsMain::buildFullURL
) statically. This kind of calling was allowed in older versions of PHP and did not generate a warning message, but it does in newer ones, like 5.4
You have several options to consider:
Look for an updated version of the 3rdparty software you are using. If you do not found one, throw it out the window, because it is a piece of garbage and its authors did not understand the concept of object oriented programming at all. I would suggest this option if there are alternatives.
Modify the source of the 3rdparty software you are using. I would not recommend this, because it can be a tedious work and it may not even fit with the licensing.
Update: If it is a single bug in the API, you may fix it, by examining whether the RequestParamsMain::buildFullURL
is used completely statically and if yes, make it a static method. If it is really not a static method, make the call non-static by creating an object from the RequestParamsMain
class, e.g.:
$request = new RequestParamsMain(/* arguments */);
$resourceURL = $request->buildFullURL(URL_PRODUCTLOOKUP,null,$param_obj);
However, if there are multiple issues, I would really not recommend to go over all of them, because it can easily be a huge amount of work and a new version for the software may easily out-wipe your results. Anyway, a bug report towards the developers can be useful in all cases.
Turn of strict warnings to hide these error messages. Of course it is not a real solution, just a workaround. E.g.:
error_reporting(E_ALL ^ E_STRICT);