Skip to content

Commit e3adb8b

Browse files
committed
Merge branch 'refs/heads/4.x' into fix-issue-186
2 parents 2bc2756 + 8c9107d commit e3adb8b

File tree

36 files changed

+63
-43
lines changed

36 files changed

+63
-43
lines changed

src/Twig/TwigEnvironment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function tokenize(Source $source): TokenStream {
6565
public static function sortNamespaces(string $input): string {
6666
$lines = \explode(\PHP_EOL, $input);
6767
$lines = \array_unique($lines);
68-
\sort($lines, \SORT_FLAG_CASE | \SORT_NATURAL);
68+
\usort($lines, 'strcmp');
6969
return \trim(\implode(\PHP_EOL, $lines)) . \PHP_EOL;
7070
}
7171

src/Twig/TwigSortSetNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function compile(Compiler $compiler): void {
2525
->raw(";\n")
2626
->write('$data = explode("\n", $data);' . "\n")
2727
->write('$data = array_unique($data);' . "\n")
28-
->write('sort($data, SORT_FLAG_CASE|SORT_NATURAL);' . "\n")
28+
->write('usort($data, "strcmp");' . "\n")
2929
->write('yield ltrim(implode("\n", $data)) . "\n";' . "\n");
3030
}
3131

src/Twig/TwigSortTokenParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function parse(Token $token): Node {
3434
$ref->setAttribute('always_defined', TRUE);
3535

3636
return new Node([
37-
new SetNode(TRUE, $ref, $body, $lineno, $this->getTag()),
38-
new TwigSortSetNode(['ref' => $ref], [], $lineno, $this->getTag()),
37+
new SetNode(TRUE, $ref, $body, $lineno),
38+
new TwigSortSetNode(['ref' => $ref], [], $lineno),
3939
]);
4040
}
4141

templates/Plugin/Migrate/_destination/destination.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ final class {{ class }} extends DestinationBase {% if services %}implements Cont
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function fields(MigrationInterface $migration = NULL): array {
75+
public function fields(?MigrationInterface $migration = NULL): array {
7676
return [
7777
'id' => $this->t('The row ID.'),
7878
// @todo Describe row fields here.

templates/Plugin/_action/action.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ final class {{ class }} extends {{ configurable ? 'ConfigurableActionBase' : 'Ac
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
110+
public function access($entity, ?AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
111111
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
112112
$access = $entity->access('update', $account, TRUE)
113113
->andIf($entity->get('field_example')->access('edit', $account, TRUE));
@@ -117,7 +117,7 @@ final class {{ class }} extends {{ configurable ? 'ConfigurableActionBase' : 'Ac
117117
/**
118118
* {@inheritdoc}
119119
*/
120-
public function execute(ContentEntityInterface $entity = NULL): void {
120+
public function execute(?ContentEntityInterface $entity = NULL): void {
121121
$entity->set('field_example', 'New value')->save();
122122
}
123123

templates/Service/_path-processor/path-processor.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class {{ class }} implements InboundPathProcessorInterface, OutboundPathPr
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL): string {
45+
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL): string {
4646
return preg_replace('#^/node/#i', '/content/', $path);
4747
}
4848

tests/functional/Generator/Plugin/Migrate/_destination/_n_deps/src/Plugin/migrate/destination/Foo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace Drupal\example\Plugin\migrate\destination;
66

77
use Drupal\migrate\Attribute\MigrateDestination;
8-
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
98
use Drupal\migrate\Plugin\MigrationInterface;
9+
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
1010
use Drupal\migrate\Row;
1111

1212
/**
@@ -30,7 +30,7 @@ public function getIds(): array {
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function fields(MigrationInterface $migration = NULL): array {
33+
public function fields(?MigrationInterface $migration = NULL): array {
3434
return [
3535
'id' => $this->t('The row ID.'),
3636
// @todo Describe row fields here.

tests/functional/Generator/Plugin/Migrate/_destination/_w_deps/src/Plugin/migrate/destination/Bar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Drupal\Core\Entity\EntityTypeManagerInterface;
88
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
99
use Drupal\migrate\Attribute\MigrateDestination;
10-
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
1110
use Drupal\migrate\Plugin\MigrationInterface;
11+
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
1212
use Drupal\migrate\Row;
1313
use Symfony\Component\DependencyInjection\ContainerInterface;
1414

@@ -65,7 +65,7 @@ public function getIds(): array {
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public function fields(MigrationInterface $migration = NULL): array {
68+
public function fields(?MigrationInterface $migration = NULL): array {
6969
return [
7070
'id' => $this->t('The row ID.'),
7171
// @todo Describe row fields here.

tests/functional/Generator/Plugin/_action/_n_deps/_w_config/src/Plugin/Action/Foo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
69+
public function access($entity, ?AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
7070
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
7171
$access = $entity->access('update', $account, TRUE)
7272
->andIf($entity->get('field_example')->access('edit', $account, TRUE));
@@ -76,7 +76,7 @@ public function access($entity, AccountInterface $account = NULL, $return_as_obj
7676
/**
7777
* {@inheritdoc}
7878
*/
79-
public function execute(ContentEntityInterface $entity = NULL): void {
79+
public function execute(?ContentEntityInterface $entity = NULL): void {
8080
$entity->set('field_example', 'New value')->save();
8181
}
8282

tests/functional/Generator/Plugin/_action/_w_deps/_n_config/src/Plugin/Action/Foo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function create(ContainerInterface $container, array $configuratio
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
69+
public function access($entity, ?AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
7070
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
7171
$access = $entity->access('update', $account, TRUE)
7272
->andIf($entity->get('field_example')->access('edit', $account, TRUE));
@@ -76,7 +76,7 @@ public function access($entity, AccountInterface $account = NULL, $return_as_obj
7676
/**
7777
* {@inheritdoc}
7878
*/
79-
public function execute(ContentEntityInterface $entity = NULL): void {
79+
public function execute(?ContentEntityInterface $entity = NULL): void {
8080
$entity->set('field_example', 'New value')->save();
8181
}
8282

0 commit comments

Comments
 (0)