Skip to content
This repository was archived by the owner on Sep 9, 2019. It is now read-only.

Commit fbf1c28

Browse files
committed
Convert main code to PHP 5.4 syntax
1 parent 77a2afe commit fbf1c28

File tree

76 files changed

+557
-557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+557
-557
lines changed

src/main/php/xp/compiler/CompilationProfile.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* * Optimizations to apply
1111
*/
1212
class CompilationProfile extends \lang\Object {
13-
public $warnings= array();
14-
public $errors= array();
15-
public $optimizations= array();
13+
public $warnings= [];
14+
public $errors= [];
15+
public $optimizations= [];
1616

1717
/**
1818
* Add a check that will produce a warning

src/main/php/xp/compiler/CompilationProfileReader.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @test xp://net.xp_lang.tests.CompilationProfileReaderTest
99
*/
1010
class CompilationProfileReader extends \lang\Object {
11-
protected $sources= array();
11+
protected $sources= [];
1212

1313
/**
1414
* Add source properties

src/main/php/xp/compiler/JitClassLoader.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function packageContents($package) {
121121
// List directory contents, replacing compileable source files with
122122
// class file names. These of course don't exist yet, but will be
123123
// compiled on demand
124-
$return= array();
124+
$return= [];
125125
$dir= strtr($package, '.', DIRECTORY_SEPARATOR);
126126
foreach ($this->files->getSourcePaths() as $path) {
127127
if (!is_dir($d= $path.$dir.DIRECTORY_SEPARATOR)) continue;
@@ -189,15 +189,15 @@ public function loadClass0($class) {
189189
throw new ClassFormatException('Cannot compile '.$source->getURI().': '.$e->formattedErrors(''), $e);
190190
} catch (FormatException $e) {
191191
$this->debug && $e->printStackTrace();
192-
throw new JitCompilationError($class, array($this), $this->emitter->messages(), $e);
192+
throw new JitCompilationError($class, [$this], $this->emitter->messages(), $e);
193193
}
194194

195195
// Clean up
196196
unset($this->source[$class]);
197197

198198
// Define type
199199
$this->debug && fputs(STDERR, $r->type()->toString()."\n");
200-
$r->executeWith(array());
200+
$r->executeWith([]);
201201
\xp::$cl[$class]= $this->getClassName().'://'.$this->instanceId();
202202
return $r->type()->literal();
203203
}
@@ -240,7 +240,7 @@ public function instanceId() {
240240
* @return lang.IClassLoader
241241
*/
242242
public static function instanceFor($path, $debug= false) {
243-
static $pool= array();
243+
static $pool= [];
244244

245245
if (!isset($pool[$path.$debug])) {
246246
$pool[$path.$debug]= new self($path, $debug);

src/main/php/xp/compiler/Runner.class.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static function __static() {
9494
*/
9595
protected static function textOf($markup) {
9696
return strip_tags(preg_replace(
97-
array('#<pre>#', '#</pre>#', '#<li>#'),
98-
array(self::$line, self::$line, '* '),
97+
['#<pre>#', '#</pre>#', '#<li>#'],
98+
[self::$line, self::$line, '* '],
9999
trim($markup)
100100
));
101101
}
@@ -106,9 +106,9 @@ protected static function textOf($markup) {
106106
*/
107107
protected static function showUsage() {
108108
$class= new \lang\XPClass(__CLASS__);
109-
Console::$err->writeLine(strtr(self::textOf($class->getComment()), array(
109+
Console::$err->writeLine(strtr(self::textOf($class->getComment()), [
110110
'{{VERSION}}' => $class->getClassLoader()->getResource('VERSION')
111-
)));
111+
]));
112112

113113
// List supported syntaxes
114114
Console::$err->writeLine(self::$line);
@@ -135,7 +135,7 @@ protected static function fromFolder($uri, $recursive) {
135135
}
136136
}
137137

138-
$files= array();
138+
$files= [];
139139
$it= new FilteredIOCollectionIterator(new FileCollection($uri), $filter, $recursive);
140140
foreach ($it as $element) {
141141
$files[]= new FileSource(new File($element->getURI()));
@@ -150,7 +150,7 @@ protected static function fromFolder($uri, $recursive) {
150150
* @return xp.compiler.io.FileManager
151151
*/
152152
protected static function declaringFileManager() {
153-
return newinstance('xp.compiler.io.FileManager', array(), '{
153+
return newinstance('xp.compiler.io.FileManager', [], '{
154154
public $declared= array();
155155
public function write($r, \io\File $target) {
156156
$r->executeWith(array());
@@ -183,7 +183,7 @@ public static function main(array $args) {
183183
$profiles= ['default'];
184184
$emitter= 'php5.5';
185185
$result= function($success) { return $success ? 0 : 1; };
186-
$files= array();
186+
$files= [];
187187
$listener= new DefaultDiagnosticListener(Console::$out);
188188
for ($i= 0, $s= sizeof($args); $i < $s; $i++) {
189189
if ('-?' == $args[$i] || '--help' == $args[$i]) {
@@ -222,7 +222,7 @@ public static function main(array $args) {
222222
$manager= self::declaringFileManager();
223223
$result= function($success, $argv) use($manager) {
224224
if (!$success) return 1;
225-
return (int)$manager->declared[0]->getMethod('main')->invoke(null, array($argv));
225+
return (int)$manager->declared[0]->getMethod('main')->invoke(null, [$argv]);
226226
};
227227
break;
228228
} else if ('-w' == $args[$i]) {
@@ -231,7 +231,7 @@ public static function main(array $args) {
231231
$manager= self::declaringFileManager();
232232
$result= function($success, $argv) use($manager) {
233233
if (!$success) return 1;
234-
Console::writeLine($manager->declared[0]->getMethod('main')->invoke(null, array($argv)));
234+
Console::writeLine($manager->declared[0]->getMethod('main')->invoke(null, [$argv]));
235235
return 0;
236236
};
237237
break;

src/main/php/xp/compiler/Syntax.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Syntax base class
77
*/
88
abstract class Syntax extends \lang\Object {
9-
private static $syntaxes= array();
9+
private static $syntaxes= [];
1010
protected $parser= null;
1111
protected $name;
1212

src/main/php/xp/compiler/ast/AnnotationNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
*/
1616
class AnnotationNode extends Node {
1717
public $type = null;
18-
public $parameters = array();
18+
public $parameters = [];
1919
}

src/main/php/xp/compiler/ast/ArrayNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ArrayNode extends Node implements Resolveable {
2121
* @return var
2222
*/
2323
public function resolve() {
24-
$resolved= array();
24+
$resolved= [];
2525
foreach ($this->values as $i => $value) {
2626
if (!$value instanceof Resolveable) {
2727
throw new \lang\IllegalStateException('Value at offset '.$i.' is not resolveable: '.\xp::stringOf($value));

src/main/php/xp/compiler/ast/ConstructorNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class ConstructorNode extends RoutineNode {
77
public
88
$modifiers = 0,
9-
$parameters = array();
9+
$parameters = [];
1010

1111
/**
1212
* Returns this members's name

src/main/php/xp/compiler/ast/DoNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DoNode extends Node {
1919
* @param xp.compiler.ast.Node expression
2020
* @param xp.compiler.ast.Node[] statements
2121
*/
22-
public function __construct(Node $expression= null, $statements= array()) {
22+
public function __construct(Node $expression= null, $statements= []) {
2323
$this->expression= $expression;
2424
$this->statements= $statements;
2525
}

src/main/php/xp/compiler/ast/IndexerNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class IndexerNode extends TypeMemberNode {
2929
public $type= null;
3030
public $parameter= null;
31-
public $handlers= array();
31+
public $handlers= [];
3232

3333
/**
3434
* Returns this routine's name

0 commit comments

Comments
 (0)