Bug #73487 [Opn->Nab]: Non-static method does not throw E_DEPRECATED
Edit report at https://bugs.php.net/bug.php?id=73487&edit=1
ID: 73487
Updated by: requinix@php.net
Reported by: vyants at dengisrazy dot ru
Summary: Non-static method does not throw E_DEPRECATED
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
PHP Version: 7.0.13
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"static::bar()" does not mean to call the bar method statically. Rather the
"static" indicates the use of late static binding (LSB) and means to call the bar method
of the class which was originally invoked. Just like how "self::" means to call a method
on the class currently executing, or "parent::" on the superclass.
See example #3 in the documentation for late static binding.
http://php.net/language.oop5.late-static-bindings#language.oop5.late-static-bindings.usage
Previous Comments:
------------------------------------------------------------------------
[2016-11-10 12:44:12] vyants at dengisrazy dot ru
Description:
------------
PHP does not throw E_DEPRECATED exception when non static method calls as static inside object.
Test script:
---------------
<?php
class Foo {
public function bar()
{
echo "1";
}
public function bar2()
{
static::bar();
}
}
$class = new Foo();
//throw E_DEPRECATED
$class::bar();
//!!! no exception
$class->bar2();
Expected result:
----------------
I expect 2 E_DEPRECATED
Actual result:
--------------
$class::bar() - throw Exception
but $class->bar2() - work without exception
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73487&edit=1
Thread (2 messages)