# do_bind_inherited_class()

- Thread: https://externals.io/message/21540
- Original archive: https://news-web.php.net/php.internals/21540
- Started by Tim Starling on 2006-01-15T13:15:21+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21540 — Tim Starling — 2006-01-15T13:15:21+00:00

URL: https://externals.io/message/21540#21540

I was just browsing the PHP source and I noticed something apparently amiss.
The top of do_bind_inherited_class() in Zend/zend_compile.c reads:

    found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant),
Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void
**) &pce);

    if (found_ce == FAILURE) {
        if (!compile_time) {
            /* If we're in compile time, in practice, it's quite possible
             * that we'll never reach this class declaration at runtime,
             * so we shut up about it.  This allows the if (!defined('FOO'))
{ return; }
             * approach to work.
             */
            zend_error(E_COMPILE_ERROR, "Cannot redeclare class %R",
Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
        }
        return NULL;
    } else {
        ce = *pce;
    }


Shouldn't that be

    found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant),
Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void
**) &pce);

    if (found_ce == FAILURE) {
        zend_error(E_COMPILE_ERROR, "Internal Zend error - Missing class
information for %R", Z_TYPE(opline->op1.u.constant),
Z_UNIVAL(opline->op1.u.constant));
        return NULL;
    } else {
        ce = *pce;
    }

same as do_bind_class()? I'll submit that as a proper patch if you prefer.

-- Tim Starling

---

## #21541 — Antony Dovgal — 2006-01-15T13:31:19+00:00

URL: https://externals.io/message/21540#21541 · In reply to: #21540

What exactly are you trying to fix?


> I was just browsing the PHP source and I noticed something apparently amiss.
> The top of do_bind_inherited_class() in Zend/zend_compile.c reads:
> 
>     found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant),
> Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void
> **) &pce);
> 
>     if (found_ce == FAILURE) {
>         if (!compile_time) {
>             /* If we're in compile time, in practice, it's quite possible
>              * that we'll never reach this class declaration at runtime,
>              * so we shut up about it.  This allows the if (!defined('FOO'))
> { return; }
>              * approach to work.
>              */
>             zend_error(E_COMPILE_ERROR, "Cannot redeclare class %R",
> Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
>         }
>         return NULL;
>     } else {
>         ce = *pce;
>     }
> 
> 
> Shouldn't that be
> 
>     found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant),
> Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void
> **) &pce);
> 
>     if (found_ce == FAILURE) {
>         zend_error(E_COMPILE_ERROR, "Internal Zend error - Missing class
> information for %R", Z_TYPE(opline->op1.u.constant),
> Z_UNIVAL(opline->op1.u.constant));
>         return NULL;
>     } else {
>         ce = *pce;
>     }
> 
> same as do_bind_class()? I'll submit that as a proper patch if you prefer.
> 
> -- Tim Starling
> 


-- 
Wbr, 
Antony Dovgal

---

## #21544 — Tim Starling — 2006-01-15T14:34:25+00:00

URL: https://externals.io/message/21540#21544 · In reply to: #21541

Antony Dovgal wrote:
> What exactly are you trying to fix?

Confusing, misdocumented code. I'm sorry, am I wasting bandwidth? I felt duty-bound to report it.

-- Tim Starling
