# import/use last call

- Thread: https://externals.io/message/32916
- Original archive: https://news-web.php.net/php.internals/32916
- Started by Stanislav Malyshev on 2007-10-22T21:28:32+00:00
- Messages: 18
- 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

---

## #32916 — Stanislav Malyshev — 2007-10-22T21:28:32+00:00

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

Hi all!

Since many packages (wordpress, propel, horde, phing, etc.) use "import" 
as either class or function name, and we couldn't find a good solution 
to make it work with import keyword without going into all kinds of 
troublesome hacks, so we are thinking about replacing 'import' keyword 
with 'use' keyword, which is already reserved.

If you know any reason why this may be a problem - please speak now (or 
forever hold your peace :). Please do not answer this email with 
proposals to replace 'namespace' keyword with 'package', etc. - it will 
be offtopic. For this topic please let's discuss only using keyword 
'use' instead of 'import'.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #32918 — Gregory Beaver — 2007-10-22T23:18:52+00:00

URL: https://externals.io/message/32916#32918 · In reply to: #32916

Stanislav Malyshev wrote:
> Hi all!
> 
> Since many packages (wordpress, propel, horde, phing, etc.) use "import"
> as either class or function name, and we couldn't find a good solution
> to make it work with import keyword without going into all kinds of
> troublesome hacks, so we are thinking about replacing 'import' keyword
> with 'use' keyword, which is already reserved.
> 
> If you know any reason why this may be a problem - please speak now (or
> forever hold your peace :). Please do not answer this email with
> proposals to replace 'namespace' keyword with 'package', etc. - it will
> be offtopic. For this topic please let's discuss only using keyword
> 'use' instead of 'import'.

Hold off for a bit - I may have a simple solution that solves the
problem for class names, method names and functions, have to code the
patch tonight first to prove it works.

Greg

---

## #32919 — Marcus Boerger — 2007-10-22T23:20:43+00:00

URL: https://externals.io/message/32916#32919 · In reply to: #32918

Hello Gregory,

  even if you can solve it easily your patch will not solve the fact that we
  won't have a token for that keyword the, or am i missing something?

marcus

Tuesday, October 23, 2007, 1:18:52 AM, you wrote:

> Stanislav Malyshev wrote:
> > […]

> Hold off for a bit - I may have a simple solution that solves the
> problem for class names, method names and functions, have to code the
> patch tonight first to prove it works.

> Greg




Best regards,
 Marcus

---

## #32920 — Stanislav Malyshev — 2007-10-22T23:59:11+00:00

URL: https://externals.io/message/32916#32920 · In reply to: #32918

> Hold off for a bit - I may have a simple solution that solves the
> problem for class names, method names and functions, have to code the
> patch tonight first to prove it works.

OK, please send it as soon as you have it :)
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #32922 — Brian Moon — 2007-10-23T01:03:17+00:00

URL: https://externals.io/message/32916#32922 · In reply to: #32916

Stanislav Malyshev wrote:
> Since many packages (wordpress, propel, horde, phing, etc.) use "import" 
> as either class or function name, and we couldn't find a good solution 
> to make it work with import keyword without going into all kinds of 
> troublesome hacks, so we are thinking about replacing 'import' keyword 
> with 'use' keyword, which is already reserved.

If 'use' is already reserved, it makes the most sense IMO.

-- 

Brian Moon
Senior Developer
------------------------------
http://dealnews.com/
It's good to be cheap =)

---

## #32923 — Gregory Beaver — 2007-10-23T03:21:45+00:00

URL: https://externals.io/message/32916#32923 · In reply to: #32919

Marcus Boerger wrote:
> Hello Gregory,
>
>   even if you can solve it easily your patch will not solve the fact that we
>   won't have a token for that keyword the, or am i missing something?
>
> marcus
Hi Marcus,

Just finished the patch (see separate reply), and in my tests, the
keyword still works as a keyword.  So unless I'm not understanding your
question, yes, we will have a token for the keyword.

Greg

P.S. feel free to call me Greg :)

---

## #32924 — Gregory Beaver — 2007-10-23T03:43:24+00:00

URL: https://externals.io/message/32916#32924 · In reply to: #32920

Stanislav Malyshev wrote:
> > […]
>
> OK, please send it as soon as you have it :)
Hi,

The attached patch is for PHP 5.3, if it is acceptable, I will port it
to PHP 6, which is not difficult, although it does involve a lot of
cut/pasting.

The patch does these things:

1) fixes an unrelated bug I found in implementation of LSB - "static" is
not checked for in zend_do_import()/zend_do_namespace() and other places
that we check for "self" and "parent"
2) fixes a rather serious error in the fix for Bug #42859 - missing
parens in zend_do_import()
3) adds "import" and "namespace" as valid function/class names
4) allows any string for method names, just as we allow any string for
variable names
5) fixes a bug in logic for $class->list where $class-> list (note the
whitespace between -> and list) returns a `T_LIST` instead of `T_STRING` 
6) It allows "import ::Classname as Blah" which is currently a parse error
7) class constants are unchanged - reserved words still error out.

