FAQ
Hello internals,

version 5 does neither support nested classes nor conditional classes.
Not supporting the former is a bit of a loss but the latter leads to
ugly software design so no worry here.

Anyway i tried the test script with 4.3.5-dev and there conditional
classes are present but not working. Hence i suggest we disable or fix
them.

Further more i think we cannot fix it becasue the script mixes compile
time and run time. It tries something like selfmodifying code.


Since i think it is ugly software design anyways i am pro disabling.

marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'

marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'


--
Best regards,
Marcus mailto:helly@php.net

Search Discussions

  • Christian Schneider at Jan 5, 2004 at 2:58 pm

    Marcus Boerger wrote:
    Further more i think we cannot fix it becasue the script mixes compile
    time and run time. It tries something like selfmodifying code.
    I agree that it should be disabled. If someone really, really wants to
    do it they can still include/eval conditionally.

    - Chris
  • Marcus Boerger at Jan 5, 2004 at 3:08 pm
    Hello Christian,

    Monday, January 5, 2004, 3:58:22 PM, you wrote:
    Marcus Boerger wrote:
    Further more i think we cannot fix it becasue the script mixes compile
    time and run time. It tries something like selfmodifying code.
    I agree that it should be disabled. If someone really, really wants to
    do it they can still include/eval conditionally.
    And in php 5 one can use the __autoload() feature which is the correct
    choice for such designs where classes are optional.

    --
    Best regards,
    Marcus mailto:helly@php.net
  • Andi Gutmans at Jan 5, 2004 at 4:22 pm
    This is strange. I remember it used to work. We'll look into it.

    Andi
    At 03:37 PM 1/5/2004 +0100, Marcus Boerger wrote:
    Hello internals,

    version 5 does neither support nested classes nor conditional classes.
    Not supporting the former is a bit of a loss but the latter leads to
    ugly software design so no worry here.

    Anyway i tried the test script with 4.3.5-dev and there conditional
    classes are present but not working. Hence i suggest we disable or fix
    them.

    Further more i think we cannot fix it becasue the script mixes compile
    time and run time. It tries something like selfmodifying code.


    Since i think it is ugly software design anyways i am pro disabling.

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'


    --
    Best regards,
    Marcus mailto:helly@php.net

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Alan Knowles at Jan 6, 2004 at 4:57 pm
    This only affects single line conditional class and function declarations.

    php -r ' if (1) { function test () { echo "1"; }} else { function
    test() { echo "0"; }} test();'

    It affects php4.3.2 and up. (and probably alot earlier....)

    if you lay this out in a file, it works perfectly: eg.
    <?php

    if (1) {
    function test () { echo "1"; }
    } else {
    function test() { echo "0"; }
    }
    test();

    I think the fix in here should be ok for conditional classes / nested
    class issue...

    http://bugs.php.net/26760

    Not sure if the above is a critical case.. - but it was a bit supprising...

    Regards
    Alan



    Andi Gutmans wrote:
    This is strange. I remember it used to work. We'll look into it.

    Andi
    At 03:37 PM 1/5/2004 +0100, Marcus Boerger wrote:

    Hello internals,

    version 5 does neither support nested classes nor conditional classes.
    Not supporting the former is a bit of a loss but the latter leads to
    ugly software design so no worry here.

    Anyway i tried the test script with 4.3.5-dev and there conditional
    classes are present but not working. Hence i suggest we disable or fix
    them.

    Further more i think we cannot fix it becasue the script mixes compile
    time and run time. It tries something like selfmodifying code.


    Since i think it is ugly software design anyways i am pro disabling.

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'


    --
    Best regards,
    Marcus mailto:helly@php.net

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Zeev Suraski at Jan 6, 2004 at 9:23 pm

    At 18:58 06/01/2004, Alan Knowles wrote:
    This only affects single line conditional class and function declarations.

    php -r ' if (1) { function test () { echo "1"; }} else { function
    test() { echo "0"; }} test();'

    It affects php4.3.2 and up. (and probably alot earlier....)
    Wow, that's a neat one. Took me a while to realize what the heck is going
    on, but basically it has to do with the way the engine mangles
    function/class names. It's based on the file name and the line
    number. This *usually* works, practically, it always works except for when
    using -r (which probably didn't exist at the time we introduced this
    mangling...

    Anyway, I'll look into fixing it. Thanks for pinpointing the problem!

    Zeev
  • Johannes Schlueter at Jan 9, 2004 at 11:16 pm
    Hi,

    Zeev Suraski wrote:
    Wow, that's a neat one. Took me a while to realize what the heck is
    going on, but basically it has to do with the way the engine mangles
    function/class names. It's based on the file name and the line number.
    This *usually* works, practically, it always works except for when using
    -r (which probably didn't exist at the time we introduced this mangling...

    Anyway, I'll look into fixing it. Thanks for pinpointing the problem!
    Might #26456 be caused by the same problem? Then it also affects the
    PHP5/ZE2 branch.
    http://bugs.php.net/bug.php?id=26456

    johannes
  • Andi Gutmans at Jan 11, 2004 at 7:39 pm
    I fixed this problem. I agree it's not great coding but there's no real
    reason to break BC on this issue.
    I also fixed the problem with conditional function declerations being on
    the same line.

    Andi
    At 03:37 PM 1/5/2004 +0100, Marcus Boerger wrote:
    Hello internals,

    version 5 does neither support nested classes nor conditional classes.
    Not supporting the former is a bit of a loss but the latter leads to
    ugly software design so no worry here.

    Anyway i tried the test script with 4.3.5-dev and there conditional
    classes are present but not working. Hence i suggest we disable or fix
    them.

    Further more i think we cannot fix it becasue the script mixes compile
    time and run time. It tries something like selfmodifying code.


    Since i think it is ugly software design anyways i am pro disabling.

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'

    marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function
    f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'


    --
    Best regards,
    Marcus mailto:helly@php.net

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJan 5, '04 at 2:37p
activeJan 11, '04 at 7:39p
posts8
users6
websitephp.net

People

Translate

site design / logo © 2022 Grokbase