Non-static method ..... should not be called statically
That means it should be called like:
$timer = (new VTimer)->get($options['magic']);
The difference between static
and non-static
is that the first one doesn't need instantiation so you can call the classname
then append ::
to it and call the method immediately.
Like so:
ClassName::method();
and if the method is not static you need to initialize it like so:
$var = new ClassName();
$var->method();
However, in PHP >=5.4 you can use this syntax instead as a shorthand:
(new ClassName)->method();
Error message Strict standards: Non-static method should not be called statically in php
Your methods are missing the static
keyword. Change
function getInstanceByName($name=''){
to
public static function getInstanceByName($name=''){
if you want to call them statically.
Note that static methods (and Singletons) are death to testability.
Also note that you are doing way too much work in the constructor, especially all that querying shouldn't be in there. All your constructor is supposed to do is set the object into a valid state. If you have to have data from outside the class to do that consider injecting it instead of pulling it. Also note that constructors cannot return anything. They will always return void so all these return false
statements do nothing but end the construction.
Strict Standards: Non-static method should not be called statically, assuming $this from incompatible context
Just change your method type, add the static
keyword and call as you are doing now.
public function getMapper() {
if (null === self::$__mapper)
{
self::setMapper(new Vox_Model_Setting_Mapper());
}
return self::$__mapper;
}
to
public static function getMapper() { # see extra static keyword
if (null === self::$__mapper)
{
self::setMapper(new Vox_Model_Setting_Mapper());
}
return self::$__mapper;
}
Strict Standards: Non-static method DatabaseConnection::getConnection() should not be called statically in
The message is telling you that DatabaseConnection->getConnection();
is not a static method.
The difference is that static methods are called on a class and using the ::
operator. Non-static methods (instance methods), are called on an instance of the class and using the ->
operator.
PHP allowed non-static methods to be called in a static way, as long as they don't use any instance properties. With error reporting set to strict, it will throw this error though.
To solve it, either create a DatabaseConnection
instance to call the method on, or change its declaration to static
if it should be a static method.
You can also make error reporting less strict, but that's the wrong way to solve it in my book,
Strict Standards: Non-static method modJumiHelper::getCodeWritten() should not be called statically
This error is caused because the functions getCodeWritten and getStorageSource are not static functions.
i.e.
Instead of being declared like so:
public static function getCodeWritten()
They are being declared like this:
public function getCodeWritten()
Be warned that "fixing" this might cause other issues. Your best bet is to contact the people who created the extension.
Strict Standards: Non-static method STemplate::assign() should not be called statically
It's because you're using a modern version of PHP with strict standards
. You may be able to make the code work by making the declaration:
public static function assign($var, $value)
However judging by the other errors you'll run into many problems. You can try disabling strict standards but it'd be best to upgrade to a modern version of Smarty
.
Strict Standards: Non-static method StreamComment::getCommentsHTML() should not be called statically, assuming $this from incompatible context
What's happened here is that this function has been called statically:
StreamComment::showall(); // Static Call
But it's defined as a non-static method, which means PHP is expecting it to be called like this:
$obj = new StreamComment();
$obj->showall(); // Dynamic Call
If this is the only place this method is called, or it's consistently called statically, you can fix this by redefining the method as static:
public static function showall() // Added the "static" keyword
{
// [..code..]
}
Hope this helps :) x
Related Topics
Facebook Graph API, How to Get Users Email
How to Add a PHP Page to Wordpress
Is Possible to Keep Session Even After the Browser Is Closed
How to Show Ajax Requests in Url
PHP Fatal Error: Call to Undefined Function Mssql_Connect()
How to Pass Variable Number of Arguments to a PHP Function
What Does "1" Mean At the End of a PHP Print_R Statement
Can You Get a Windows (Ad) Username in PHP
How We Can Add Two Date Intervals in PHP
Fastest Way to Serve a File Using PHP
PHP Class Instantiation. to Use or Not to Use the Parentheses
PHP Script to Loop Through All of the Files in a Directory
Check If a User/Guest Has Purchased Specific Products in Woocommerce
Paypal Access - Ssl Certificate: Unable to Get Local Issuer Certificate
PHP: Utilizing Exit(); or Die(); After Header("Location: ");