Note that the zend_compile.c fixes can all be committed directly as they
are all bugfixes and not related to the import/namespace/reserved words fix.

To implement this, I added several states to the lexer in order to
return `T_STRING` whenever possible, which is after T_NEW, T_INTERFACE,
T_CLASS, `T_EXTENDS` and in the `T_IMPLEMENTS` list.  In addition, after
 `T_FUNCTION` outside of a class, it returns `T_STRING` for "import" and
"namespace" but no other reserved words.  After `T_FUNCTION` inside of a
class (method declaration), it returns `T_STRING` for all possible
strings.  After :: or -> `T_STRING` is always returned.  Also, rather than
take the approach LSB does with T_STATIC, I have the lexer initialize
the string value of T_IMPORT and `T_NAMESPACE` so we can preserve case for
autoloading needs.  The parser frees the unused char * when normal
import/namespace declarations are called.

In the parser, I use fully_qualified_class_name instead of
namespace_name for both import syntaxes.  This introduces a minor issue
in that this is no longer a parse error:

import static::oops as Classname;

However, if "Classname" is used, this will simply result in "Fatal
error: Class 'static::oops' not found in..." and shouldn't be too big of
a deal.  Also in the parser, I inserted T_IMPORT and `T_NAMESPACE` as
aliases to `T_STRING` in global situations to allow for static method
calls, class constants, and fully-qualified namespace calls.

Basically this script is now possible with the patch:

<?php
namespace import;
import ::Exception as Test;
function import() {echo 'import function';}
interface import {}
interface fooey {}
class Exception extends ::Exception implements fooey, import {}
class namespace {
    const HI = 3;
    function list() {echo __METHOD__;}
}
import();
var_dump(namespace::HI);
namespace::list();
?>

and results in this output:

cellog@lot-49:~/workspace/php5$ sapi/cli/php -n testme.php
import functionint(3)
import::namespace::list

I have not performed profiling on the patch, instead focusing on
correctness for now.

The patch looks complicated because of the additional states, but is
really not that complicated, honest.

:)
Greg

---

## #32929 — Giedrius D — 2007-10-23T09:08:23+00:00

URL: https://externals.io/message/32916#32929 · In reply to: #32924

Hi,

sorry if I missed something but is there any reason to not use keyword "use"?

IMHO allowing keywords in class, method, function, etc. names brings
more confusion then value.


