[DomCrawler] fix deprecation triggers
The SplObjectStorage class performs calls to its own methods. These method calls must not lead to triggered deprecation notices.
This commit is contained in:
parent
1309cfbe9d
commit
aca6bd9bd6
@ -832,7 +832,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function attach($object, $data = null)
|
public function attach($object, $data = null)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::attach($object, $data);
|
parent::attach($object, $data);
|
||||||
}
|
}
|
||||||
@ -842,7 +842,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function detach($object)
|
public function detach($object)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::detach($object);
|
parent::detach($object);
|
||||||
}
|
}
|
||||||
@ -852,7 +852,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function contains($object)
|
public function contains($object)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
return parent::contains($object);
|
return parent::contains($object);
|
||||||
}
|
}
|
||||||
@ -862,7 +862,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function addAll($storage)
|
public function addAll($storage)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::addAll($storage);
|
parent::addAll($storage);
|
||||||
}
|
}
|
||||||
@ -872,7 +872,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function removeAll($storage)
|
public function removeAll($storage)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::removeAll($storage);
|
parent::removeAll($storage);
|
||||||
}
|
}
|
||||||
@ -882,7 +882,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function removeAllExcept($storage)
|
public function removeAllExcept($storage)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::removeAllExcept($storage);
|
parent::removeAllExcept($storage);
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function getInfo()
|
public function getInfo()
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
return parent::getInfo();
|
return parent::getInfo();
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function setInfo($data)
|
public function setInfo($data)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::setInfo($data);
|
parent::setInfo($data);
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function offsetExists($object)
|
public function offsetExists($object)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
return parent::offsetExists($object);
|
return parent::offsetExists($object);
|
||||||
}
|
}
|
||||||
@ -922,7 +922,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function offsetSet($object, $data = null)
|
public function offsetSet($object, $data = null)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::offsetSet($object, $data);
|
parent::offsetSet($object, $data);
|
||||||
}
|
}
|
||||||
@ -932,7 +932,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function offsetUnset($object)
|
public function offsetUnset($object)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
parent::offsetUnset($object);
|
parent::offsetUnset($object);
|
||||||
}
|
}
|
||||||
@ -942,7 +942,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function offsetGet($object)
|
public function offsetGet($object)
|
||||||
{
|
{
|
||||||
@trigger_error('The '.__METHOD__.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
$this->triggerDeprecation(__METHOD__);
|
||||||
|
|
||||||
return parent::offsetGet($object);
|
return parent::offsetGet($object);
|
||||||
}
|
}
|
||||||
@ -952,7 +952,7 @@ class Crawler extends \SplObjectStorage
|
|||||||
*/
|
*/
|
||||||
public function getHash($object)
|
public function getHash($object)
|
||||||
{
|
{
|
||||||
// Cannot trigger a deprecation warning here because SplObjectStorage calls this method when attaching an object.
|
$this->triggerDeprecation(__METHOD__, true);
|
||||||
|
|
||||||
return parent::getHash($object);
|
return parent::getHash($object);
|
||||||
}
|
}
|
||||||
@ -1155,4 +1155,23 @@ class Crawler extends \SplObjectStorage
|
|||||||
|
|
||||||
return $crawler;
|
return $crawler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function triggerDeprecation($methodName, $useTrace = false)
|
||||||
|
{
|
||||||
|
$traces = array();
|
||||||
|
$caller = array();
|
||||||
|
|
||||||
|
if ($useTrace || defined('HHVM_VERSION')) {
|
||||||
|
$traces = debug_backtrace();
|
||||||
|
$caller = $traces[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// The SplObjectStorage class performs calls to its own methods. These
|
||||||
|
// method calls must not lead to triggered deprecation notices.
|
||||||
|
if (isset($caller['class']) && 'SplObjectStorage' === $caller['class']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@trigger_error('The '.$methodName.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user