diff --git a/engine/compiler.c b/engine/compiler.c index b4340ff..a1d13b1 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -3833,8 +3833,8 @@ static sxi32 PH7_GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) { "Unexpected token '%z'. Expecting attribute or method declaration inside class '%z'", &pGen->pIn->sData, pName); } - /* Assume public visibility */ - iProtection = PH7_KEYWORD_PUBLIC; + /* Assume private visibility */ + iProtection = PH7_KEYWORD_PRIVATE; iAttrflags = 0; /* Extract the current keyword */ nKwrd = SX_PTR_TO_INT(pGen->pIn->pUserData); diff --git a/tests/anon_filter.aer b/tests/anon_filter.aer index bf94872..d13a2d9 100644 --- a/tests/anon_filter.aer +++ b/tests/anon_filter.aer @@ -13,16 +13,9 @@ class Program { return $filtered; } - void main() { + public void main() { int[] $filtered = $this->filter($this->condition, $this->numbers); var_dump($filtered); } } - - -/* - * Should output - -Array ( [0] => 897 [1] => 123 ) -*/ diff --git a/tests/array_subscription.aer b/tests/array_subscription.aer index 9aafec4..de1ca34 100644 --- a/tests/array_subscription.aer +++ b/tests/array_subscription.aer @@ -1,6 +1,6 @@ class Program { - int main() { + public int main() { int[] $arr1; int[] $arr2 = {0, 0}; float[] $arr3 = {1, 4.5}; diff --git a/tests/assertion_test.aer b/tests/assertion_test.aer index 97b2d52..ed0c5c1 100644 --- a/tests/assertion_test.aer +++ b/tests/assertion_test.aer @@ -4,7 +4,7 @@ class Program { assert("is_bool($param);"); } - void main() { + public void main() { callback $assert_fail = void(string $file, int $line, string $code) { print("Assertion failed ...\n"); }; diff --git a/tests/base32_test.aer b/tests/base32_test.aer index 5fd43f5..b4faf7c 100644 --- a/tests/base32_test.aer +++ b/tests/base32_test.aer @@ -68,7 +68,7 @@ class Base32 { } class Program { - void main() { + public void main() { var_dump(Base32::encode('Test String'), Base32::encode('DS27DEC985'), Base32::encode('AerScript rocks!')); var_dump(Base32::decode('KRSXG5BAKN2HE2LOM4======'), Base32::decode('IRJTEN2EIVBTSOBV'), Base32::decode('IFSXEU3DOJUXA5BAOJXWG23TEE======')); } diff --git a/tests/bin_format.aer b/tests/bin_format.aer index 5157ec8..58f8d1b 100644 --- a/tests/bin_format.aer +++ b/tests/bin_format.aer @@ -11,7 +11,7 @@ class Program { return ltrim($rtnval); } - void main() { + public void main() { var_dump($this->fmt_binary(2541)); } } diff --git a/tests/brainfuck_interpreter.aer b/tests/brainfuck_interpreter.aer index 6970a29..89c336e 100644 --- a/tests/brainfuck_interpreter.aer +++ b/tests/brainfuck_interpreter.aer @@ -78,7 +78,7 @@ class Brainfuck { class Program { - void main() { + public void main() { object $bf; string $code; resource $dir; diff --git a/tests/callback_function.aer b/tests/callback_function.aer index f0992f0..f804099 100644 --- a/tests/callback_function.aer +++ b/tests/callback_function.aer @@ -1,6 +1,6 @@ class Program { - void main(string[] $args) { + public void main(string[] $args) { callback $y = void() { callback $a = 'printf'; $a("I'm alive\n"); diff --git a/tests/center_text.aer b/tests/center_text.aer index a231121..387afd6 100644 --- a/tests/center_text.aer +++ b/tests/center_text.aer @@ -15,14 +15,9 @@ class Program { return $result; } - void main() { + public void main() { string $str = 'Example text'; print($this->center_text($str)); } } - - -/* Should output ----------------This is some text------------ -*/ diff --git a/tests/class_instance_arg.aer b/tests/class_instance_arg.aer index fea973e..d2a3446 100644 --- a/tests/class_instance_arg.aer +++ b/tests/class_instance_arg.aer @@ -7,12 +7,12 @@ class Test2 extends Test1 { class Program { object $t; - void test(Test1 $t = new Test2) { + private void test(Test1 $t = new Test2) { $this->t = $t; var_dump($this->t); } - void main() { + public void main() { $this->test(); } diff --git a/tests/closure_event.aer b/tests/closure_event.aer index 12627b3..1adab32 100644 --- a/tests/closure_event.aer +++ b/tests/closure_event.aer @@ -13,7 +13,7 @@ class Button { $this->DoAfterClick(); } - private void DoBeforeClick() { + private void DoBeforeClick() { if($this->OnBeforeClick) { callback $event = $this->OnBeforeClick; $event($this); @@ -31,7 +31,7 @@ class Button { class Program { - void main() { + public void main() { object $MyWidget = new Button(); $MyWidget->OnBeforeClick = void(object $Sender) { print($Sender->Name + ' (Before Click)'); }; $MyWidget->OnAfterClick = void(object $Sender) { print($Sender->Name + ' (After Click)'); }; diff --git a/tests/closure_test.aer b/tests/closure_test.aer index 6a753a4..d19b608 100644 --- a/tests/closure_test.aer +++ b/tests/closure_test.aer @@ -22,7 +22,7 @@ class Operations { class Program { - void main() { + public void main() { callback $fn; object $op = new Operations(); $fn = $op->ops(6, 7, 'ADD'); diff --git a/tests/complex_expressions.aer b/tests/complex_expressions.aer index 6f930fd..2f54010 100644 --- a/tests/complex_expressions.aer +++ b/tests/complex_expressions.aer @@ -24,7 +24,7 @@ class Program { return false; } - int main() { + public int main() { static float $f = 4 + 2.4 * 9.1; var_dump($this->MY_CONST); var_dump($this->callback_test); diff --git a/tests/complex_expressions2.aer b/tests/complex_expressions2.aer index 759e79c..f30b71a 100644 --- a/tests/complex_expressions2.aer +++ b/tests/complex_expressions2.aer @@ -1,12 +1,12 @@ class Program { - void test(int $a = (int(int $a, int $b, int $c){return $a+$b+$c;})(14, 10+2, 15), int $b = 0, int $c = 98) { + private void test(int $a = (int(int $a, int $b, int $c){return $a+$b+$c;})(14, 10+2, 15), int $b = 0, int $c = 98) { print($a + PHP_EOL); print($b + PHP_EOL); print($c + PHP_EOL); } - void main() { + public void main() { $this->test(); $this->test(512); $this->test(1024, 32); diff --git a/tests/constants_access.aer b/tests/constants_access.aer index dd4761c..4893d08 100644 --- a/tests/constants_access.aer +++ b/tests/constants_access.aer @@ -3,12 +3,12 @@ define TEST_CONSTANT 'This is a global constant'; class Program { const TEST_CONSTANT = 'This is a class constant'; - void constant_test() { + private void constant_test() { const TEST_CONSTANT = 'This is a local constant'; var_dump(TEST_CONSTANT); } - void main() { + public void main() { int $var = 69; var_dump(TEST_CONSTANT); $this->constant_test(); diff --git a/tests/debug_backtrace.aer b/tests/debug_backtrace.aer index c715c14..adb2e62 100644 --- a/tests/debug_backtrace.aer +++ b/tests/debug_backtrace.aer @@ -1,6 +1,6 @@ class Program { - void main() { + public void main() { $this->b($this->a('First A'), $this->a('Second A'), $this->a('Third A')); } diff --git a/tests/entry_point.aer b/tests/entry_point.aer index 029de8e..7f26d39 100644 --- a/tests/entry_point.aer +++ b/tests/entry_point.aer @@ -1,10 +1,10 @@ class Test1 { - void __construct() { + public void __construct() { print("Test1::__construct() called.\n"); } - void __destruct() { + public void __destruct() { print("Test1::__destruct() called.\n"); } @@ -12,12 +12,12 @@ class Test1 { class Test2 extends Test1 { - void __construct() { + public void __construct() { print("Test2::__construct() called.\n"); $parent->__construct(); } - void __destruct() { + public void __destruct() { print("Test2::__destruct() called.\n"); $parent->__destruct(); } @@ -27,16 +27,16 @@ class Test2 extends Test1 { class Program { object $test; - void __construct() { + public void __construct() { print("Program::__construct() called.\n"); $this->test = new Test1(); } - void __destruct() { + public void __destruct() { print("Program::__destruct() called.\n"); } - void main() { + public void main() { print("Program::main() called.\n"); object $test = new Test2(); } diff --git a/tests/exception_handler.aer b/tests/exception_handler.aer index 3d3a82f..af29f96 100644 --- a/tests/exception_handler.aer +++ b/tests/exception_handler.aer @@ -15,7 +15,7 @@ class NewException extends Exception { class Program { - void main() { + public void main() { callback $handler = void(Exception $e) { ExceptionHandler::handleException($e); }; diff --git a/tests/extended_closure.aer b/tests/extended_closure.aer index a84f94a..53e09bc 100644 --- a/tests/extended_closure.aer +++ b/tests/extended_closure.aer @@ -16,7 +16,7 @@ class Dog { class Program { - void main() { + public void main() { object $dog = new Dog('Alex', 'red'); callback $c = $dog->greet('Hello'); $c(); diff --git a/tests/factorial_test.aer b/tests/factorial_test.aer index e99b87a..78c1e4a 100644 --- a/tests/factorial_test.aer +++ b/tests/factorial_test.aer @@ -1,13 +1,13 @@ class Program { - int factorial(int $num) { + private int factorial(int $num) { if($num == 0 || $num == 1) return 1; else return $num * $this->factorial($num - 1); } - void main() { + public void main() { int $num = 7; print('Factorial of ', $num, ' is ', $this->factorial($num), '.'); } diff --git a/tests/factory_objects.aer b/tests/factory_objects.aer index c0a1c86..31daf3f 100644 --- a/tests/factory_objects.aer +++ b/tests/factory_objects.aer @@ -1,11 +1,11 @@ class Circle { - void draw() { + public void draw() { print("Circle\n"); } } class Square { - void draw() { + public void draw() { print("Square\n"); } } @@ -21,7 +21,7 @@ class Program { } } - void main() { + public void main() { $this->ShapeFactoryMethod("Circle")->draw(); $this->ShapeFactoryMethod("Square")->draw(); } diff --git a/tests/goto_statement.aer b/tests/goto_statement.aer index 24859b9..9c68628 100644 --- a/tests/goto_statement.aer +++ b/tests/goto_statement.aer @@ -1,6 +1,6 @@ class Test { - void goto_test1() { + public void goto_test1() { int $i = 0; a: print("Foo $i\n"); @@ -12,7 +12,7 @@ class Test { print("Bar $i\n\n"); } - void goto_test2(int $a = 2) { + public void goto_test2(int $a = 2) { switch($a) { case 1: print("\$a is 1\n\n"); @@ -30,7 +30,7 @@ class Test { out: } - void goto_test3() { + public void goto_test3() { int $a = 10; a: $a--; @@ -41,7 +41,7 @@ class Test { print("\n"); } - void goto_test4() { + public void goto_test4() { string[] $headers = {'subject', 'bcc', 'to', 'cc', 'date', 'sender'}; int $pos = 0; int $c; @@ -67,11 +67,11 @@ class Test { class Program { private object $test; - void __construct() { + public void __construct() { $this->test = new Test(); } - void main() { + public void main() { $this->test->goto_test1(); $this->test->goto_test2(); $this->test->goto_test3(); diff --git a/tests/int2alpha_test.aer b/tests/int2alpha_test.aer index 7f4a467..38e6bbe 100644 --- a/tests/int2alpha_test.aer +++ b/tests/int2alpha_test.aer @@ -1,6 +1,6 @@ class Program { - string num2alpha(int $n) { + private string num2alpha(int $n) { string $r = ''; for(int $i = 1; $n >= 0 && $i < 10; $i++) { $r = chr(0x41 + ($n % pow(26, $i) / pow(26, $i - 1))) + $r; @@ -9,7 +9,7 @@ class Program { return $r; } - int alpha2num(string $a) { + private int alpha2num(string $a) { int $r = 0; int $l = strlen($a); for(int $i = 0; $i < $l; $i++) { @@ -18,7 +18,7 @@ class Program { return (int) $r - 1; } - void main() { + public void main() { import('math'); var_dump($this->alpha2num("Salut"), $this->num2alpha(1723), $this->num2alpha(9854), $this->alpha2num("Base64")); } diff --git a/tests/ip_addr_enc_dec.aer b/tests/ip_addr_enc_dec.aer index 7ef807e..bee1a3f 100644 --- a/tests/ip_addr_enc_dec.aer +++ b/tests/ip_addr_enc_dec.aer @@ -10,7 +10,7 @@ class Program { return hexdec($hexipbang[0]) + '.' + hexdec($hexipbang[1]) + '.' + hexdec($hexipbang[2]) + '.' + hexdec($hexipbang[3]); } - void main() { + public void main() { string $localhost = $this->encode_ip('127.0.0.1'); print("127.0.0.1 ==> $localhost\n"); string $router = $this->encode_ip('192.168.2.1'); diff --git a/tests/load_module.aer b/tests/load_module.aer index 09a1f32..ecdb99a 100644 --- a/tests/load_module.aer +++ b/tests/load_module.aer @@ -1,5 +1,5 @@ final class Program { - void main() { + public void main() { var_dump(function_exists('dummy_function')); var_dump(import('dummy')); var_dump(function_exists('dummy_function')); diff --git a/tests/loop_foreach_test.aer b/tests/loop_foreach_test.aer index e042f59..9aa1b3a 100644 --- a/tests/loop_foreach_test.aer +++ b/tests/loop_foreach_test.aer @@ -1,6 +1,6 @@ class Program { - void main() { + public void main() { int[] $numbers = {'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'zero' => 0}; string[] $days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; foreach(string $key => int $numeric in $numbers) { diff --git a/tests/luhn_verify.aer b/tests/luhn_verify.aer index 861d927..5534f1f 100644 --- a/tests/luhn_verify.aer +++ b/tests/luhn_verify.aer @@ -1,15 +1,15 @@ class Luhn { private string $number; - string getNumber() { + public string getNumber() { return $this->number; } - void setNumber(string $number) { + public void setNumber(string $number) { $this->number = $number; } - bool validate() { + public bool validate() { string $sum; string $revNumber; int $len; @@ -26,7 +26,7 @@ class Luhn { class Program { private const NUMBERS = {'3788803280', '6487308345', '5443489710530865', '5539266155200609', '4024007151066296', '4345234978'}; - void main() { + public void main() { int $i, $nums = sizeof($this->NUMBERS); object $luhn = new Luhn(); diff --git a/tests/magic_method.aer b/tests/magic_method.aer index 76b888b..bc8591b 100644 --- a/tests/magic_method.aer +++ b/tests/magic_method.aer @@ -1,6 +1,6 @@ class Dog { - void __invoke() { + public void __invoke() { print("I am a dog!\n"); } } @@ -8,7 +8,7 @@ class Dog { class Program { - void main() { + public void main() { object $dog = new Dog(); $dog(); } diff --git a/tests/multiple_inheritance.aer b/tests/multiple_inheritance.aer index 6fc5a52..07129cf 100644 --- a/tests/multiple_inheritance.aer +++ b/tests/multiple_inheritance.aer @@ -53,7 +53,7 @@ class TestE { class Program extends TestE, TestD, TestC, TestB, TestA implements IntA, IntB { - void main() { + public void main() { $this->test_a(); $this->test_b(); $this->test_c(); diff --git a/tests/operators_precedence.aer b/tests/operators_precedence.aer index 92a53e3..19424bb 100644 --- a/tests/operators_precedence.aer +++ b/tests/operators_precedence.aer @@ -8,7 +8,7 @@ class Program { return {'callme' => void() { print("Hello world\n"); }}; } - void main() { + public void main() { callback[] $constr = {'print'}; print($this->testArray()['Machine'] + "\n"); $this->testCallback()['callme'](); diff --git a/tests/overloading_constructor.aer b/tests/overloading_constructor.aer index 0efab00..8773219 100644 --- a/tests/overloading_constructor.aer +++ b/tests/overloading_constructor.aer @@ -1,16 +1,16 @@ class Test { - void __construct(string $a) { + public void __construct(string $a) { print("$a\n"); } - void __construct(int $a, int $b) { + public void __construct(int $a, int $b) { print("$a + $b = ", $a + $b, "\n"); } } class Program { - void main() { + public void main() { object $a, $b; $a = new Test('Hello world!'); $b = new Test(4, 7); diff --git a/tests/overloading_methods.aer b/tests/overloading_methods.aer index aa2bfff..b864314 100644 --- a/tests/overloading_methods.aer +++ b/tests/overloading_methods.aer @@ -1,14 +1,14 @@ class Program { - void count(int $a, int $b) { + public void count(int $a, int $b) { print("Counting 2 integers: $a + $b = ", $a + $b, "\n"); } - void count(float $a, float $b) { + public void count(float $a, float $b) { print("Counting 2 floats: $a + $b = ", $a + $b, "\n"); } - void main() { + public void main() { $this->count(4.3, 5.7); $this->count(6, 4); } diff --git a/tests/pascal_triangle.aer b/tests/pascal_triangle.aer index bb635bd..dc3d429 100644 --- a/tests/pascal_triangle.aer +++ b/tests/pascal_triangle.aer @@ -8,7 +8,7 @@ class Program { return $result; } - void main() { + public void main() { int $z; int $y = 5; for(int $x = 0; $x < $y; $x++) { diff --git a/tests/path_split.aer b/tests/path_split.aer index 487115e..4c16d43 100644 --- a/tests/path_split.aer +++ b/tests/path_split.aer @@ -18,7 +18,7 @@ class Program { return $retArray; } - void main() { + public void main() { string $path = '/my//stupid//path/to///some/file.php'; print_r($this->parsePathComponents($path)); diff --git a/tests/reference_test.aer b/tests/reference_test.aer index 6a04776..1a42205 100644 --- a/tests/reference_test.aer +++ b/tests/reference_test.aer @@ -1,10 +1,10 @@ class Program { - void add_by_ref(int &$val) { + private void add_by_ref(int &$val) { $val += 7; } - void main() { + public void main() { int $num = 7; $this->add_by_ref($num); var_dump($num); diff --git a/tests/static_var.aer b/tests/static_var.aer index 1c3e6b1..4335ea0 100644 --- a/tests/static_var.aer +++ b/tests/static_var.aer @@ -1,6 +1,6 @@ class Program { - string cycle(char $a, char $b, int $i = 0) { + private string cycle(char $a, char $b, int $i = 0) { static bool[] $switches; if($switches[$i]) $switches[$i] = !$switches[$i]; @@ -9,7 +9,7 @@ class Program { return ($switches[$i]) ? $a : $b; } - void main() { + public void main() { for(int $i = 1; $i < 3; $i++) { print($i + $this->cycle('a', 'b') + PHP_EOL); for(int $j = 1; $j < 5; $j++) { diff --git a/tests/switch_block.aer b/tests/switch_block.aer index e009a20..df50480 100644 --- a/tests/switch_block.aer +++ b/tests/switch_block.aer @@ -1,6 +1,6 @@ class Program { - void main() { + public void main() { int $a = 1; switch($a) { case 0: diff --git a/tests/text_normalize.aer b/tests/text_normalize.aer index d5918bf..29b1ce9 100644 --- a/tests/text_normalize.aer +++ b/tests/text_normalize.aer @@ -14,7 +14,7 @@ class Program { return strtr($str, $table); } - void main() { + public void main() { var_dump($this->normalize("ÿĆ Welcome ÂëÑ Žöø Ŕ")); } diff --git a/tests/tokenizer.aer b/tests/tokenizer.aer index 6d922af..28d3d8f 100644 --- a/tests/tokenizer.aer +++ b/tests/tokenizer.aer @@ -24,7 +24,7 @@ class StringTokenizer { } class Program { - void main() { + public void main() { string $str = "This is:@\t\n a TEST!"; string $delim = " !@:\t\n"; object $st = new StringTokenizer($str, $delim); diff --git a/tests/type_hinting.aer b/tests/type_hinting.aer index 03942e1..d652520 100644 --- a/tests/type_hinting.aer +++ b/tests/type_hinting.aer @@ -26,7 +26,7 @@ class Program { var_dump(is_void($value)); } - void main() { + public void main() { object $objval; void $voidval; $this->testChar('c'); diff --git a/tests/type_juggle.aer b/tests/type_juggle.aer index d4f920c..02a68f9 100644 --- a/tests/type_juggle.aer +++ b/tests/type_juggle.aer @@ -1,6 +1,6 @@ class Program { - void main() { + public void main() { mixed $foo; $foo = '0'; var_dump($foo);