加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

方法声明兼容,但PHP抱怨

发布时间:2020-05-25 09:09:17 所属栏目:PHP 来源:互联网
导读:所以我有这门课: class JSObjectStorage extends SplObjectStorage{ /**Adds a JavaScript object inside the storage, and optionally associate it to some data.*/ public function attach($javaScript,

所以我有这门课:

class JSObjectStorage extends SplObjectStorage
{

    /**Adds a JavaScript object inside the storage,and optionally associate it to some data.*/    
    public function attach($javaScript,$data = null){}

    /**Removes the object from the storage.*/
    public function detach($javaScript){}

    /**Adds all objects-data pairs from a different JavaScriptBundle storage in the current storage.*/
    public function addAll(SplObjectStorage $storage){}

    /**Removes objects contained in another storage from the current storage.*/
    public function removeAll(SplObjectStorage $storage){}

    /**Removes all objects except for those contained in another storage from the current storage.*/
    public function removeAllExcept(SplObjectStorage $storage){}

    /**Alias to JSObjectStorage::attach. */    
    public function offsetSet($javaScript,$data = null){}

    /**Alias to JSObjectStorage::detach*/
    public function offsetUnset($javaScript){}

    /**Returns the data associated with an object in the storage.*/
    public function offsetGet($javaScript){}

    /**This method calculates an identifier for the objects added to JSObjectStorage object.*/
    public function getHash($javaScript){}
}

这是SplObjectStorage:

http://php.net/manual/en/class.splobjectstorage.php

如您所见,它们是相同的,但是当我实例化JSObjectSTorage时,我收到以下错误:

Strict standards: Declaration of
MOWAFWCoreTypeJavaScriptJSObjectStorage::addAll() should be
compatible with that of SplObjectStorage::addAll() in
/Users/**/JSObjectStorage.php on line 175

这恰好是removeAll()和removeAllExcept().

有任何想法吗?!

我正在使用:

PHP 5.3.10 with Suhosin-Patch (cli) (built: Feb 20 2012 22:55:53) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0,Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.2,Copyright (c) 2002-2011,by Derick Rethans
有人发布了一个名为 “Namespace interfaces not working due to type hinting issues” (Bug #40653)的错误报告,尽管PHP版本不同,它看起来像你的情况(它读取v.< 5.3.7).

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读