jamInTheValleys Posted November 11, 2010 Share Posted November 11, 2010 Hello, If I have an index file with: date_default_timezone_set('GMT'); error_reporting(E_ALL | E_STRICT); abstract class A { abstract public static function YesIReallyMeanAbstractStatic(); } class B extends A { public static function YesIReallyMeanAbstractStatic() { } } This will not error. However if I have: date_default_timezone_set('GMT'); error_reporting(E_ALL | E_STRICT); require('class_a_in_a_different_file.php'); // Or use __autoload() to do the same. class B extends A { public static function YesIReallyMeanAbstractStatic() { } } This will throw the error: "Static function A::YesIReallyMeanAbstractStatic() should not be abstract" I know abstract statics are debatable... but it makes no sense to me for it to be allowed in the first example but disallowed in other. So I was wondering if this is a bug? Or is there something else going on here? I assume the parser is evaluating the included file and then throwing the error which doesn't happen if both classes are in the same file as they can then be evaluated altogether. Quote Link to comment https://forums.phpfreaks.com/topic/218408-abstarct-static-inconsistent-error-handling/ Share on other sites More sharing options...
jamInTheValleys Posted November 12, 2010 Author Share Posted November 12, 2010 If nobody has any thoughts then I guess I'll file a bug report. Quote Link to comment https://forums.phpfreaks.com/topic/218408-abstarct-static-inconsistent-error-handling/#findComment-1133406 Share on other sites More sharing options...
jamInTheValleys Posted November 12, 2010 Author Share Posted November 12, 2010 In the first example the error_reporting isn't set until after the evaluation of the file. In the second example the error reporting is set by the first file and then the second file is evaluated, throwing the E_STRICT error. Quote Link to comment https://forums.phpfreaks.com/topic/218408-abstarct-static-inconsistent-error-handling/#findComment-1133439 Share on other sites More sharing options...
ManiacDan Posted November 12, 2010 Share Posted November 12, 2010 Right, the parser is what throws the error, and the first document is fully parsed without the strict warning being thrown before it's executed and the error level is properly set. Setting the error level in php.ini will "fix" this strange behavior. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/218408-abstarct-static-inconsistent-error-handling/#findComment-1133444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.