Below is a complete list of the possible E_STRICT
error messages in PHP 5.6 and bundled extensions (derived from http://lxr.php.net/s?refs=E_STRICT&project=PHP_5_6), along with a brief code sample that will provoke them.
In PHP 5.5, calling any mysql_*
function would also produce an E_STRICT
, as of PHP 5.6 it produces an E_NOTICE
.
There are likely other places that emit them in PECL extensions, feel free to edit them in here if you find one.
Accessing static property ClassName::$propName as non static
class ClassName
{
public static $propName = 1;
}
$o = new ClassName;
echo $o->propName; // error here
Resource ID#1 used as offset, casting to integer (1)
$fp = fopen('file.txt', 'r');
$array[$fp] = 'something'; // error here
// it's worth noting that an explicit cast to int has the same effect with no error:
$array[(int)$fp] = 'something'; //works
Non-static method ClassName::methodName() should not be called statically (may include additional text: assuming $this from compatible context OtherClassName)
class ClassName
{
public function methodName()
{
return 1;
}
}
echo ClassName::methodName(); // error here
Only variables should be assigned by reference
function func()
{
return 1;
}
$var = &func(); // error here
Only variables should be passed by reference
function func(&$arg)
{
$arg = 1;
}
function func2()
{
return 0;
}
func(func2()); // error here
Static function ClassName::methodName() should not be abstract
abstract class ClassName
{
abstract public static function methodName(); // error here
}
class OtherClassName extends ClassName
{
public static function methodName()
{
return 1;
}
}
Redefining already defined constructor for class ClassName
// Emitted when both a PHP4-style and PHP5-style constructor are declared in a class
class ClassName
{
public function ClassName($arg)
{
}
public function __construct($arg) // error here
{
}
}
Declaration of ClassName::methodName() should be compatible with OtherClassName::methodName()
// Emitted when a class declaration violates the Liskov Substitution Principle
// http://en.wikipedia.org/wiki/Liskov_substitution_principle
class OtherClassName
{
public function methodName()
{
return 1;
}
}
class ClassName extends OtherClassName
{
public function methodName($arg) // error here
{
return $arg + 1;
}
}
You should be using the time() function instead
// Emitted when calling mktime() with no arguments
$time = mktime(); // error here
Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars
// Emitted when using a multi-byte character set that is not UTF-8 with
// htmlentities and some related functions
echo htmlentities("<Stuff>", ENT_COMPAT | ENT_HTML401, '936'); // error here
There is no next result set. Please, call mysqli_stmt_more_results()/mysqli_stmt::more_results() to check whether to call this function/method
// Emitted by mysqli_next_result() when there are no more results
do {
// stuff
} while (mysqli_next_result($link)); // error here