Commit Graph

257 Commits

Author SHA1 Message Date
Xinchen Hui
35951d4be0 Support list in foreach
RFC: https://wiki.php.net/rfc/foreachlist
2012-08-25 22:23:57 +08:00
Stanislav Malyshev
3336e1e78c Merge branch 'pull-request/31'
* pull-request/31:
  Fix lexing of nested heredoc strings in token_get_all()
2012-08-19 21:43:04 -07:00
Xinchen Hui
c64f4e736c Add functions declarations, use tabs 2012-08-14 08:59:40 +08:00
Xinchen Hui
80d5ae3cea Implemented 'finally' keywords for php
RFC: https://wiki.php.net/rfc/finally
FR: https://bugs.php.net/bug.php?id=32100
and I have got some improvment ideas(performance), will implemented
later. thanks
2012-08-13 21:48:39 +08:00
Xinchen Hui
ba568aaebb Fixed invalid read in CONST_STRING dereference, reported by Nikic 2012-07-26 00:29:39 +08:00
Xinchen Hui
a027ba3afe Merge branch 'PHP-5.4'
* PHP-5.4:
  Fixed bug #62357 (compile failure: (S) Arguments missing for built-in function __memcmp).
2012-06-26 18:50:52 +08:00
Xinchen Hui
a44a1dc194 Fixed bug #62357 (compile failure: (S) Arguments missing for built-in function __memcmp).
Any C library function may be a macro, We should avoid using ZEND_STRS(L) as their arguments
2012-06-26 18:42:33 +08:00
Nikita Popov
ec061a93c5 Allow arbitrary expressions for empty()
This change is as per RFC https://wiki.php.net/rfc/empty_isset_exprs.

The change allows passing the result of function calls and other
expressions to the empty() language construct. This is accomplished by
simply rewriting empty(expr) to !expr.

The change does not affect the suppression of errors when using empty()
on variables. empty($undefinedVar) will continue not to throw errors.
When an expression is used inside empty() on the other hand, errors will
not be suppressed. Thus empty($undefinedVar + $somethingElse) *will*
throw a notice.

The change also does not make empty() into a real function, so using
'empty' as a callback is still not possible.

In addition to the empty() changes the commit adds nicer error messages
when isset() is used on function call results or other expressions.
2012-05-13 14:56:51 +02:00
Xinchen Hui
565892d4c0 Implement const array/string dereference
RFC:https://wiki.php.net/rfc/constdereference
2012-04-17 10:06:17 +08:00
Nikita Popov
4cf90e06c9 Fix lexing of nested heredoc strings in token_get_all()
This fixes bug #60097.

Before two global variables CG(heredoc) and CG(heredoc_len) were used to
track the current heredoc label. In order to support nested heredoc
strings the *previous* heredoc label was assigned as the token value of
T_START_HEREDOC and the language_parser.y assigned that to CG(heredoc).

This created a dependency of the lexer on the parser. Thus the
token_get_all() function, which accesses the lexer directly without
also running the parser, was not able to tokenize nested heredoc strings
(and leaked memory). Same applies for the source-code highlighting
functions.

The new approach is to maintain a heredoc_label_stack in the lexer, which
contains all active heredoc labels.

As it is no longer required, T_START_HEREDOC and T_END_HEREDOC now don't
carry a token value anymore.

