[PHP] Update the lists of PHP keywords with new ones from PHP 5.4

and newer (and some missing ones from 5.3).  Reserved PHP constants
names are now checked against enum values and constants, instead
of against function and method names.  Built-in PHP function names
no longer match methods added by %extend.  Functions and methods
named '__sleep', '__wakeup', 'not', 'parent', or 'virtual' are no
longer needlessly renamed.
This commit is contained in:
Olly Betts 2014-02-19 17:21:34 +13:00
commit 06e5a5fb0d
2 changed files with 232 additions and 73 deletions

View file

@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.0 (in progress)
============================
2014-02-19: olly
[PHP] Update the lists of PHP keywords with new ones from PHP 5.4
and newer (and some missing ones from 5.3). Reserved PHP constants
names are now checked against enum values and constants, instead
of against function and method names. Built-in PHP function names
no longer match methods added by %extend. Functions and methods
named '__sleep', '__wakeup', 'not', 'parent', or 'virtual' are no
longer needlessly renamed.
2014-02-15: wsfulton
Fix the %$ismember %rename predicates to also apply to members added via %extend.

View file

@ -2,37 +2,41 @@
* phpkw.swg
* ----------------------------------------------------------------------------- */
/* Keyword (case insensitive) */
#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x`
/* Class (case insensitive) */
#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, renaming to 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x`
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
/* Constant (case insensitive) */
#define PHPBN1a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem,sourcefmt="%(lower)s") `x`
#define PHPBN1b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant,sourcefmt="%(lower)s") `x`
%define PHPBN1(X)
PHPBN1a(X); PHPBN1b(X)
%enddef
/*
From
/* Constant (case sensitive) */
#define PHPBN2a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem) `x`
#define PHPBN2b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant) `x`
%define PHPBN2(X)
PHPBN2a(X); PHPBN2b(X)
%enddef
http://aspn.activestate.com/ASPN/docs/PHP/reserved.html
http://php.net/manual/en/reserved.keywords.php
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
and reviewed by Olly Betts.
Further updates from the PHP manual on php.net.
*/
/* We classify these as kw since PHP will not run if used globally. */
/* "You cannot use any of the following words as constants, class names,
/* From: http://php.net/manual/en/reserved.keywords.php
* "You cannot use any of the following words as constants, class names,
* function or method names. Using them as variable names is generally OK, but
* could lead to confusion."
*/
/* case insensitive */
/* Check is case insensitive - these *MUST* be listed in lower case here */
PHPKW(__halt_compiler);
PHPKW(abstract);
PHPKW(and);
PHPKW(array);
PHPKW(as);
PHPKW(break);
PHPKW(callable); // As of PHP 5.4
PHPKW(case);
PHPKW(catch);
PHPKW(class);
@ -57,20 +61,22 @@ PHPKW(eval); // "Language construct"
PHPKW(exit); // "Language construct"
PHPKW(extends);
PHPKW(final);
PHPKW(finally); // As of PHP 5.5
PHPKW(for);
PHPKW(foreach);
PHPKW(function);
PHPKW(global);
PHPKW(goto); // As of PHP5.3
PHPKW(goto); // As of PHP 5.3
PHPKW(if);
PHPKW(implements);
PHPKW(include); // "Language construct"
PHPKW(include_once); // "Language construct"
PHPKW(instanceof);
PHPKW(insteadof); // As of PHP 5.4
PHPKW(interface);
PHPKW(isset); // "Language construct"
PHPKW(list); // "Language construct"
PHPKW(namespace); // As of PHP5.3
PHPKW(namespace); // As of PHP 5.3
PHPKW(new);
PHPKW(or);
PHPKW(print); // "Language construct"
@ -83,39 +89,70 @@ PHPKW(return); // "Language construct"
PHPKW(static);
PHPKW(switch);
PHPKW(throw);
PHPKW(trait); // As of PHP 5.4
PHPKW(try);
PHPKW(unset); // "Language construct"
PHPKW(use);
PHPKW(var);
PHPKW(while);
PHPKW(xor);
// Compile-time constants
PHPKW(__CLASS__);
PHPKW(__DIR__); // As of PHP5.3
PHPKW(__FILE__);
PHPKW(__FUNCTION__);
PHPKW(__METHOD__);
PHPKW(__NAMESPACE__); // As of PHP5.3
PHPKW(__LINE__);
PHPKW(yield); // As of PHP 5.5
// Compile-time "magic" constants
// From: http://php.net/manual/en/reserved.keywords.php
// also at: http://php.net/manual/en/language.constants.predefined.php
/* These *MUST* be listed in lower case here */
PHPKW(__class__);
PHPKW(__dir__); // As of PHP 5.3
PHPKW(__file__);
PHPKW(__function__);
PHPKW(__line__);
PHPKW(__method__);
PHPKW(__namespace__); // As of PHP 5.3
PHPKW(__trait__); // As of PHP 5.4
/* We classify these as built-in names since they conflict, but PHP still runs */
/* Type 1: case insensitive */
PHPBN1(__sleep);
PHPBN1(__wakeup);
PHPBN1(not);
PHPBN1(parent);
PHPBN1(virtual);
PHPBN1(NULL);
PHPBN1(TRUE);
PHPBN1(FALSE);
/* Predefined case-insensitive constants */
/* These *MUST* be listed in lower case here */
PHPBN1(null);
PHPBN1(true);
PHPBN1(false);
/* Type 2: case sensitive */
/* "Core Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */
PHPBN2(E_ALL);
/* "Core Predefined Constants" from http://php.net/manual/en/reserved.constants.php */
/* These are case sensitive */
PHPBN2(PHP_VERSION);
PHPBN2(PHP_MAJOR_VERSION); // As of PHP 5.2.7
PHPBN2(PHP_MINOR_VERSION); // As of PHP 5.2.7
PHPBN2(PHP_RELEASE_VERSION); // As of PHP 5.2.7
PHPBN2(PHP_VERSION_ID); // As of PHP 5.2.7
PHPBN2(PHP_EXTRA_VERSION); // As of PHP 5.2.7
PHPBN2(PHP_ZTS); // As of PHP 5.2.7
PHPBN2(PHP_DEBUG); // As of PHP 5.2.7
PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3.0
PHPBN2(PHP_OS);
PHPBN2(PHP_SAPI);
PHPBN2(PHP_EOL); // As of PHP 5.0.2
PHPBN2(PHP_INT_MAX); // As of PHP 5.0.5
PHPBN2(PHP_INT_SIZE); // As of PHP 5.0.5
PHPBN2(DEFAULT_INCLUDE_PATH);
PHPBN2(PEAR_INSTALL_DIR);
PHPBN2(PEAR_EXTENSION_DIR);
PHPBN2(PHP_EXTENSION_DIR);
PHPBN2(PHP_PREFIX);
PHPBN2(PHP_BINDIR);
PHPBN2(PHP_BINARY); // As of PHP 5.4
PHPBN2(PHP_MANDIR); // As of PHP 5.3.7
PHPBN2(PHP_LIBDIR);
PHPBN2(PHP_DATADIR);
PHPBN2(PHP_SYSCONFDIR);
PHPBN2(PHP_LOCALSTATEDIR);
PHPBN2(PHP_CONFIG_FILE_PATH);
PHPBN2(PHP_CONFIG_FILE_SCAN_DIR);
PHPBN2(PHP_SHLIB_SUFFIX);
PHPBN2(E_ERROR);
PHPBN2(E_PARSE);
PHPBN2(E_WARNING);
PHPBN2(E_PARSE);
PHPBN2(E_NOTICE);
PHPBN2(E_CORE_ERROR);
PHPBN2(E_CORE_WARNING);
@ -124,31 +161,17 @@ PHPBN2(E_COMPILE_WARNING);
PHPBN2(E_USER_ERROR);
PHPBN2(E_USER_WARNING);
PHPBN2(E_USER_NOTICE);
PHPBN2(E_DEPRECATED); // As of PHP 5.3
PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3
PHPBN2(PHP_OS);
PHPBN2(PHP_VERSION);
PHPBN2(PHP_SAPI);
PHPBN2(PHP_EOL);
PHPBN2(PHP_INT_MAX);
PHPBN2(PHP_INT_SIZE);
PHPBN2(DEFAULT_INCLUDE_PATH);
PHPBN2(PEAR_INSTALL_DIR);
PHPBN2(PEAR_EXTENSION_DIR);
PHPBN2(PHP_EXTENSION_DIR);
PHPBN2(PHP_PREFIX);
PHPBN2(PHP_BINDIR);
PHPBN2(PHP_LIBDIR);
PHPBN2(PHP_DATADIR);
PHPBN2(PHP_SYSCONFDIR);
PHPBN2(PHP_LOCALSTATEDIR);
PHPBN2(PHP_CONFIG_FILE_PATH);
PHPBN2(PHP_CONFIG_FILE_SCAN_DIR);
PHPBN2(PHP_SHLIB_SUFFIX);
PHPBN2(E_DEPRECATED); // As of PHP 5.3.0
PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3.0
PHPBN2(E_ALL);
PHPBN2(E_STRICT);
PHPBN2(__COMPILER_HALT_OFFSET__); // As of PHP 5.1.0
// TRUE, FALSE, NULL are listed on the same page, but are actually
// case-insensitive, whereas all the other constants listed there seem to be
// case-sensitive, so we handle TRUE, FALSE, NULL in PHPBN1.
PHPBN2(PHP_OUTPUT_HANDLER_START);
PHPBN2(PHP_OUTPUT_HANDLER_CONT);
PHPBN2(PHP_OUTPUT_HANDLER_END);
PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3
/* These don't actually seem to be set (tested on Linux, I guess they're
* Windows only?) */
PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3
@ -162,7 +185,7 @@ PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3
PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3
PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3
PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3
/* "Standard Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */
/* "Standard Predefined Constants" from http://php.net/manual/en/reserved.constants.php */
PHPBN2(EXTR_OVERWRITE);
PHPBN2(EXTR_SKIP);
PHPBN2(EXTR_PREFIX_SAME);
@ -370,10 +393,6 @@ PHPBN2(LOG_NDELAY);
PHPBN2(LOG_NOWAIT);
PHPBN2(LOG_PERROR);
/* Added in PHP5 */
PHPBN2(E_STRICT);
PHPBN2(__COMPILER_HALT_OFFSET__);
/* Added in PHP 5.2 */
PHPBN2(PREG_BACKTRACK_LIMIT_ERROR);
PHPBN2(PREG_BAD_UTF8_ERROR);
@ -485,17 +504,143 @@ PHPBN2(SIG_UNBLOCK);
PHPBN2(TRAP_BRKPT);
PHPBN2(TRAP_TRACE);
/* Class names reserved by PHP */
/* case insensitive */
/* Added in PHP 5.4 */
PHPBN2(ENT_DISALLOWED);
PHPBN2(ENT_HTML401);
PHPBN2(ENT_HTML5);
PHPBN2(ENT_SUBSTITUTE);
PHPBN2(ENT_XML1);
PHPBN2(ENT_XHTML);
PHPBN2(IPPROTO_IP);
PHPBN2(IPPROTO_IPV6);
PHPBN2(IPV6_MULTICAST_HOPS);
PHPBN2(IPV6_MULTICAST_IF);
PHPBN2(IPV6_MULTICAST_LOOP);
PHPBN2(IP_MULTICAST_IF);
PHPBN2(IP_MULTICAST_LOOP);
PHPBN2(IP_MULTICAST_TTL);
PHPBN2(MCAST_JOIN_GROUP);
PHPBN2(MCAST_LEAVE_GROUP);
PHPBN2(MCAST_BLOCK_SOURCE);
PHPBN2(MCAST_UNBLOCK_SOURCE);
PHPBN2(MCAST_JOIN_SOURCE_GROUP);
PHPBN2(MCAST_LEAVE_SOURCE_GROUP);
PHPBN2(CURLOPT_MAX_RECV_SPEED_LARGE);
PHPBN2(CURLOPT_MAX_SEND_SPEED_LARGE);
PHPBN2(LIBXML_HTML_NODEFDTD);
PHPBN2(LIBXML_HTML_NOIMPLIED);
PHPBN2(LIBXML_PEDANTIC);
PHPBN2(OPENSSL_CIPHER_AES_128_CBC);
PHPBN2(OPENSSL_CIPHER_AES_192_CBC);
PHPBN2(OPENSSL_CIPHER_AES_256_CBC);
PHPBN2(OPENSSL_RAW_DATA);
PHPBN2(OPENSSL_ZERO_PADDING);
PHPBN2(PHP_OUTPUT_HANDLER_CLEAN);
PHPBN2(PHP_OUTPUT_HANDLER_CLEANABLE);
PHPBN2(PHP_OUTPUT_HANDLER_DISABLED);
PHPBN2(PHP_OUTPUT_HANDLER_FINAL);
PHPBN2(PHP_OUTPUT_HANDLER_FLUSH);
PHPBN2(PHP_OUTPUT_HANDLER_FLUSHABLE);
PHPBN2(PHP_OUTPUT_HANDLER_REMOVABLE);
PHPBN2(PHP_OUTPUT_HANDLER_STARTED);
PHPBN2(PHP_OUTPUT_HANDLER_STDFLAGS);
PHPBN2(PHP_OUTPUT_HANDLER_WRITE);
PHPBN2(PHP_SESSION_ACTIVE);
PHPBN2(PHP_SESSION_DISABLED);
PHPBN2(PHP_SESSION_NONE);
PHPBN2(STREAM_META_ACCESS);
PHPBN2(STREAM_META_GROUP);
PHPBN2(STREAM_META_GROUP_NAME);
PHPBN2(STREAM_META_OWNER);
PHPBN2(STREAM_META_OWNER_NAME);
PHPBN2(STREAM_META_TOUCH);
PHPBN2(ZLIB_ENCODING_DEFLATE);
PHPBN2(ZLIB_ENCODING_GZIP);
PHPBN2(ZLIB_ENCODING_RAW);
PHPBN2(U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR);
PHPBN2(IDNA_CHECK_BIDI);
PHPBN2(IDNA_CHECK_CONTEXTJ);
PHPBN2(IDNA_NONTRANSITIONAL_TO_ASCII);
PHPBN2(IDNA_NONTRANSITIONAL_TO_UNICODE);
PHPBN2(INTL_IDNA_VARIANT_2003);
PHPBN2(INTL_IDNA_VARIANT_UTS46);
PHPBN2(IDNA_ERROR_EMPTY_LABEL);
PHPBN2(IDNA_ERROR_LABEL_TOO_LONG);
PHPBN2(IDNA_ERROR_DOMAIN_NAME_TOO_LONG);
PHPBN2(IDNA_ERROR_LEADING_HYPHEN);
PHPBN2(IDNA_ERROR_TRAILING_HYPHEN);
PHPBN2(IDNA_ERROR_HYPHEN_3_4);
PHPBN2(IDNA_ERROR_LEADING_COMBINING_MARK);
PHPBN2(IDNA_ERROR_DISALLOWED);
PHPBN2(IDNA_ERROR_PUNYCODE);
PHPBN2(IDNA_ERROR_LABEL_HAS_DOT);
PHPBN2(IDNA_ERROR_INVALID_ACE_LABEL);
PHPBN2(IDNA_ERROR_BIDI);
PHPBN2(IDNA_ERROR_CONTEXTJ);
PHPBN2(JSON_PRETTY_PRINT);
PHPBN2(JSON_UNESCAPED_SLASHES);
PHPBN2(JSON_NUMERIC_CHECK);
PHPBN2(JSON_UNESCAPED_UNICODE);
PHPBN2(JSON_BIGINT_AS_STRING);
/* Added in PHP 5.5 */
PHPBN2(IMG_AFFINE_TRANSLATE);
PHPBN2(IMG_AFFINE_SCALE);
PHPBN2(IMG_AFFINE_ROTATE);
PHPBN2(IMG_AFFINE_SHEAR_HORIZONTAL);
PHPBN2(IMG_AFFINE_SHEAR_VERTICAL);
PHPBN2(IMG_CROP_DEFAULT);
PHPBN2(IMG_CROP_TRANSPARENT);
PHPBN2(IMG_CROP_BLACK);
PHPBN2(IMG_CROP_WHITE);
PHPBN2(IMG_CROP_SIDES);
PHPBN2(IMG_FLIP_BOTH);
PHPBN2(IMG_FLIP_HORIZONTAL);
PHPBN2(IMG_FLIP_VERTICAL);
PHPBN2(IMG_BELL);
PHPBN2(IMG_BESSEL);
PHPBN2(IMG_BICUBIC);
PHPBN2(IMG_BICUBIC_FIXED);
PHPBN2(IMG_BLACKMAN);
PHPBN2(IMG_BOX);
PHPBN2(IMG_BSPLINE);
PHPBN2(IMG_CATMULLROM);
PHPBN2(IMG_GAUSSIAN);
PHPBN2(IMG_GENERALIZED_CUBIC);
PHPBN2(IMG_HERMITE);
PHPBN2(IMG_HAMMING);
PHPBN2(IMG_HANNING);
PHPBN2(IMG_MITCHELL);
PHPBN2(IMG_POWER);
PHPBN2(IMG_QUADRATIC);
PHPBN2(IMG_SINC);
PHPBN2(IMG_NEAREST_NEIGHBOUR);
PHPBN2(IMG_WEIGHTED4);
PHPBN2(IMG_TRIANGLE);
PHPBN2(JSON_ERROR_RECURSION);
PHPBN2(JSON_ERROR_INF_OR_NAN);
PHPBN2(JSON_ERROR_UNSUPPORTED_TYPE);
PHPBN2(MYSQLI_SERVER_PUBLIC_KEY);
/* Added in PHP 5.6 */
PHPBN2(LDAP_ESCAPE_DN);
PHPBN2(LDAP_ESCAPE_FILTER);
/* Class names reserved by PHP (case insensitive) */
PHPCN(directory);
PHPCN(stdclass);
PHPCN(__php_incomplete_class);
PHPCN(directory);
/* Added in PHP5 (this list apparently depends which extensions you load by default). */
PHPCN(parent);
PHPCN(self);
/* Added in PHP5. */
PHPCN(exception);
PHPCN(errorexception); // As of PHP 5.1
PHPCN(php_user_filter);
PHPCN(errorexception);
PHPCN(closure); // As of PHP 5.3
PHPCN(generator); // As of PHP 5.5
PHPCN(self);
PHPCN(static);
PHPCN(parent);
/* From extensions (which of these are actually predefined depends which
* extensions are loaded by default). */
PHPCN(xmlwriter);
PHPCN(libxmlerror);
PHPCN(simplexmlelement);
@ -588,7 +733,8 @@ PHPCN(sqliteexception);
PHPCN(datetime);
/* Built-in PHP functions (incomplete). */
/* Includes Array Functions - http://us3.php.net/manual/en/ref.array.php */
/* Includes Array Functions - http://php.net/manual/en/ref.array.php */
/* Check is case insensitive - these *MUST* be listed in lower case here */
PHPFN(acos);
PHPFN(array_change_key_case);
PHPFN(array_chunk);
@ -688,7 +834,11 @@ PHPFN(uksort);
PHPFN(usort);
#undef PHPKW
#undef PHPBN1a
#undef PHPBN1b
#undef PHPBN1
#undef PHPBN2a
#undef PHPBN2b
#undef PHPBN2
#undef PHPCN
#undef PHPFN