> Stanislav Malyshev wrote:
> > […]
> Hi,
>
> The attached patch is for PHP 5.3, if it is acceptable, I will port it
> to PHP 6, which is not difficult, although it does involve a lot of
> cut/pasting.
>
> The patch does these things:
>
> 1) fixes an unrelated bug I found in implementation of LSB - "static" is
> not checked for in zend_do_import()/zend_do_namespace() and other places
> that we check for "self" and "parent"
> 2) fixes a rather serious error in the fix for Bug #42859 - missing
> parens in zend_do_import()
> 3) adds "import" and "namespace" as valid function/class names
> 4) allows any string for method names, just as we allow any string for
> variable names
> 5) fixes a bug in logic for $class->list where $class-> list (note the
> whitespace between -> and list) returns a `T_LIST` instead of `T_STRING` 
> 6) It allows "import ::Classname as Blah" which is currently a parse error
> 7) class constants are unchanged - reserved words still error out.
>
> Note that the zend_compile.c fixes can all be committed directly as they
> are all bugfixes and not related to the import/namespace/reserved words fix.
>
> To implement this, I added several states to the lexer in order to
> return `T_STRING` whenever possible, which is after T_NEW, T_INTERFACE,
> T_CLASS, `T_EXTENDS` and in the `T_IMPLEMENTS` list.  In addition, after
> `T_FUNCTION` outside of a class, it returns `T_STRING` for "import" and
> "namespace" but no other reserved words.  After `T_FUNCTION` inside of a
> class (method declaration), it returns `T_STRING` for all possible
> strings.  After :: or -> `T_STRING` is always returned.  Also, rather than
> take the approach LSB does with T_STATIC, I have the lexer initialize
> the string value of T_IMPORT and `T_NAMESPACE` so we can preserve case for
> autoloading needs.  The parser frees the unused char * when normal
> import/namespace declarations are called.
>
> In the parser, I use fully_qualified_class_name instead of
> namespace_name for both import syntaxes.  This introduces a minor issue
> in that this is no longer a parse error:
>
> import static::oops as Classname;
>
> However, if "Classname" is used, this will simply result in "Fatal
> error: Class 'static::oops' not found in..." and shouldn't be too big of
> a deal.  Also in the parser, I inserted T_IMPORT and `T_NAMESPACE` as
> aliases to `T_STRING` in global situations to allow for static method
> calls, class constants, and fully-qualified namespace calls.
>
> Basically this script is now possible with the patch:
>
> <?php
> namespace import;
> import ::Exception as Test;
> function import() {echo 'import function';}
> interface import {}
> interface fooey {}
> class Exception extends ::Exception implements fooey, import {}
> class namespace {
>     const HI = 3;
>     function list() {echo __METHOD__;}
> }
> import();
> var_dump(namespace::HI);
> namespace::list();
> ?>
>
> and results in this output:
>
> cellog@lot-49:~/workspace/php5$ sapi/cli/php -n testme.php
> import functionint(3)
> import::namespace::list
>
> I have not performed profiling on the patch, instead focusing on
> correctness for now.
>
> The patch looks complicated because of the additional states, but is
> really not that complicated, honest.
>
> :)
> Greg
>
> ? Zend/tests/zend_function_name.phpt
> Index: Zend/zend_compile.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_compile.c,v
> retrieving revision 1.647.2.27.2.41.2.10
> diff -u -r1.647.2.27.2.41.2.10 zend_compile.c
> --- Zend/zend_compile.c 17 Oct 2007 10:01:21 -0000      1.647.2.27.2.41.2.10
> +++ Zend/zend_compile.c 23 Oct 2007 03:15:41 -0000
> @@ -2975,7 +2975,7 @@
>
>         lcname = zend_str_tolower_dup(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len);
>
> -       if (!(strcmp(lcname, "self") && strcmp(lcname, "parent"))) {
> +       if (!(strcmp(lcname, "self") && strcmp(lcname, "parent") && strcmp(lcname, "static"))) {
>                 efree(lcname);
>                 zend_error(E_COMPILE_ERROR, "Cannot use '%s' as class name as it is reserved", class_name->u.constant.value.str.val);
>         }
> @@ -4582,7 +4582,9 @@
>         if (((Z_STRLEN(name->u.constant) == sizeof("self")-1) &&
>               !memcmp(lcname, "self", sizeof("self")-1)) ||
>             ((Z_STRLEN(name->u.constant) == sizeof("parent")-1) &&
> -          !memcmp(lcname, "parent", sizeof("parent")-1))) {
> +          !memcmp(lcname, "parent", sizeof("parent")-1)) ||
> +           ((Z_STRLEN(name->u.constant) == sizeof("static")-1) &&
> +          !memcmp(lcname, "static", sizeof("static")-1))) {
>                 zend_error(E_COMPILE_ERROR, "Cannot use '%s' as namespace name", Z_STRVAL(name->u.constant));
>         }
>         efree(lcname);
> @@ -4596,7 +4598,7 @@
>  {
>         char *lcname;
>         zval *name, *ns, tmp;
> -       zend_bool warn = 0;
> +       zend_bool warn = 0, shorthand = 0;
>
>         if (!CG(current_import)) {
>                 CG(current_import) = emalloc(sizeof(HashTable));
> @@ -4611,11 +4613,12 @@
>                 char *p;
>
>                 /* The form "import A::B" is eqivalent to "import A::B as B".
> -                  So we extract the last part of compound name ti use as a new_name */
> +                  So we extract the last part of compound name to use as a new_name */
>                 name = &tmp;
>                 p = zend_memrchr(Z_STRVAL_P(ns), ':', Z_STRLEN_P(ns));
>                 if (p) {
>                         ZVAL_STRING(name, p+1, 1);
> +                       shorthand = 1;
>                 } else {
>                         *name = *ns;
>                         zval_copy_ctor(name);
> @@ -4627,6 +4630,8 @@
>
>         if (((Z_STRLEN_P(name) == sizeof("self")-1) &&
>            !memcmp(lcname, "self", sizeof("self")-1)) ||
> +           ((Z_STRLEN_P(name) == sizeof("static")-1) &&
> +          !memcmp(lcname, "static", sizeof("static")-1)) ||
>             ((Z_STRLEN_P(name) == sizeof("parent")-1) &&
>            !memcmp(lcname, "parent", sizeof("parent")-1))) {
>                 zend_error(E_COMPILE_ERROR, "Cannot use '%s' as import name", Z_STRVAL_P(name));
> @@ -4640,7 +4645,8 @@
>                 ns_name[Z_STRLEN_P(CG(current_namespace))] = ':';
>                 ns_name[Z_STRLEN_P(CG(current_namespace))+1] = ':';
>                 memcpy(ns_name+Z_STRLEN_P(CG(current_namespace))+2, lcname, Z_STRLEN_P(name)+1);
> -               if (zend_hash_exists(CG(class_table), ns_name, Z_STRLEN_P(CG(current_namespace)) + 2 + Z_STRLEN_P(name)+1)) {
> +               /* if our new import name is simply the shorthand, skip this check */
> +               if ((!shorthand || !memcmp(ns_name, Z_STRVAL_P(ns), Z_STRLEN_P(ns) + 1)) && zend_hash_exists(CG(class_table), ns_name, Z_STRLEN_P(CG(current_namespace)) + 2 + Z_STRLEN_P(name)+1)) {
>                         zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined class", Z_STRVAL_P(name));
>                 }
>                 efree(ns_name);
> Index: Zend/zend_language_parser.y
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_language_parser.y,v
> retrieving revision 1.160.2.4.2.8.2.4
> diff -u -r1.160.2.4.2.8.2.4 zend_language_parser.y
> --- Zend/zend_language_parser.y 1 Oct 2007 10:37:13 -0000       1.160.2.4.2.8.2.4
> +++ Zend/zend_language_parser.y 23 Oct 2007 03:15:41 -0000
> @@ -47,7 +47,7 @@
>  %}
>
>  %pure_parser
> -%expect 2
> +%expect 3
>
>  %left `T_INCLUDE` T_INCLUDE_ONCE `T_EVAL` T_REQUIRE `T_REQUIRE_ONCE` 
>  %left ','
> @@ -142,7 +142,7 @@
>  %token `T_END_HEREDOC` 
>  %token `T_DOLLAR_OPEN_CURLY_BRACES` 
>  %token `T_CURLY_OPEN` 
> -%token `T_PAAMAYIM_NEKUDOTAYIM` 
> +%left `T_PAAMAYIM_NEKUDOTAYIM` 
>  %token `T_NAMESPACE` 
>  %token T_IMPORT
>  %token `T_NS_C` 
> @@ -160,6 +160,8 @@
>
>  namespace_name:
>                 `T_STRING` { $$ = $1; }
> +       |       T_IMPORT { $$ = $1; }
> +       |       `T_NAMESPACE` { $$ = $1; }
>         |       namespace_name `T_PAAMAYIM_NEKUDOTAYIM` T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
>  ;
>
> @@ -168,9 +170,9 @@
>         |       function_declaration_statement  { zend_do_early_binding(TSRMLS_C); }
>         |       class_declaration_statement             { zend_do_early_binding(TSRMLS_C); }
>         |       `T_HALT_COMPILER` '(' ')' ';'             { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
> -       |       `T_NAMESPACE` namespace_name ';'  { zend_do_namespace(&$2 TSRMLS_CC); }
> -       |       T_IMPORT namespace_name ';'             { zend_do_import(&$2, `NULL` TSRMLS_CC); }
> -       |       T_IMPORT namespace_name `T_AS` T_STRING ';'       { zend_do_import(&$2, &$4 TSRMLS_CC); }
> +       |       `T_NAMESPACE` namespace_name ';'  { efree($1.u.constant.value.str.val);zend_do_namespace(&$2 TSRMLS_CC); }
> +       |       T_IMPORT fully_qualified_class_name ';'         { efree($1.u.constant.value.str.val);zend_do_import(&$2, `NULL` TSRMLS_CC); }
> +       |       T_IMPORT fully_qualified_class_name `T_AS` function_name_token ';'        { efree($1.u.constant.value.str.val);zend_do_import(&$2, &$4 TSRMLS_CC); }
>         |       constant_declaration ';'
>  ;
>
> @@ -298,6 +300,12 @@
>                         '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
>  ;
>
> +function_name_token:
> +               `T_STRING` { $$ = $1; }
> +       |       `T_NAMESPACE` { $$ = $1; }
> +       |       T_IMPORT { $$ = $1; }
> +;
> +
>  unticked_class_declaration_statement:
>                 class_entry_type `T_STRING` extends_from
>                         { zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); }
> @@ -636,7 +644,7 @@
>  ;
>
>  function_call:
> -               `T_STRING`        '(' { $2.u.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
> +               function_name_token     '(' { $2.u.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
>                                 function_call_parameter_list
>                                 ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
>         |       `T_PAAMAYIM_NEKUDOTAYIM` T_STRING '(' { $3.u.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
> @@ -661,6 +669,8 @@
>
>  fully_qualified_class_name:
>                 `T_STRING` { $$ = $1; }
> +       |       T_IMPORT { $$ = $1; }
> +       |       `T_NAMESPACE` { $$ = $1; }
>         |       `T_STATIC` { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1, 1);}
>         |       `T_PAAMAYIM_NEKUDOTAYIM` T_STRING { zend_do_build_namespace_name(&$$, NULL, &$2 TSRMLS_CC); }
>         |       fully_qualified_class_name `T_PAAMAYIM_NEKUDOTAYIM` T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
> Index: Zend/zend_language_scanner.l
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
> retrieving revision 1.131.2.11.2.13.2.2
> diff -u -r1.131.2.11.2.13.2.2 zend_language_scanner.l
> --- Zend/zend_language_scanner.l        7 Oct 2007 05:22:03 -0000       1.131.2.11.2.13.2.2
> +++ Zend/zend_language_scanner.l        23 Oct 2007 03:15:42 -0000
> @@ -45,6 +45,11 @@
>  %x ST_COMMENT
>  %x ST_DOC_COMMENT
>  %x ST_ONE_LINE_COMMENT
> +%x ST_LOOKING_FOR_CLASSNAME
> +%x ST_LOOKING_FOR_EXTENDS
> +%x ST_LOOKING_FOR_IMPLEMENTS
> +%x ST_LOOKING_FOR_FUNCTION_NAME
> +%x ST_LOOKING_FOR_METHOD_NAME
>  %option stack
>
>  %{
> @@ -969,143 +974,172 @@
>  %option noyywrap
>  %%
>
> -<ST_IN_SCRIPTING>"exit" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"exit" {
>         return T_EXIT;
>  }
>
> -<ST_IN_SCRIPTING>"die" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"die" {
>         return T_EXIT;
>  }
>
>  <ST_IN_SCRIPTING>"function" {
> +       if (CG(active_class_entry)) {
> +               yy_push_state(ST_LOOKING_FOR_METHOD_NAME TSRMLS_CC);
> +       } else {
> +               yy_push_state(ST_LOOKING_FOR_FUNCTION_NAME TSRMLS_CC);
> +       }
> +       return T_FUNCTION;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"function" {
>         return T_FUNCTION;
>  }
>
> -<ST_IN_SCRIPTING>"const" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"const" {
>         return T_CONST;
>  }
>
> -<ST_IN_SCRIPTING>"return" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"return" {
>         return T_RETURN;
>  }
>
> -<ST_IN_SCRIPTING>"try" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"try" {
>         return T_TRY;
>  }
>
> -<ST_IN_SCRIPTING>"catch" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"catch" {
>         return T_CATCH;
>  }
>
> -<ST_IN_SCRIPTING>"throw" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"throw" {
>         return T_THROW;
>  }
>
> -<ST_IN_SCRIPTING>"if" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"if" {
>         return T_IF;
>  }
>
> -<ST_IN_SCRIPTING>"elseif" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"elseif" {
>         return T_ELSEIF;
>  }
>
> -<ST_IN_SCRIPTING>"endif" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"endif" {
>         return T_ENDIF;
>  }
>
> -<ST_IN_SCRIPTING>"else" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"else" {
>         return T_ELSE;
>  }
>
> -<ST_IN_SCRIPTING>"while" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"while" {
>         return T_WHILE;
>  }
>
> -<ST_IN_SCRIPTING>"endwhile" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"endwhile" {
>         return T_ENDWHILE;
>  }
>
> -<ST_IN_SCRIPTING>"do" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"do" {
>         return T_DO;
>  }
>
> -<ST_IN_SCRIPTING>"for" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"for" {
>         return T_FOR;
>  }
>
> -<ST_IN_SCRIPTING>"endfor" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"endfor" {
>         return T_ENDFOR;
>  }
>
> -<ST_IN_SCRIPTING>"foreach" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"foreach" {
>         return T_FOREACH;
>  }
>
> -<ST_IN_SCRIPTING>"endforeach" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"endforeach" {
>         return T_ENDFOREACH;
>  }
>
> -<ST_IN_SCRIPTING>"declare" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"declare" {
>         return T_DECLARE;
>  }
>
> -<ST_IN_SCRIPTING>"enddeclare" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"enddeclare" {
>         return T_ENDDECLARE;
>  }
>
> -<ST_IN_SCRIPTING>"instanceof" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"instanceof" {
>         return T_INSTANCEOF;
>  }
>
> -<ST_IN_SCRIPTING>"as" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"as" {
>         return T_AS;
>  }
>
> -<ST_IN_SCRIPTING>"switch" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"switch" {
>         return T_SWITCH;
>  }
>
> -<ST_IN_SCRIPTING>"endswitch" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"endswitch" {
>         return T_ENDSWITCH;
>  }
>
> -<ST_IN_SCRIPTING>"case" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"case" {
>         return T_CASE;
>  }
>
> -<ST_IN_SCRIPTING>"default" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"default" {
>         return T_DEFAULT;
>  }
>
> -<ST_IN_SCRIPTING>"break" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"break" {
>         return T_BREAK;
>  }
>
> -<ST_IN_SCRIPTING>"continue" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"continue" {
>         return T_CONTINUE;
>  }
>
> -<ST_IN_SCRIPTING>"echo" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"echo" {
>         return T_ECHO;
>  }
>
> -<ST_IN_SCRIPTING>"print" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"print" {
>         return T_PRINT;
>  }
>
>  <ST_IN_SCRIPTING>"class" {
> +       yy_push_state(ST_LOOKING_FOR_CLASSNAME TSRMLS_CC);
> +       return T_CLASS;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"class" {
>         return T_CLASS;
>  }
>
>  <ST_IN_SCRIPTING>"interface" {
> +       yy_push_state(ST_LOOKING_FOR_CLASSNAME TSRMLS_CC);
> +       return T_INTERFACE;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"interface" {
>         return T_INTERFACE;
>  }
>
>  <ST_IN_SCRIPTING>"extends" {
> +       yy_push_state(ST_LOOKING_FOR_EXTENDS TSRMLS_CC);
> +       return T_EXTENDS;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"extends" {
>         return T_EXTENDS;
>  }
>
>  <ST_IN_SCRIPTING>"implements" {
> +       yy_push_state(ST_LOOKING_FOR_IMPLEMENTS TSRMLS_CC);
> +       return T_IMPLEMENTS;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"implements" {
>         return T_IMPLEMENTS;
>  }
>
> @@ -1118,31 +1152,47 @@
>         return T_OBJECT_OPERATOR;
>  }
>
> -<ST_LOOKING_FOR_PROPERTY>{LABEL} {
> +<ST_LOOKING_FOR_METHOD_NAME>'&' {
> +       return '&';
> +}
> +
> +<ST_LOOKING_FOR_PROPERTY,ST_LOOKING_FOR_METHOD_NAME>{WHITESPACE} {
> +       zendlval->value.str.val = yytext; /* no copying - intentional */
> +       zendlval->value.str.len = yyleng;
> +       zendlval->type = IS_STRING;
> +       HANDLE_NEWLINES(yytext, yyleng);
> +       return T_WHITESPACE;
> +}
> +
> +<ST_LOOKING_FOR_PROPERTY,ST_LOOKING_FOR_METHOD_NAME>{LABEL} {
>         yy_pop_state(TSRMLS_C);
>         zend_copy_value(zendlval, yytext, yyleng);
>         zendlval->type = IS_STRING;
>         return T_STRING;
>  }
>
> -<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
> +<ST_LOOKING_FOR_PROPERTY,ST_LOOKING_FOR_METHOD_NAME>{ANY_CHAR} {
>         yyless(0);
>         yy_pop_state(TSRMLS_C);
>  }
>
>  <ST_IN_SCRIPTING>"::" {
> +       yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
>         return T_PAAMAYIM_NEKUDOTAYIM;
>  }
>
>  <ST_IN_SCRIPTING>"new" {
> +       yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
>         return T_NEW;
>  }
>
> -<ST_IN_SCRIPTING>"clone" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"clone" {
> +       zend_copy_value(zendlval, yytext, yyleng);
> +       zendlval->type = IS_STRING;
>         return T_CLONE;
>  }
>
> -<ST_IN_SCRIPTING>"var" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"var" {
>         return T_VAR;
>  }
>
> @@ -1178,79 +1228,83 @@
>         return T_UNSET_CAST;
>  }
>
> -<ST_IN_SCRIPTING>"eval" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"eval" {
>         return T_EVAL;
>  }
>
> -<ST_IN_SCRIPTING>"include" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"include" {
>         return T_INCLUDE;
>  }
>
> -<ST_IN_SCRIPTING>"include_once" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"include_once" {
>         return T_INCLUDE_ONCE;
>  }
>
> -<ST_IN_SCRIPTING>"require" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"require" {
>         return T_REQUIRE;
>  }
>
> -<ST_IN_SCRIPTING>"require_once" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"require_once" {
>         return T_REQUIRE_ONCE;
>  }
>
>  <ST_IN_SCRIPTING>"namespace" {
> +       zend_copy_value(zendlval, yytext, yyleng);
> +       zendlval->type = IS_STRING;
>         return T_NAMESPACE;
>  }
>
>  <ST_IN_SCRIPTING>"import" {
> +       zend_copy_value(zendlval, yytext, yyleng);
> +       zendlval->type = IS_STRING;
>         return T_IMPORT;
>  }
>
> -<ST_IN_SCRIPTING>"use" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"use" {
>         return T_USE;
>  }
>
> -<ST_IN_SCRIPTING>"global" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"global" {
>         return T_GLOBAL;
>  }
>
> -<ST_IN_SCRIPTING>"isset" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"isset" {
>         return T_ISSET;
>  }
>
> -<ST_IN_SCRIPTING>"empty" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"empty" {
>         return T_EMPTY;
>  }
>
> -<ST_IN_SCRIPTING>"__halt_compiler" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__halt_compiler" {
>         return T_HALT_COMPILER;
>  }
>
> -<ST_IN_SCRIPTING>"static" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"static" {
>         return T_STATIC;
>  }
>
> -<ST_IN_SCRIPTING>"abstract" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"abstract" {
>         return T_ABSTRACT;
>  }
>
> -<ST_IN_SCRIPTING>"final" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"final" {
>         return T_FINAL;
>  }
>
> -<ST_IN_SCRIPTING>"private" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"private" {
>         return T_PRIVATE;
>  }
>
> -<ST_IN_SCRIPTING>"protected" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"protected" {
>         return T_PROTECTED;
>  }
>
> -<ST_IN_SCRIPTING>"public" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"public" {
>         return T_PUBLIC;
>  }
>
> -<ST_IN_SCRIPTING>"unset" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"unset" {
>         return T_UNSET;
>  }
>
> @@ -1258,11 +1312,11 @@
>         return T_DOUBLE_ARROW;
>  }
>
> -<ST_IN_SCRIPTING>"list" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"list" {
>         return T_LIST;
>  }
>
> -<ST_IN_SCRIPTING>"array" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"array" {
>         return T_ARRAY;
>  }
>
> @@ -1480,7 +1534,7 @@
>         return T_DNUMBER;
>  }
>
> -<ST_IN_SCRIPTING>"__CLASS__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__CLASS__" {
>         char *class_name = NULL;
>
>         if (CG(active_class_entry)) {
> @@ -1496,7 +1550,7 @@
>         return T_CLASS_C;
>  }
>
> -<ST_IN_SCRIPTING>"__FUNCTION__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__FUNCTION__" {
>         char *func_name = NULL;
>
>         if (CG(active_op_array)) {
> @@ -1512,7 +1566,7 @@
>         return T_FUNC_C;
>  }
>
> -<ST_IN_SCRIPTING>"__METHOD__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__METHOD__" {
>         char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL;
>         char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL;
>         size_t len = 0;
> @@ -1533,13 +1587,13 @@
>         return T_METHOD_C;
>  }
>
> -<ST_IN_SCRIPTING>"__LINE__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__LINE__" {
>         zendlval->value.lval = CG(zend_lineno);
>         zendlval->type = IS_LONG;
>         return T_LINE;
>  }
>
> -<ST_IN_SCRIPTING>"__FILE__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__FILE__" {
>         char *filename = zend_get_compiled_filename(TSRMLS_C);
>
>         if (!filename) {
> @@ -1551,7 +1605,7 @@
>         return T_FILE;
>  }
>
> -<ST_IN_SCRIPTING>"__NAMESPACE__" {
> +<ST_IN_SCRIPTING,ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>"__NAMESPACE__" {
>         if (CG(current_namespace)) {
>                 *zendlval = *CG(current_namespace);
>                 zval_copy_ctor(zendlval);
> @@ -1561,6 +1615,38 @@
>         return T_NS_C;
>  }
>
> +<ST_LOOKING_FOR_IMPLEMENTS>"," {
> +       return ',';
> +}
> +
> +<ST_LOOKING_FOR_FUNCTION_NAME>"&" {
> +       return '&';
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS>"::" {
> +       return T_PAAMAYIM_NEKUDOTAYIM;
> +}
> +
> +<ST_LOOKING_FOR_IMPLEMENTS,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME>{WHITESPACE} {
> +       zendlval->value.str.val = yytext; /* no copying - intentional */
> +       zendlval->value.str.len = yyleng;
> +       zendlval->type = IS_STRING;
> +       HANDLE_NEWLINES(yytext, yyleng);
> +       return T_WHITESPACE;
> +}
> +
> +<ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_FUNCTION_NAME,ST_LOOKING_FOR_IMPLEMENTS>{LABEL} {
> +       yy_pop_state(TSRMLS_C);
> +       zend_copy_value(zendlval, yytext, yyleng);
> +       zendlval->type = IS_STRING;
> +       return T_STRING;
> +}
> +
> +<ST_LOOKING_FOR_FUNCTION_NAME,ST_LOOKING_FOR_CLASSNAME,ST_LOOKING_FOR_EXTENDS,ST_LOOKING_FOR_IMPLEMENTS>{ANY_CHAR} {
> +       yyless(0);
> +       yy_pop_state(TSRMLS_C);
> +}
> +
>  <INITIAL>(([^<]|"<"[^?%s<]){1,400})|"<s"|"<" {
>  #ifdef ZEND_MULTIBYTE
>         if (SCNG(output_filter)) {
> @@ -1693,7 +1779,6 @@
>         return T_STRING;
>  }
>
> -
>  <ST_IN_SCRIPTING>{WHITESPACE} {
>         zendlval->value.str.val = yytext; /* no copying - intentional */
>         zendlval->value.str.len = yyleng;
>
>
> --
> 
> 
>


-- 
Pagarbiai
Giedrius Dubinskas
Mob.: 8 672 42863

---

## #32930 — dz@bitxtender.com — 2007-10-23T11:58:05+00:00

URL: https://externals.io/message/32916#32930 · In reply to: #32929

yeah. let's just go for "use".


David




Am 23.10.2007 um 11:08 schrieb Giedrius D:

> Hi,
>
> sorry if I missed something but is there any reason to not use  
> keyword "use"?
>
> IMHO allowing keywords in class, method, function, etc. names brings
> more confusion then value.
>
> 
> > […]
>
>
> -- 
> Pagarbiai
> Giedrius Dubinskas
> Mob.: 8 672 42863

---

## #32931 — Gregory Beaver — 2007-10-23T14:03:43+00:00

URL: https://externals.io/message/32916#32931 · In reply to: #32929

Giedrius D wrote:
> Hi,
>
> sorry if I missed something but is there any reason to not use keyword "use"?
>
> IMHO allowing keywords in class, method, function, etc. names brings
> more confusion then value.
>   
The same confusion that is brought about by allowing keywords as
variable names?

<?php
class Test
{
    public $class;
}

$a = new Test;
$a->class = 1;
?>

Is this next example any more confusing?

<?php
class Test
{
    function class(){}
}

$a = new Test;
$a->class();
?>

I think you're confused by what is proposed :).

Greg

---

## #32933 — Giedrius D — 2007-10-23T17:42:46+00:00

URL: https://externals.io/message/32916#32933 · In reply to: #32931

> The same confusion that is brought about by allowing keywords as
> variable names?
>
> <?php
> class Test
> {
>     public $class;
> }
>
> $a = new Test;
> $a->class = 1;
> ?>
>
> Is this next example any more confusing?
>
> <?php
> class Test
> {
>     function class(){}
> }
>
> $a = new Test;
> $a->class();
> ?>
>
> I think you're confused by what is proposed :).

Yes you are right about the methods but consider something like this:
<?php
namespace (Foo::Bar);
import(new new);
// etc.
?>
Looks kinda odd to me although it might have sense in some context.

Anyway my main question was: is there any reason not to use keyword "use"?

Giedrius

---

## #32934 — Gregory Beaver — 2007-10-23T18:56:30+00:00

URL: https://externals.io/message/32916#32934 · In reply to: #32933

Giedrius D wrote:
> 
>   
> > […]
>
> Yes you are right about the methods but consider something like this:
> <?php
> namespace (Foo::Bar);
> import(new new);
>   
parse error - of all reserved words, only "namespace" and "import" are
allowed as class names in my patch
> // etc.
> ?>
> Looks kinda odd to me although it might have sense in some context.
>
> Anyway my main question was: is there any reason not to use keyword "use"?
The only reason for me is that "use" implies some kind of autoloading,
as I suggested in one of my other mails.  This gets into parsing
semantics, something I'm not interested in doing.  If the folks go with
"use" that is fine, but for me personally not the best solution, which
is why I put hours into making this patch.

However, no matter what I definitely would like to see code written for
PHP 5.2 and earlier that uses "import" or "namespace" as class names or
functions continue to work in PHP 5.3.  "namespace" is used commonly for
XML information (for obvious reasons), and import is a very common idea,
as already stated.

Greg

---

## #32935 — Giedrius D — 2007-10-23T20:45:55+00:00

URL: https://externals.io/message/32916#32935 · In reply to: #32934

> > […]
> parse error - of all reserved words, only "namespace" and "import" are
> allowed as class names in my patch
Sorry missed that. Somehow I thought this applies only to functions.
Anyway allowing some keywords as class/function names and other not
adds some inconsistency to the language IMHO.

> > […]
> The only reason for me is that "use" implies some kind of autoloading,
> as I suggested in one of my other mails.  This gets into parsing
> semantics, something I'm not interested in doing.
I guess it's the matter of background. To me "import" implies
autoloading where "use" doesn't.

> If the folks go with
> "use" that is fine, but for me personally not the best solution, which
> is why I put hours into making this patch.
>
> However, no matter what I definitely would like to see code written for
> PHP 5.2 and earlier that uses "import" or "namespace" as class names or
> functions continue to work in PHP 5.3.  "namespace" is used commonly for
> XML information (for obvious reasons), and import is a very common idea,
> as already stated.
I appreciate work but as I said above I think it adds inconsistency
and I think its not very good idea. I deffinetely agree that code
written for PHP 5.2 should continue to work in PHP 5.3. However this
patch is only one of possible solutions and it's up to you guys which
way to go.

Just a thought: maybe we should be discussing
namespace/name_space/something instead of import/use :-)

Just my 2 cents.

Giedrius

---

## #32952 — Sebastian Nohn — 2007-10-24T06:11:50+00:00

URL: https://externals.io/message/32916#32952 · In reply to: #32934

Gregory Beaver wrote:
> Giedrius D wrote:
> > […]

> > […]

> The only reason for me is that "use" implies some kind of autoloading,
> as I suggested in one of my other mails.  This gets into parsing
> semantics, something I'm not interested in doing.  If the folks go with
> "use" that is fine, but for me personally not the best solution, which
> is why I put hours into making this patch.

If I directly compare "use" with "import", "import" sounds way more like
"get me that stuff somehow magically" than "use" does.

- Sebastian

---

## #32967 — Marcus Boerger — 2007-10-24T15:48:42+00:00

URL: https://externals.io/message/32916#32967 · In reply to: #32952

Hello Sebastian,

  erm you are not going to use the stuff then?

marcus

Wednesday, October 24, 2007, 8:11:50 AM, you wrote:

> Gregory Beaver wrote:
> > […]

> > […]

> > […]

> If I directly compare "use" with "import", "import" sounds way more like
> "get me that stuff somehow magically" than "use" does.

> - Sebastian




Best regards,
 Marcus

---

## #32968 — Sebastian Nohn — 2007-10-24T17:53:46+00:00

URL: https://externals.io/message/32916#32968 · In reply to: #32967

Marcus Boerger wrote:
> Hello Sebastian,
> 
>   erm you are not going to use the stuff then?

Of course. I was just trying to explain what the plain words sound like.

> marcus
> 
> Wednesday, October 24, 2007, 8:11:50 AM, you wrote:
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 

- Sebastian

---

## #32969 — Sebastian Nohn — 2007-10-24T17:54:40+00:00

URL: https://externals.io/message/32916#32969 · In reply to: #32967

Marcus Boerger wrote:
> Hello Sebastian,
> 
>   erm you are not going to use the stuff then?

Of course. I was just trying to explain, what the plain words sound like
to me.

> marcus
> 
> Wednesday, October 24, 2007, 8:11:50 AM, you wrote:
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]

- Sebastian

---

## #32996 — Derick Rethans — 2007-11-01T08:24:25+00:00

URL: https://externals.io/message/32916#32996 · In reply to: #32916

Hei!



> Since many packages (wordpress, propel, horde, phing, etc.) use "import" as
> either class or function name, and we couldn't find a good solution to make it
> work with import keyword without going into all kinds of troublesome hacks, so
> we are thinking about replacing 'import' keyword with 'use' keyword, which is
> already reserved.

Is there any progress on this? It's also breaking code like:
	 const IMPORT = 3;


regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org
