Bug->Req #75943 [Nab->Sus]: autoload trying load existing class when it extends not existing class
| From: | requinix@php.net | Date: | Fri, 09 Feb 2018 14:19:12 +0000 |
| Subject: | Bug->Req #75943 [Nab->Sus]: autoload trying load existing class when it extends not existing class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213899@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75943&edit=1
ID: 75943
Updated by: requinix@php.net
Reported by: akademic at hub dot sknt dot ru
Summary: autoload trying load existing class when it extends
not existing class
-Status: Not a bug
+Status: Suspended
-Type: Bug
+Type: Feature/Change Request
Package: Class/Object related
Operating System: Ubuntu 16.04.3 LTS
PHP Version: 7.2.2
Block user comment: N
Private report: N
New Comment:
Thank you for your interest in PHP and for submitting a feature
request. Please be aware that due to the magnitude of change this
request requires, it would be necessary to discuss it on PHP
Internals list (internals@lists.php.net) as an RFC. Please read
the guide about creating RFCs here:
<https://wiki.php.net/rfc/howto>. If you
haven't had experience
with writing RFCs before, it is advised to seek guidance on the
Internals list (<http://php.net/mailing-lists.php>) and/or solicit
help from one of the experienced developers.
Please something something this comment something a view on the
merits of your proposal â every proposal which requires changes of
certain magnitude, even the very successful and widely supported
ones, must be done through the RFC process. This helps make the
process predictable, transparent and accessible to all developers.
Previous Comments:
------------------------------------------------------------------------
[2018-02-09 14:14:12] akademic at hub dot sknt dot ru
> Oh. I missed out on this reply:
Oh, come on. :) I see you've understand what I've meant.
I believe that this issue should become PHP improvement.
Like it was with supporting expressions in empty() function, late static binding and so on.
If PHP could find class_one in current file, PHP would become more smooth language. It's not
about my needs, it's about consistency.
------------------------------------------------------------------------
[2018-02-09 13:43:57] requinix@php.net
Oh. I missed out on this reply:
> Your example (
echo $x; $x = 1;) is about _execution_.
"No, I say that $x=1 is a declaration. I'm declaring $x to be a variable with the initial
value of 1. PHP should recognize this and allow me to use the variable in the echo statement, and
the fact that it does not is a bug."
Tomato, tomato.
------------------------------------------------------------------------
[2018-02-09 13:40:45] requinix@php.net
> the *real* problem anyways is that it behaves different at all
Of course. I was addressing the (unasked) question of which of the two behaviors was correct. You
say one, I say the other. But it's ultimately about opcache, which I am certainly not an expert
of.
> Your example is about _execution_. My example is about _declaration_.
At first glance yes, because as PHP developers we have the ingrained belief that class and function
definitions are separate from the execution of the script. But that is not entirely true. Sometimes
there is overlap. This is one of those times.
I think I've made my point clear enough that I can't really add anything more to it, so
unless a dev comes and says I'm incorrect then this report is not a bug and is simply a
misunderstanding of some of the PHP internals. These sorts of things are often hidden to userland
developers anyways.
Unless you want to make this a feature request. Do you believe that PHP should change how it deals
with classes (and functions) to suit your needs?
------------------------------------------------------------------------
[2018-02-09 13:20:56] akademic at hub dot sknt dot ru
I've understood your first comment completly.
And now I know what happens under the rug. And I've fixed my code now.
I appreciate your help.
Your example (echo $x; $x = 1;) is about _execution_.
My example (class class_one extends class_two) is about _declaration_. I believe there
is the difference.
I understand technical reasons.
But take a look on this case from PHP-user point.
I have a class:
class class_one {}
And it works perfectly.
Now I change it to class class_one extends class_two {}
My thoughts: I don't have class_two in this file, but I have autoload function, which knows
where class_two is located. So that's ok.
Reality: Fatal error: Class 'class_one' not found. WTF?
I haven't changed the names. I haven't moved code blocks around. I've simply added a
little bit of inheritance and things have gone wrong.
It shouldn't be that. Both situations (with and without inheritance) should fail or both
situations should success.
------------------------------------------------------------------------
[2018-02-09 13:14:39] spam2 at rhsoft dot net
no, the bug is clearly that it don't work without because at *compile time* there is no reason
that order matters - that's what compilers are about
the *real* problem anyways is that it behaves different at all while a cache/optimizer should be
fully transparent and not change basic behavior
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=75943
--
Edit this bug report at https://bugs.php.net/bug.php?id=75943&edit=1