Skip to content

Commit 52eb394

Browse files
committed
Apply "static_lambda" CS rule
1 parent 5ab5468 commit 52eb394

File tree

17 files changed

+31
-30
lines changed

17 files changed

+31
-30
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'php_unit_set_up_tear_down_visibility' => true,
2727
'php_unit_test_annotation' => false,
2828
'php_unit_test_case_static_method_calls' => true,
29+
'static_lambda' => true,
2930
'ternary_to_null_coalescing' => true,
3031
])
3132
->setFinder($finder)

example/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
'rootClose' => '',
6363
'childOpen' => '',
6464
'childClose' => '',
65-
'nodeDecorator' => function ($node) {
65+
'nodeDecorator' => static function ($node) {
6666
return str_repeat('-', $node['level']).$node['title'].PHP_EOL;
6767
},
6868
];

src/References/ReferencesListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function postLoad(EventArgs $eventArgs)
7878
$property->setValue(
7979
$object,
8080
new LazyCollection(
81-
function () use ($id, &$manager, $class, $identifier) {
81+
static function () use ($id, &$manager, $class, $identifier) {
8282
$results = $manager
8383
->getRepository($class)
8484
->findBy([
@@ -194,7 +194,7 @@ public function updateManyEmbedReferences(EventArgs $eventArgs)
194194
$property->setValue(
195195
$object,
196196
new LazyCollection(
197-
function () use ($id, &$manager, $class, $identifier) {
197+
static function () use ($id, &$manager, $class, $identifier) {
198198
$results = $manager
199199
->getRepository($class)
200200
->findBy([

src/Sluggable/SluggableListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private function generateSlug(SluggableAdapter $ea, $object)
344344
switch ($options['style']) {
345345
case 'camel':
346346
$quotedSeparator = preg_quote($options['separator']);
347-
$slug = preg_replace_callback('/^[a-z]|'.$quotedSeparator.'[a-z]/smi', function ($m) {
347+
$slug = preg_replace_callback('/^[a-z]|'.$quotedSeparator.'[a-z]/smi', static function ($m) {
348348
return strtoupper($m[0]);
349349
}, $slug);
350350
break;

src/Sortable/SortableListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ protected function addRelocation($hash, $class, $groups, $start, $stop, $delta,
563563

564564
try {
565565
$newDelta = ['start' => $start, 'stop' => $stop, 'delta' => $delta, 'exclude' => $exclude];
566-
array_walk($this->relocations[$hash]['deltas'], function (&$val, $idx, $needle) {
566+
array_walk($this->relocations[$hash]['deltas'], static function (&$val, $idx, $needle) {
567567
if ($val['start'] == $needle['start'] && $val['stop'] == $needle['stop']) {
568568
$val['delta'] += $needle['delta'];
569569
$val['exclude'] = array_merge($val['exclude'], $needle['exclude']);

src/Tool/Logging/DBAL/QueryAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private function generateSql($sql, $params, $types)
192192
$converted = $this->getConvertedParams($params, $types);
193193
if (is_int(key($params))) {
194194
$index = key($converted);
195-
$sql = preg_replace_callback('@\?@sm', function ($match) use (&$index, $converted) {
195+
$sql = preg_replace_callback('@\?@sm', static function ($match) use (&$index, $converted) {
196196
return $converted[$index++];
197197
}, $sql);
198198
} else {

src/Translatable/Query/TreeWalker/TranslationWalker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private function getTranslatableListener()
434434
private function replace(array $repl, $str)
435435
{
436436
foreach ($repl as $target => $result) {
437-
$str = preg_replace_callback('/(\s|\()('.$target.')(,?)(\s|\)|$)/smi', function ($m) use ($result) {
437+
$str = preg_replace_callback('/(\s|\()('.$target.')(,?)(\s|\)|$)/smi', static function ($m) use ($result) {
438438
return $m[1].$result.$m[3].$m[4];
439439
}, $str);
440440
}

src/Tree/Entity/Repository/ClosureTreeRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getPathQuery($node)
9797
*/
9898
public function getPath($node)
9999
{
100-
return array_map(function (AbstractClosure $closure) {
100+
return array_map(static function (AbstractClosure $closure) {
101101
return $closure->getAncestor();
102102
}, $this->getPathQuery($node)->getResult());
103103
}
@@ -175,7 +175,7 @@ public function children($node = null, $direct = false, $sortByField = null, $di
175175
{
176176
$result = $this->childrenQuery($node, $direct, $sortByField, $direction, $includeNode)->getResult();
177177
if ($node) {
178-
$result = array_map(function (AbstractClosure $closure) {
178+
$result = array_map(static function (AbstractClosure $closure) {
179179
return $closure->getDescendant();
180180
}, $result);
181181
}

src/Tree/Entity/Repository/MaterializedPathRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function getNodesHierarchy($node = null, $direct = false, array $options
269269
$nodes = $this->getNodesHierarchyQuery($node, $direct, $options, $includeNode)->getArrayResult();
270270
usort(
271271
$nodes,
272-
function ($a, $b) use ($path) {
272+
static function ($a, $b) use ($path) {
273273
return strcmp($a[$path], $b[$path]);
274274
}
275275
);

src/Tree/Entity/Repository/NestedTreeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ public function recover()
820820
$self = $this;
821821
$em = $this->_em;
822822

823-
$doRecover = function ($root, &$count, &$lvl) use ($meta, $config, $self, $em, &$doRecover) {
823+
$doRecover = static function ($root, &$count, &$lvl) use ($meta, $config, $self, $em, &$doRecover) {
824824
$lft = $count++;
825825
foreach ($self->getChildren($root, true) as $child) {
826826
$depth = ($lvl + 1);

0 commit comments

Comments
 (0)