Marcus Boerger
21d32c2430
Fix ~ operator in class constants.
2003-05-29 19:27:11 +00:00
Sterling Hughes
0191ba5de1
allow expressions within constants, so the following is possible
...
class foo {
const a = 1<<0;
const b = 1<<1;
const c = a | b;
}
this makes const a compile-time expression. all other operators are
unaffected.
2003-04-10 15:43:47 +00:00
Zeev Suraski
65f06d8027
Revert Harald's commit
2003-04-10 04:43:42 +00:00
George Schlossnagle
dd090f4a77
One line fix so that it will compile
2003-04-10 03:11:27 +00:00
Harald Radi
07e775bcde
removing the *syntactical sugar* again
...
# commiting that on behalf of the community :)
# don't blame me, i'm just acting as a proxy
2003-04-09 20:23:06 +00:00
Andrei Zmievski
bdd3b6042c
Implement a different way to catch documentation comments.
2003-04-02 16:51:49 +00:00
Andrei Zmievski
e6255b06b1
Revert portions of the doc comment patch. There should be no parser
...
errors now.
2003-04-02 16:13:12 +00:00
Stanislav Malyshev
59af205988
Add __NAMESPACE__ auto-constant.
2003-04-01 09:22:41 +00:00
Andrei Zmievski
5657b83691
Multi-purpose patch:
...
- The fields of zend_namespace were not completely initialized which
led to a variety of problems.
- The occurrence of class/interface/namespace definition is now
captured.
- Functions/classes/interfaces/namespaces can be preceded by doc
comments which are stored for use by extensions.
2003-03-31 20:42:01 +00:00
Andrei Zmievski
52372c31cd
Since zend_do_begin_class_member_function_call assumes the previous
...
opcode is FETCH_CONSTANT, swap the calls around.
2003-03-30 18:51:04 +00:00
Stanislav Malyshev
43e87093c1
Un-nest namespaces - now namespace X { namespace Y {} } is a parse error
...
Also refine namespaced includes
2003-03-26 20:42:23 +00:00
Andrei Zmievski
39d5a63803
- Keep track of starting/ending line numbers for user functions.
...
- Store last parsed doc comment in a compiler global for future use.
2003-03-19 21:17:47 +00:00
Zeev Suraski
12cbee7b05
Optimize
2003-03-09 22:23:27 +00:00
Zeev Suraski
0eae231254
Fix handling of ::foo
2003-03-09 22:17:15 +00:00
Zeev Suraski
8bc88d8df4
Fix parsing rules of namespaces/classes
2003-03-09 20:53:57 +00:00
Zeev Suraski
a89abf9162
Add ability to use ::interface_name in implements
2003-03-09 17:07:15 +00:00
Zeev Suraski
0338111950
Require abstract classes to be explicitly declared 'abstract', in order to
...
avoid making developers traverse the entire class/interface hierarchy
before they can figure out whether a class is instantiable
(ok, so it makes sense :)
2003-03-06 22:53:23 +00:00
Zeev Suraski
ff76511a08
Add class type hints
2003-03-06 14:31:17 +00:00
Zeev Suraski
6ad2420d2d
Implement $obj::static_func()
2003-03-05 13:25:33 +00:00
Zeev Suraski
26dd8492ed
Add support for interfaces
2003-03-05 11:14:44 +00:00
Zeev Suraski
d5ada68654
Remove legacy code
2003-03-04 13:52:03 +00:00
Zeev Suraski
535aa63293
Add 'final'
2003-02-24 12:05:58 +00:00
Stanislav Malyshev
e645f20d07
Allow namespaces to have a number of parts. I.e., now you can do:
...
namespace foo {
function abc() {}
}
...
namespace foo {
functio def() {}
}
2003-02-20 19:01:53 +00:00
Zeev Suraski
827434c2a3
Whitespace & minor renames
2003-02-17 15:07:57 +00:00
Zeev Suraski
76c6d7e721
whitespace
2003-02-17 15:04:29 +00:00
Stanislav Malyshev
3e45b23799
add support for ::foo syntax meaning "global one"
2003-02-16 13:27:33 +00:00
Stanislav Malyshev
a4c3b2ce80
Namespace patch. Big changes:
...
1. Nested classes are gone.
2. New syntax for namespaces:
namespace foo {
class X { ... }
function bar { ... }
var x = 1;
const ZZ = 2;
}
3. Namespaced symbol access: $x = new foo::X; - etc.
For now, namespaces are case insensitive, just like classes.
Also, there can be no global class and namespace with the same name
(to avoid ambiguities in :: resolution).
2003-02-16 11:12:43 +00:00
Zeev Suraski
2814504143
Improve parser handling of 'abstract'
2003-02-11 09:48:37 +00:00
Zeev Suraski
6317e26576
- Treat $this->foo inside class X as an implicit 'public $foo' if X::$foo
...
is not explicitly declared
- Forbid multiple declaration of the same variable
2003-02-10 12:46:58 +00:00
foobar
333406bdc2
- Added some missing CVS $Id$ tags, headers and footers.
2003-02-01 01:49:15 +00:00
Andi Gutmans
c073b76aac
- Change "is" to "instanceof" as it explains better what the operator means.
...
- "is_a" was also appropriate but ugly.
2003-01-14 21:29:23 +00:00
Zeev Suraski
4bab4a7b55
Fix writability checks
2003-01-09 14:46:46 +00:00
Zeev Suraski
32b100e6cb
- Allow variables to have both 'static' modifier and an access level.
...
NOTE: This only works at the syntax level right now (parser). It
doesn't actually work as of yet - all statics are considered
public for now
- Prevent users from putting more restrictions on methods in derived classes
(i.e., you cannot make a public method private in a derived class, etc.)
2002-12-09 12:10:17 +00:00
Zeev Suraski
dc5c790a49
Treat the absence of an access type just as if 'public' was supplied
2002-12-08 14:09:43 +00:00
Zeev Suraski
e156edb1d0
Remove unintentional code
2002-12-07 15:52:08 +00:00
Zeev Suraski
e062dffe6c
- Implement public/protected/private methods.
...
- Prevent instantiation of classes with abstract methods.
Based in part on Marcus's patch.
2002-12-06 17:09:44 +00:00
Andi Gutmans
6aa90a75bd
- FN_IS_STATIC -> FN_STATIC
2002-11-24 20:32:49 +00:00
Andi Gutmans
e8214a3384
- Commit Marcus' cleanup of abstract and static inheritance and improve
...
- error messages
2002-11-23 20:44:12 +00:00
Andi Gutmans
227f7838d6
- Fix build (thanks Marcus)
...
- Implement abstract methods, syntax:
- abstract function foo($vars);
- I don't see any reason why modifiers such as static/public need to be
- used with abstract. PHP is weakly typed and there would be no meaning to
- this anyway. People who want a strictly typed compiled language are
- looking in the wrong place.
2002-11-20 18:00:23 +00:00
Stanislav Malyshev
830c2e0df6
fix statics - make it behave like $this (fetch type "static")
...
Side effect: indirect references to statics won't work.
2002-11-10 17:50:27 +00:00
Andi Gutmans
c497868005
- Add support for static methods. Basically methods which are defined as
...
- static don't have $this. That's the whole difference.
2002-11-05 19:37:31 +00:00
Andi Gutmans
983be5c73c
- ATTENTION: Finally nuke old_function and cfunction. I think it is time
...
- to get rid of these BC notations. This is from the days of the move from
- PHP/FI 2 -> PHP 3
2002-11-05 18:25:09 +00:00
Andi Gutmans
046bdeaaab
- Support new classname::$class_name, e.g.:
...
<?
class foo::bar {
public $hello = "Hello, World\n";
}
$name = "bar";
$obj = new foo::$name;
print $obj->hello;
?>
2002-10-14 20:13:03 +00:00
Ilia Alshanetsky
d3617c51b8
MFZE1 zend_str_tolower issue.
2002-10-09 14:21:40 +00:00
Andi Gutmans
aa7bffeec6
- Fix problem when crashing on illegal tokens in class name during class
...
- definition.
2002-10-01 20:00:45 +00:00
Ilia Alshanetsky
ee7b8f906d
MFZE1
2002-09-26 18:56:11 +00:00
Andi Gutmans
f78fa50423
- Megapatch to try and support inheritance from sub-classes. Things might
...
- be *very* buggy now so don't get too upset if that happens.
- I still need to improve some stuff but it's a good step (hopefully).
2002-09-24 19:05:53 +00:00
Andi Gutmans
8831b9cfd0
- MFZE1.
2002-09-23 17:20:59 +00:00
Jason Greene
b806a8e247
MFZE1 (use token instead of global for opcode counting)
2002-08-14 01:40:59 +00:00
Andi Gutmans
52406cb37c
- Make new 'is' operator work with classes only and return false when
...
- the object isn't of the said class or the value isn't an object.
2002-08-08 16:32:34 +00:00
Andrei Zmievski
82c72f2799
@- Adding 'is' operator that can be used to check the type of a variable,
...
@ or its class. (Andrei)
2002-07-30 04:07:15 +00:00
Andi Gutmans
9c52e883f0
- Rejuggle some code.
2002-07-17 18:36:29 +00:00
Andi Gutmans
bc5ea87e28
- Commit patch to support protected member variables (by Timm Friebe w/
...
- some fixes by me).
- You can't access protected variables from outside the object. If you want
- to see a protected member from your ancestors you need to declare the
- member as protected in the class you want to use it in. You can't
- redeclare a protected variable as private nor the other way around.
2002-07-15 18:09:56 +00:00
Andi Gutmans
7b68f5108a
- Nuke delete(). It was a big mistake to introduce it and I finally
...
- understand why Java didn't do so.
- If you still want to control destruction of your object then either make
- sure you kill all references or create a destruction method which you
- call yourself.
2002-07-14 19:23:18 +00:00
Sebastian Bergmann
c9f1c9c19f
Allow for 'class Namespace::Bar extends Foo' syntax. Patch by Timm Friebe <thekid@thekid.de>.
2002-07-07 08:22:23 +00:00
Zeev Suraski
0ae66bd659
spelling fix
2002-07-06 16:48:13 +00:00
Andi Gutmans
5f2fcdd689
- Add missing semi-colon.
2002-06-29 15:38:40 +00:00
Andi Gutmans
e2f57d0fcc
- MFZE1
2002-06-22 14:37:49 +00:00
Andi Gutmans
b2015c5610
- Fix problem with assigning functions by reference.
2002-06-11 17:33:53 +00:00
foobar
60ccb411ba
MFZE1
2002-04-10 21:23:01 +00:00
Andi Gutmans
e7100e22dc
- No idea how this slipped in. Fix delete $obj statement.
2002-03-21 04:20:03 +00:00
Andi Gutmans
a990c4da3e
- Finish covering all parsed methods to check for validity in parser.
...
- Change zval's refcount to zend_uint (If it doesn't slow down the Engine
- too much it should probably stay this way). If anyone has time to test
- the difference in speed between zend_ushort & zend_uint in zend.h of
- the struct _zval_struct (one line change) I'd be glad to get some
- figures.
2002-03-19 19:09:53 +00:00
Andi Gutmans
c5ad6ae1b8
- More fixes to check for member/function call legality.
2002-03-18 20:27:03 +00:00
Andi Gutmans
46afe61d25
- Start putting error handling where method calls are being used in a
...
- context where only writable variables should be used.
2002-03-17 19:13:46 +00:00
Andi Gutmans
b90d80b588
- Initial patch to support importing from class scopes (for Stig).
...
- It isn't complete yet but I want to work on it from another machine. It
- shouldn't break anything else so just don't try and use it.
- The following is a teaser of something that already works:
<?php
class MyClass
{
function hello()
{
print "Hello, World\n";
}
class MyClass2
{
function hello()
{
print "Hello, World in MyClass2\n";
}
}
}
import function hello, class MyClass2 from MyClass;
MyClass2::hello();
hello();
?>
2002-03-02 20:38:52 +00:00
Andi Gutmans
90bd4539c7
- Remove use of C++ reserved words namespace/this
2002-03-01 14:27:26 +00:00
Andi Gutmans
d1eea3de9c
- Fix bug in nested try/catch's
...
- Infrastructure for implementing imports of methods.
2002-03-01 14:04:51 +00:00
Andi Gutmans
00e90f2ff3
- Experimental support for private members.
...
<?
class MyClass {
private $Hello = "Hello, World!\n";
function printHello()
{
print $this->Hello;
}
}
class MyClass2 extends MyClass {
function printHello()
{
MyClass::printHello(); /* Should print */
print $this->Hello; /* Shouldn't print out anything */
}
}
$obj = new MyClass();
print $obj->Hello; /* Shouldn't print out anything */
$obj->printHello(); /* Should print */
$obj = new MyClass2();
print $obj->Hello; /* Shouldn't print out anything */
$obj->printHello();
?>
2002-02-21 11:50:44 +00:00
Andi Gutmans
21b04ff2a6
@ Allow a series of consecutive catch() statements (Andi, Zend Engine)
...
<?php
class MyException1 {
}
class MyException2 {
}
try {
throw new MyException2();
} catch (MyException1 $m) {
print "Caught MyException1";
} catch (MyException2 $m) {
print "Caught MyException2";
}
2002-02-13 19:26:07 +00:00
Andi Gutmans
2131b019c7
- Improve performance of functions that use $GLOBALS[]
...
- Please check this and make sure it doesn't break anything.
2002-01-20 20:42:15 +00:00
Thies C. Arntzen
a0ab80ab80
MFZE1
2002-01-19 10:35:51 +00:00
Andi Gutmans
f1e8815c26
- Change exception handling to use the Java-like catch(MyException $exception)
...
- semantics. Example:
<?php
class MyException {
function __construct($exception)
{
$this->exception = $exception;
}
function Display()
{
print "MyException: $this->exception\n";
}
}
class MyExceptionFoo extends MyException {
function __construct($exception)
{
$this->exception = $exception;
}
function Display()
{
print "MyException: $this->exception\n";
}
}
try {
throw new MyExceptionFoo("Hello");
} catch (MyException $exception) {
$exception->Display();
}
?>
2002-01-13 20:21:55 +00:00
Sebastian Bergmann
62dc854bb0
Happy New Year.
2002-01-06 15:21:36 +00:00
Andi Gutmans
ae1a702501
- Fix some case insensitivity stuff in respect to classes
2001-12-28 16:36:04 +00:00
Andi Gutmans
b14f6cf79f
- Support default arguments for reference parameters
...
- Fix two compile warnings
2001-12-28 13:28:33 +00:00
Andi Gutmans
2ce4b47657
- Initial support for _clone()
2001-12-26 17:49:22 +00:00
Andi Gutmans
f85c818fe8
- Start fixing the parsing rules so that function and method calls
...
- can't be used in a write context.
2001-12-26 14:46:18 +00:00
Andi Gutmans
e1e02af55b
- Revert delete syntax patch
2001-12-25 17:10:58 +00:00
Andi Gutmans
9e7c0d67d0
- Add initial capability of defining nested classes as class foo::bar
2001-12-22 15:31:44 +00:00
Andi Gutmans
1e56cac358
- Seems like most people prefer delete($obj) over delete $obj.
2001-12-16 19:53:06 +00:00
Andi Gutmans
ac7ed464b5
- Start adding parsed variable checks.
2001-12-16 19:45:49 +00:00
Andi Gutmans
880e7d8ce7
- Framework for knowing what kind of variable we just parsed.
...
- This will be used in compile-time error checking which couldn't be done
- at the level of the grammar.
2001-12-16 19:18:19 +00:00
Andi Gutmans
7c749c1897
- Rearrange grammar to allow dereferencing of objects returned from
...
- functions. It still crashes though.
2001-12-13 22:21:50 +00:00
Andi Gutmans
74efc41fc3
- Make classes have scope and function/constant lookups default to the class
2001-12-12 17:38:37 +00:00
Sebastian Bergmann
d863d52a5d
Update headers.
2001-12-11 15:16:21 +00:00
Andi Gutmans
3bfee898db
- More namespaces work.
...
- Nuke memory leak.
2001-12-10 18:57:17 +00:00
Andi Gutmans
42486196ad
- Initial work on changing namespace scope. Only methods & variables
...
- right now.
<?
$hey = "Global hey\n";
class foo {
static $hey = "Namespace hey\n";
function bar()
{
print "in foo::bar()\n";
}
}
function bar()
{
print "in bar()\n";
}
bar();
namespace foo;
bar();
namespace;
bar();
namespace foo;
$bar_indirect = "bar";
$bar_indirect();
namespace;
print $hey;
namespace foo;
print $hey;
$hey = "Namespace hey #2\n";
namespace;
print $hey;
$hey = "Global hey #2\n";
namespace foo;
print $hey;
?>
2001-12-06 17:47:04 +00:00
Andi Gutmans
fe94f59427
- Nuke the namespace work I did. It'll be redone differently.
2001-12-06 17:23:08 +00:00
Andi Gutmans
e858d27888
- Initial support for class constants. There are still a few semantic
...
- issues which need to be looked into but basically it seems to work.
- Example:
<?php
class foo
{
const hey = "hello";
}
print foo::hey;
?>
2001-11-30 16:29:47 +00:00
Andi Gutmans
f289014922
- Support syntax for class constants (doesn't do anything yet but
...
- required some reworking of the grammar).
2001-11-27 17:46:31 +00:00
Andi Gutmans
7cd6ccc0ec
- Support static $var = 0; style initialization of static class
...
- members. For example:
- class foo {
- static $my_static = 5;
-
- }
-
- print foo::$my_static;
2001-11-26 18:05:01 +00:00
Andi Gutmans
d2da63f629
- Support static members. The following script works:
...
<?
class foo
{
class bar
{
function init_values()
{
for ($i=1; $i<10; $i++) {
foo::bar::$hello[$i] = $i*$i;
}
}
function print_values()
{
for ($i=1; $i<10; $i++) {
print foo::bar::$hello[$i] . "\n";
}
}
}
}
foo::bar::init_values();
foo::bar::print_values();
for ($i=1; $i<10; $i++) {
print $hello[$i]?"Shouldn't be printed\n":"";
}
?>
2001-11-25 08:49:09 +00:00
Stig S. Bakken
9382ddec52
non-zts compile fix
2001-11-05 00:16:33 +00:00
Andi Gutmans
a332f826a7
- Support instantiation of nested class. The following script now should
...
- work:
-<?php
- class foo
- {
- function bar()
- {
- print "bar() in class bar\n";
- }
-
- class barbara
- {
- function bar()
- {
- print "bar() in class foo::barbara\n";
- }
- }
- }
-
- $obj = new foo();
- $obj->bar();
-
- $obj = new foo::barbara();
- $obj->bar();
-
2001-11-04 19:30:49 +00:00
Andi Gutmans
26578c386d
- Initial support for nested class definitions
2001-10-29 17:19:02 +00:00
Andi Gutmans
2eabb14dc7
- Merge the NAMESPACES_BRANCH. It wasn't a good idea to have a branch when
...
- the whole CVS tree is work in progress
2001-09-30 17:29:55 +00:00
Andi Gutmans
d7536a8a5f
- Shift around the variable parsing code to make it simpler.
2001-09-07 14:46:12 +00:00
Andi Gutmans
7c4a0cc6cf
- CLS_CC -> TSRMLS_CC
2001-09-03 16:57:49 +00:00
Andi Gutmans
29f5dbe10b
- Initial support for exceptions.
2001-08-30 15:26:30 +00:00
Zeev Suraski
4f6c95d17a
Whitespace
2001-08-11 15:56:40 +00:00