# [patch] final use only for methods

- Thread: https://externals.io/message/979
- Original archive: https://news-web.php.net/php.internals/979
- Started by Sterling Hughes on 2003-04-19T16:17:50+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #979 — Sterling Hughes — 2003-04-19T16:17:50+00:00

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

The attached patch modifies zend_language_parser, having it generate a
compiler error when final is used on a class property (since we are only
allowing it for methods.)

-Sterling

-- 
"First they ignore you, then they laugh at you,  
 then they fight you, then you win."  
    - Gandhi

---

## #981 — Timm Friebe — 2003-04-19T17:46:25+00:00

URL: https://externals.io/message/979#981 · In reply to: #979

> The attached patch modifies zend_language_parser, having it generate a
> compiler error when final is used on a class property (since we are only
> allowing it for methods.)

You could then also drop:

if (parent_info->flags & ZEND_ACC_FINAL) {
  zend_error(E_COMPILE_ERROR, "Cannot override final property %s::$%s",
parent_ce->name, hash_key->arKey);
}

and

if (((current_access_type->u.constant.value.lval |
new_modifier->u.constant.value.lval) & (ZEND_ACC_ABSTRACT |
ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) {
	zend_error(E_COMPILE_ERROR, "Cannot use the final modifier on an
abstract class member");
}

and

if (((current_access_type->u.constant.value.lval |
new_modifier->u.constant.value.lval) & (ZEND_ACC_PRIVATE |
ZEND_ACC_FINAL)) == (ZEND_ACC_PRIVATE | ZEND_ACC_FINAL)) {
	zend_error(E_COMPILE_ERROR, "Cannot use the final modifier on a private
class member");
}

from zend_compile.c

- Timm

---

## #982 — marcus.boerger@t-online.de — 2003-04-19T18:47:38+00:00

URL: https://externals.io/message/979#982 · In reply to: #979

At 19:46 19.04.2003, Timm Friebe wrote:
>
> > […]
>
>You could then also drop:
>
>if (parent_info->flags & ZEND_ACC_FINAL) {
>   zend_error(E_COMPILE_ERROR, "Cannot override final property %s::$%s",
>parent_ce->name, hash_key->arKey);
>}


Only the above. The other two are needed for method checks.

marcus
