Skip to content

Commit

Permalink
doc: inArray deprecated and must be replaced by ems_in_array
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Jan 6, 2024
1 parent f2f551a commit 0070ad7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 10 additions & 0 deletions EMS/common-bundle/src/Twig/CommonExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ public function getFilters(): array
new TwigFilter('ems_color', fn ($color) => new Color($color)),
new TwigFilter('ems_array_intersect', $this->arrayIntersect(...)),
new TwigFilter('ems_array_merge_recursive', $this->arrayMergeRecursive(...)),
new TwigFilter('ems_in_array', $this->inArray(...)),
// deprecated
new TwigFilter('array_key', $this->arrayKey(...), ['deprecated' => true, 'alternative' => 'ems_array_key']),
new TwigFilter('format_bytes', Converter::formatBytes(...), ['deprecated' => true, 'alternative' => 'ems_format_bytes']),
new TwigFilter('locale_attr', [RequestRuntime::class, 'localeAttribute'], ['deprecated' => true, 'alternative' => 'ems_locale_attr']),
new TwigFilter('emsch_ouuid', $this->getOuuid(...), ['deprecated' => true, 'alternative' => 'ems_ouuid']),
new TwigFilter('array_intersect', $this->arrayIntersect(...), ['deprecated' => true, 'alternative' => 'ems_array_intersect']),
new TwigFilter('merge_recursive', $this->arrayMergeRecursive(...), ['deprecated' => true, 'alternative' => 'ems_array_merge_recursive']),
new TwigFilter('inArray', $this->inArray(...), ['deprecated' => true, 'alternative' => 'ems_in_array']),
];
}

Expand Down Expand Up @@ -123,4 +125,12 @@ public function arrayMergeRecursive(array ...$arrays): array
{
return \array_merge_recursive($arrays);
}

/**
* @param array<mixed> $haystack
*/
public function inArray(mixed $needle, array $haystack): bool
{
return false !== \array_search($needle, $haystack, true);
}
}
9 changes: 0 additions & 9 deletions EMS/core-bundle/src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public function getFunctions(): array
public function getFilters(): array
{
return [
new TwigFilter('inArray', $this->inArray(...)),
new TwigFilter('firstInArray', $this->firstInArray(...)),
new TwigFilter('md5', $this->md5(...)),
new TwigFilter('convertJavaDateFormat', $this->convertJavaDateFormat(...)),
Expand Down Expand Up @@ -1027,14 +1026,6 @@ public function getTimeFieldTimeFormat(array $options): string
return TimeFieldType::getFormat($options);
}

/**
* @param array<mixed> $haystack
*/
public function inArray(mixed $needle, array $haystack): bool
{
return false !== \array_search($needle, $haystack);
}

/**
* @param array<mixed> $haystack
*/
Expand Down
1 change: 1 addition & 0 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ E.g.:
* `emsch_ouuid` must be replaced by `ems_ouuid`
* `array_intersect` must be replaced by `ems_array_intersect`
* `merge_recursive` must be replaced by `ems_array_merge_recursive`
* `inArray` must be replaced by `ems_in_array`

### Deprecated twig function

Expand Down

0 comments on commit 0070ad7

Please sign in to comment.