]> granicus.if.org Git - php/commitdiff
- Interfaces may have static methods to enforce their existance in
authorMarcus Boerger <helly@php.net>
Sun, 19 Feb 2006 11:55:11 +0000 (11:55 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 19 Feb 2006 11:55:11 +0000 (11:55 +0000)
  implementing classes

Zend/zend_API.c
Zend/zend_compile.c
tests/classes/abstract_static.phpt

index 2225079fb298bf04c13e3e1a6ff5213b1ccd02c2..77c593779911428d22f92709eb4b25d99685ba84 100644 (file)
@@ -2081,7 +2081,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
                                        scope->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
                                }
                        }
-                       if (ptr->flags & ZEND_ACC_STATIC) {
+                       if (ptr->flags & ZEND_ACC_STATIC && (!scope || (scope->ce_flags & ZEND_ACC_INTERFACE))) {
                                zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
                        }
                } else {
index 774455251f17e255f7536eb903da3d2fc16adecd..898bb9f7561a9cbbabcb80e871f5ab93b1f6d91c 100644 (file)
@@ -1108,7 +1108,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
        } else {
                fn_flags = 0;
        }
-       if ((fn_flags & ZEND_ACC_STATIC) && (fn_flags & ZEND_ACC_ABSTRACT)) {
+       if ((fn_flags & ZEND_ACC_STATIC) && (fn_flags & ZEND_ACC_ABSTRACT) && !(CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) {
                zend_error(E_COMPILE_ERROR, "Static function %v%s%R() cannot be abstract", is_method ? CG(active_class_entry)->name : "", is_method ? "::" : "", Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant));
        }
 
index 2e46e9dc06dce6ca7b4849f6a3139ca6f883c96f..01f358638bd4f884301bd357718d551dba5f4f95 100644 (file)
@@ -1,21 +1,29 @@
 --TEST--
-ZE2 A static abstrcat method may not be called
---SKIPIF--
-<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
+ZE2 A static abstrcat methods
 --FILE--
 <?php
 
-abstract class fail {
-       abstract static function show();
+interface showable
+{
+       static function show();
 }
 
-class pass extends fail {
+class pass implements showable
+{
        static function show() {
                echo "Call to function show()\n";
        }
 }
 
 pass::show();
+
+eval('
+class fail
+{
+       abstract static function func();
+}
+');
+
 fail::show();
 
 echo "Done\n"; // shouldn't be displayed
@@ -23,4 +31,4 @@ echo "Done\n"; // shouldn't be displayed
 --EXPECTF--
 Call to function show()
 
-Fatal error: Cannot call abstract method fail::show() in %s on line %d
+Fatal error: Static function fail::func() cannot be abstract in %s on line %d