2012-10-30 16 views
5

Więc mam tej klasy:deklaracja Metoda jest kompatybilny ale PHP narzeka

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){} 
} 

i to jest SplObjectStorage:

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

Jak widać są one identyczne, ale kiedy instancję JSObjectSTorage , Pojawia się następujący błąd:

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

Tak dzieje się w przypadku removeAll() i removeAllExcept().

Jakieś pomysły ?!


Używam:

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 
+2

Jakiej wersji PHP używasz? Po prostu próbowałem z 5.4.8 i twój kod działa dobrze. – Roberto

+1

Czy na pewno tak się nie dzieje również w przypadku metody 'removeAll()'? Jeśli tak, to podejrzewam, że podpowiedź typu, ponieważ mogą to być parametry - może niekompatybilność z wersją PHP, nie jest jednak pewna. – inhan

+0

@inhan Tak, jak podałem w pytaniu, to również dzieje się przy removeAll() i removeAllExcept(). Usunięcie wskazówki dotyczącej typu nie rozwiązuje problemu. – Tivie

Odpowiedz

Powiązane problemy