In order to make the work with zend_ptr_stack in this context more
convenient I added a new function zend_ptr_stack_top(), which retrieves the
top element of the stack (similar to zend_stack_top()).
2012-03-31 21:53:30 +02:00
Dmitry Stogov
b515bfbdfb Improved traits implementation. Now to support __CLASS__ constant in traits php doesn't have to copy the complete compiled method, but can reuse the same code. The resolution of __CLASS__ constants in methods defined in traits are delayed till run-time. This approach also made possible to use __CLASS__ constant as default value for traits properties and method arguments. 2012-01-17 08:09:13 +00:00
Dmitry Stogov
032d140fd6 Improved traits implementation. Now to support __CLASS__ constant in traits php doesn't have to copy the complete compiled method, but can reuse the same code. The resolution of __CLASS__ constants in methods defined in traits are delayed till run-time. This approach also made possible to use __CLASS__ constant as default value for traits properties and method arguments. 2012-01-17 08:09:13 +00:00
Felipe Pena
8775a37559 - Year++ 2012-01-01 13:15:04 +00:00
Felipe Pena
4e19825281 - Year++ 2012-01-01 13:15:04 +00:00
Felipe Pena
eebaaf423f - Added class member access on instantiation (e.g. (new foo)->bar()) support 2011-11-06 13:25:45 +00:00
Felipe Pena
ff48763f4b - Added class member access on instantiation (e.g. (new foo)->bar()) support 2011-11-06 13:25:45 +00:00
Felipe Pena
8db63e8874 - Drop T_SCALAR_CAST 2011-08-16 12:13:35 +00:00
Felipe Pena
17abf879ed - Drop T_SCALAR_CAST 2011-08-16 12:13:35 +00:00
Hannes Magnusson
306c42023e Callable typehint following the rules of is_callable($arg, false); 2011-08-16 10:44:47 +00:00
Hannes Magnusson
550980cfe5 Callable typehint following the rules of is_callable($arg, false); 2011-08-16 10:44:47 +00:00
Dmitry Stogov
ad4d6d1ce3 Added support for Class::{expr}() syntax (Pierrick) 2011-08-01 12:08:44 +00:00
Dmitry Stogov
74f68932b7 Added support for Class::{expr}() syntax (Pierrick) 2011-08-01 12:08:44 +00:00
Stefan Marr
0158804a15 Added __TRAIT__ magic constant [TRAITS] [DOC]
# __TRAIT__ behaves like __CLASS__ more or less but is constraint to traits.
# Since traits are not types, there are not many valid use cases, and trying
# to use __TRAIT__ to make traits more like classes is discouraged.
2011-07-31 17:39:30 +00:00
Stefan Marr
dbc6849bca Added __TRAIT__ magic constant [TRAITS] [DOC]
# __TRAIT__ behaves like __CLASS__ more or less but is constraint to traits.
# Since traits are not types, there are not many valid use cases, and trying
# to use __TRAIT__ to make traits more like classes is discouraged.
2011-07-31 17:39:30 +00:00
Pierre Joye
80496c9dc4 - add short array syntax as defined in https://wiki.php.net/rfc/shortsyntaxforarrays, 2nd solution using => only 2011-07-23 20:23:21 +00:00
Pierre Joye
cbe0ed86e7 - add short array syntax as defined in https://wiki.php.net/rfc/shortsyntaxforarrays, 2nd solution using => only 2011-07-23 20:23:21 +00:00
Felipe Pena
0fe6fd9e89 - Changed zend_resolve_class_name() prototype
# No needed to pass fetch_type as pointer here
2011-07-09 17:27:59 +00:00
Felipe Pena
70cacfd3a8 - Changed zend_resolve_class_name() prototype
# No needed to pass fetch_type as pointer here
2011-07-09 17:27:59 +00:00
Felipe Pena
0124c28610 - Fixed bug #55086 (Namespace alias does not work inside trait's use block)
patch by: Pierrick
2011-07-02 17:12:20 +00:00
Felipe Pena
d8e8e68f07 - Fixed bug #55086 (Namespace alias does not work inside trait's use block)
patch by: Pierrick
2011-07-02 17:12:20 +00:00
Felipe Pena
bcf7e60d4c - Fixed build on Windows 2011-06-24 00:38:53 +00:00
Felipe Pena
e9ce400f8b - Fixed build on Windows 2011-06-24 00:38:53 +00:00
Felipe Pena
72f7be3df0 - Improved parse error messages 2011-06-23 23:00:53 +00:00
Felipe Pena
0372e6ad80 - Improved parse error messages 2011-06-23 23:00:53 +00:00
Felipe Pena
80d432ca62 - Avoid zend_do_ticks() call for each statement in parsing 2011-06-12 01:43:10 +00:00
Felipe Pena
e613aae620 - Avoid zend_do_ticks() call for each statement in parsing 2011-06-12 01:43:10 +00:00
Stanislav Malyshev
e18618905c scalar types cleanup 2011-06-03 01:09:32 +00:00
Stanislav Malyshev
d7c9c5af92 scalar types cleanup 2011-06-03 01:09:32 +00:00
Stanislav Malyshev
516c2f5920 removing scalar types in trunk 2011-05-15 00:36:13 +00:00
Felipe Pena
0203cc3d44 - Year++ 2011-01-01 02:17:06 +00:00
Dmitry Stogov
2188f26c45 Fixed bug #52614 (Memory leak when writing on uninitialized variable returned from method call) 2010-08-25 09:14:36 +00:00
Felipe Pena
eb0ba9068d - Allow write context on array dereferencing from method return
- New tests
2010-06-12 16:11:10 +00:00
Felipe Pena
99c31b31ec - Added array dereferencing support [DOC]
# http://wiki.php.net/rfc/functionarraydereferencing
2010-06-08 00:05:29 +00:00
Ilia Alshanetsky
33fae4caa0 Added support for numeric & scalar type hint as defined within
http://wiki.php.net/rfc/typecheckingstrictandweak RFC
2010-05-24 18:32:59 +00:00
Derick Rethans
1bc9247651 - Added scalar typehinting. 2010-05-20 19:18:35 +00:00
Stefan Marr
cd6415f1a9 Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
# 
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
# 
# Internals of the Traits Patch
# -----------------------------
# 
# Open TODOs
# """"""""""
# 
# - Reflection API
# - support for traits for internal classes
#   - currently destroy_zend_class does not handle that case 
# 
# Introduced Structures
# """""""""""""""""""""
# 
# Data structures to encode the composition information specified in the
# source:
#  - zend_trait_method_reference
#  - zend_trait_precedence
#  - zend_trait_alias
# 
# Changes
# """""""
# 
# zend_class_entry
#  - uses NULL terminated lists of pointers for
#    - trait_aliases
#    - trait_precedences
#    - do you prefer an explicit counter?
#    - the information is only necessary during class composition
#      but might be interesting for reflection
#    - did not want to blow up class further with not really necessary length counters
# 
# added keywords
#   - trait
#   - insteadof
# 
# Added opcodes
#  ZEND_ADD_TRAIT
#    - similar to ZEND_ADD_INTERFACE
#    - adds the trait to the list of traits of a class, no actual composition done
#  ZEND_BIND_TRAITS
#    - emitted in zend_do_end_class_declaration
#    - concludes the class definition and will initiate the trait composition
#      when the class definition is encountered during runtime
# 
# Added Flags
#   ZEND_ACC_TRAIT = 0x120
#   ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
#   ZEND_FETCH_CLASS_TRAIT = 14
# 
# zend_vm_execute.h
#  - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
#    ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
# 
# zend_compile.c
#  - refactored do_inherit_method_check
#    split into do_inherit_method_check and do_inheritance_check_on_method
#  - added helper functions use a '_' as prefix and are not mentioned in the
#    headers
#  - _copy_functions
#    prepare hash-maps of functions which should be merged into a class
#    here the aliases are handled
#  - _merge_functions
#    builds a hash-table of the methods which need to be added to a class
#    does the conflict detection
#  - reused php_runkit_function_copy_ctor
#    - it is not identical with the original code anymore, needed to update it
#      think I fixed some bugs, not sure whether all have been reported back to runkit
#    - has to be renamed, left the name for the moment, to make its origin obvious
#    - here might be optimization potential
#    - not sure whether everything needs to be copied
#      - copying the literals might be broken
#        - added it since the literals array is freed by efree and gave problems
#          with doubled frees
#      - all immutable parts of the zend_op array should not be copied
#        - am not sure which parts are immutable
#        - and not sure how to avoid doubled frees on the same arrays on shutdown
#  - _merge_functions_to_class
#    does the final merging with the target class to handle inherited
#    and overridden methods
#  - small helper for NULL terminated lists
#    zend_init_list, zend_add_to_list
# 
# zend_language_parser.y
#  - reused class definition for traits
#    - there should be something with regard to properties
#      - if they get explicitly defined, it might be worthwhile to
#        check that there are no collisions with other traits in a composition
#        (however, I would not introduce elaborate language features to control that
#         but a notice for such conflicts might be nice to the developers)
2010-04-22 22:05:56 +00:00
Dmitry Stogov
453b49ed20 Added a number of small performance tweaks and optimizations
. ZEND_RECV now always has IS_CV as its result
  . ZEND_CATCH now has to be used only with constant class names
  . ZEND_FETCH_DIM_? may fetch array and dimension operans in a different order
2010-04-20 11:16:39 +00:00
Dmitry Stogov
94dd83722b Changed the structure of op_array.opcodes. The constant values are moved from opcode operands into a separate literal table 2010-04-20 10:57:45 +00:00
Stanislav Malyshev
c93a4f192b restore $this support for closures to its former glory 2010-04-19 19:45:03 +00:00
Sebastian Bergmann
3defe76254 sed -i "s#1998-2009#1998-2010#g" **/*.re **/*.y **/*.l 2010-01-05 20:40:23 +00:00