Skip to content

Commit 092b05c

Browse files
committed
CS fixes: always use parentheses when instantiating a class
Includes selectively applying this to a few of the test fixtures to make them more syntax-varied without affecting their function.
1 parent 1b36205 commit 092b05c

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

Patchwork.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function relay(?array $args = null)
3636

3737
function fallBack()
3838
{
39-
throw new Exceptions\NoResult;
39+
throw new Exceptions\NoResult();
4040
}
4141

4242
function restore(CallRerouting\Handle $handle)

src/CallRerouting.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function instantiate(@parameters) {
7171
function connect($source, callable $target, ?Handle $handle = null, $partOfWildcard = false)
7272
{
7373
$source = translateIfLanguageConstruct($source);
74-
$handle = $handle ?: new Handle;
74+
$handle = $handle ?: new Handle();
7575
list($class, $method) = Utils\interpretCallable($source);
7676
if (constitutesWildcard($source)) {
7777
return applyWildcard($source, $target, $handle);
@@ -112,7 +112,7 @@ function constitutesWildcard($source)
112112

113113
function applyWildcard($wildcard, callable $target, ?Handle $handle = null)
114114
{
115-
$handle = $handle ?: new Handle;
115+
$handle = $handle ?: new Handle();
116116
list($class, $method, $instance) = Utils\interpretCallable($wildcard);
117117
if (!empty($instance)) {
118118
foreach (Utils\matchWildcard($method, get_class_methods($instance)) as $item) {
@@ -181,7 +181,7 @@ function inPreprocessedFile($callable)
181181

182182
function connectFunction($function, callable $target, ?Handle $handle = null)
183183
{
184-
$handle = $handle ?: new Handle;
184+
$handle = $handle ?: new Handle();
185185
$routes = &State::$routes[''][$function];
186186
$offset = Utils\append($routes, [$target, $handle]);
187187
$handle->addReference($routes[$offset]);
@@ -190,7 +190,7 @@ function connectFunction($function, callable $target, ?Handle $handle = null)
190190

191191
function queueConnection($source, callable $target, ?Handle $handle = null)
192192
{
193-
$handle = $handle ?: new Handle;
193+
$handle = $handle ?: new Handle();
194194
$offset = Utils\append(State::$queue, [$source, $target, $handle]);
195195
$handle->addReference(State::$queue[$offset]);
196196
return $handle;
@@ -213,7 +213,7 @@ function deployQueue()
213213

214214
function connectMethod($function, callable $target, ?Handle $handle = null)
215215
{
216-
$handle = $handle ?: new Handle;
216+
$handle = $handle ?: new Handle();
217217
list($class, $method, $instance) = Utils\interpretCallable($function);
218218
$target = new Decorator($target);
219219
$target->superclass = $class;
@@ -235,9 +235,9 @@ function connectMethod($function, callable $target, ?Handle $handle = null)
235235
function connectInstantiation($class, callable $target, ?Handle $handle = null)
236236
{
237237
if (!Config\isNewKeywordRedefinable()) {
238-
throw new Exceptions\NewKeywordNotRedefinable;
238+
throw new Exceptions\NewKeywordNotRedefinable();
239239
}
240-
$handle = $handle ?: new Handle;
240+
$handle = $handle ?: new Handle();
241241
$class = strtr($class, ['\\' => '__']);
242242
$routes = &State::$routes["Patchwork\\Instantiators\\$class"]['instantiate'];
243243
$offset = Utils\append($routes, [$target, $handle]);
@@ -318,7 +318,7 @@ function relay(?array $args = null)
318318

319319
$route = &State::$routes[$class][$method][$offset];
320320
$backup = $route;
321-
$route = ['Patchwork\fallBack', new Handle];
321+
$route = ['Patchwork\fallBack', new Handle()];
322322
$top = Stack\top();
323323
if ($args === null) {
324324
$args = $top['args'];
@@ -600,7 +600,7 @@ function getInstantiator($class, $calledClass)
600600
});
601601
}
602602
$instantiator = "$namespace\\$adaptedName";
603-
return new $instantiator;
603+
return new $instantiator();
604604
}
605605

606606
class State

src/CodeManipulation/Source.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function cache(array $args, \Closure $function)
303303
$result = &$this->cache;
304304
foreach (array_merge([$location], $args) as $step) {
305305
if (!is_scalar($step)) {
306-
throw new \LogicException;
306+
throw new \LogicException();
307307
}
308308
if (!isset($result[$step])) {
309309
$result[$step] = [];

src/CodeManipulation/Stream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function getOtherWrapper($context)
8282
{
8383
if (isset(static::$otherWrapperClass)) {
8484
$class = static::$otherWrapperClass;
85-
$otherWrapper = new $class;
85+
$otherWrapper = new $class();
8686
if ($context !== null) {
8787
$otherWrapper->context = $context;
8888
}

src/Stack.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function top($property = null)
5252
function topOffset()
5353
{
5454
if (empty(State::$items)) {
55-
throw new Exceptions\StackEmpty;
55+
throw new Exceptions\StackEmpty();
5656
}
5757
list($offset, $calledClass) = end(State::$items);
5858
return $offset;
@@ -61,7 +61,7 @@ function topOffset()
6161
function topCalledClass()
6262
{
6363
if (empty(State::$items)) {
64-
throw new Exceptions\StackEmpty;
64+
throw new Exceptions\StackEmpty();
6565
}
6666
list($offset, $calledClass) = end(State::$items);
6767
return $calledClass;
@@ -70,7 +70,7 @@ function topCalledClass()
7070
function topArgsOverride()
7171
{
7272
if (empty(State::$items)) {
73-
throw new Exceptions\StackEmpty;
73+
throw new Exceptions\StackEmpty();
7474
}
7575
list($offset, $calledClass, $argsOverride) = end(State::$items);
7676
return $argsOverride;

tests/includes/InheritanceWithAssertions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function getBar()
3737
Patchwork\CallRerouting\deployQueue();
3838

3939
$foo = new FooObject;
40-
$bar = new BarObject;
40+
$bar = new BarObject();
4141
$baz = new BazObject;
4242

4343
assert($foo->getFoo() === "foo");

tests/includes/RedefinitionOfNewWithUse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testMethod()
1919
return 'test2';
2020
});
2121

22-
$test = new TestClass;
22+
$test = new TestClass();
2323

2424
assert($test->testMethod() === 'test2');
2525
}

tests/includes/Singleton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static function getInstance()
66
{
77
static $instance = null;
88
if (!isset($instance)) {
9-
$instance = new self;
9+
$instance = new self();
1010
}
1111
return $instance;
1212
}

0 commit comments

Comments
 (0)