Skip to content

Commit

Permalink
Remove unneeded backslashes for function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed Jun 13, 2023
1 parent 866ed4b commit 73f68be
Show file tree
Hide file tree
Showing 40 changed files with 79 additions and 79 deletions.
10 changes: 5 additions & 5 deletions docs/_data/fxn_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@
"description": "an array or iterable of values to look through",
"defaultValue": null,
"defaultValueAsString": null,
"type": "array|iterable"
"type": "iterable"
},
{
"name": "condition",
Expand Down Expand Up @@ -852,7 +852,7 @@
"description": "an array or iterable of values to look through",
"defaultValue": null,
"defaultValueAsString": null,
"type": "array|iterable"
"type": "iterable"
},
{
"name": "condition",
Expand Down Expand Up @@ -897,7 +897,7 @@
"description": "an array or iterable of values to look through",
"defaultValue": null,
"defaultValueAsString": null,
"type": "array|iterable"
"type": "iterable"
},
{
"name": "condition",
Expand Down Expand Up @@ -942,7 +942,7 @@
"description": "an array or iterable of values to look through",
"defaultValue": null,
"defaultValueAsString": null,
"type": "array|iterable"
"type": "iterable"
},
{
"name": "condition",
Expand Down Expand Up @@ -979,7 +979,7 @@
"description": "an array or iterable of values to look through",
"defaultValue": null,
"defaultValueAsString": null,
"type": "array|iterable"
"type": "iterable"
},
{
"name": "condition",
Expand Down
18 changes: 9 additions & 9 deletions src/__/__.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__/arrays/chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function chunkIterable($iterable, $size, $preserveKeys)
function chunk($iterable, $size = 1, $preserveKeys = false)
{
if (is_array($iterable)) {
return \array_chunk($iterable, $size, $preserveKeys);
return array_chunk($iterable, $size, $preserveKeys);
}

return chunkIterable($iterable, $size, $preserveKeys);
Expand Down
2 changes: 1 addition & 1 deletion src/__/arrays/compact.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function compactIterable($iterable)
function compact($iterable)
{
if (is_array($iterable)) {
return \array_values(\array_filter($iterable));
return array_values(array_filter($iterable));
}

return compactIterable($iterable);
Expand Down
2 changes: 1 addition & 1 deletion src/__/arrays/drop.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function dropIterable($input, $number)
function drop($input, $number = 1)
{
if (is_array($input)) {
return \array_slice($input, $number);
return array_slice($input, $number);
}

return dropIterable($input, $number);
Expand Down
4 changes: 2 additions & 2 deletions src/__/arrays/dropRight.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
function dropRightIterable($input, $number)
{
$arr = \iterator_to_array($input, true);
$arr = iterator_to_array($input, true);
$items = dropRightArray($arr, $number);

foreach ($items as $item) {
Expand All @@ -34,7 +34,7 @@ function dropRightIterable($input, $number)
*/
function dropRightArray($input, $number)
{
return \array_slice($input, 0, max(count($input) - $number, 0));
return array_slice($input, 0, max(count($input) - $number, 0));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/__/arrays/dropRightWhile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
function dropIteratorRightWhile($input, $comparison)
{
$arr = \iterator_to_array($input, true);
$arr = iterator_to_array($input, true);
$items = dropArrayRightWhile($arr, $comparison);

foreach ($items as $item) {
Expand All @@ -39,7 +39,7 @@ function dropArrayRightWhile($input, $comparison)
continue;
}

return \array_slice($input, 0, $i + 1);
return array_slice($input, 0, $i + 1);
}

return [];
Expand Down
2 changes: 1 addition & 1 deletion src/__/arrays/dropWhile.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function dropArrayWhile($input, $comparison)
$count++;
}

return \array_slice($input, $count);
return array_slice($input, $count);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/__/arrays/prepend.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
function prepend(array $array, $value = null)
{
\array_unshift($array, $value);
array_unshift($array, $value);

return $array;
}
2 changes: 1 addition & 1 deletion src/__/arrays/randomize.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
function randomize(array $array)
{
for ($i = 0, $c = \count($array); $i < $c - 1; $i++) {
$j = \rand($i + 1, $c - 1);
$j = rand($i + 1, $c - 1);
list($array[$i], $array[$j]) = [$array[$j], $array[$i]];
}

Expand Down
2 changes: 1 addition & 1 deletion src/__/arrays/repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
*/
function repeat($object, $times)
{
return \array_fill(0, (int)$times, $object);
return array_fill(0, (int)$times, $object);
}
10 changes: 5 additions & 5 deletions src/__/collections/ease.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*
* @internal
*
* @param array $map
* @param array $array
* @param string $glue
* @param string $prefix
* @param array $map
* @param iterable $array
* @param string $glue
* @param string $prefix
*/
function _ease(&$map, $array, $glue, $prefix = '')
{
foreach ($array as $index => $value) {
if (\is_array($value)) {
if (is_array($value)) {
_ease($map, $value, $glue, $prefix . $index . $glue);
} else {
$map[$prefix . $index] = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @internal
*
* @param \Traversable $iterable
* @param iterable $iterable
* @param \Closure|null $closure Closure to filter the array
*
* @return \Generator
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/findEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* @since 0.2.1 added to bottomline
*
* @param array|iterable $collection an array or iterable of values to look through
* @param iterable $collection an array or iterable of values to look through
* @param bool|\Closure|double|int|string $condition condition to match using either a primitive value or a callback
*
* @see find
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/findIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
*
* @since 0.2.1 added to bottomline
*
* @param array|iterable $collection an array or iterable of values to look through
* @param iterable $collection an array or iterable of values to look through
* @param bool|\Closure|double|int|string $condition condition to match using either a primitive value or a callback
* @param int|string $returnValue the value to return if nothing matches
*
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/findLast.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*
* @since 0.2.1 added to bottomline
*
* @param array|iterable $collection an array or iterable of values to look through
* @param iterable $collection an array or iterable of values to look through
* @param bool|\Closure|double|int|string $condition condition to match using either a primitive value or a callback
* @param mixed|null $returnValue the value to return if nothing matches
*
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/findLastEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* @since 0.2.1 added to bottomline
*
* @param array|iterable $collection an array or iterable of values to look through
* @param iterable $collection an array or iterable of values to look through
* @param bool|\Closure|double|int|string $condition condition to match using either a primitive value or a callback
*
* @see find
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/findLastIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
*
* @since 0.2.1 added to bottomline
*
* @param array|iterable $collection an array or iterable of values to look through
* @param iterable $collection an array or iterable of values to look through
* @param bool|\Closure|double|int|string $condition condition to match using either a primitive value or a callback
* @param int|string $returnValue the value to return if nothing matches
*
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function get($collection, $path, $default = null)
// TODO Make the algorithm recursive.
// TODO Factorize between object and array access (use a $getter function,
// as the $setter in __::set()).
if (\is_array($collection) && isset($collection[$path])) {
if (is_array($collection) && isset($collection[$path])) {
return $collection[$path];
}

Expand Down
4 changes: 2 additions & 2 deletions src/__/collections/groupBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@
*/
function groupBy($iterable, $key)
{
if (!\is_bool($key) && !\is_scalar($key) && !\is_callable($key)) {
if (!is_bool($key) && !is_scalar($key) && !is_callable($key)) {
return $iterable;
}

$grouped = [];
foreach ($iterable as $value) {
$groupKey = null;

if (\is_callable($key)) {
if (is_callable($key)) {
$groupKey = call_user_func($key, $value);
} else {
$groupKey = \__::get($value, $key);
Expand Down
4 changes: 2 additions & 2 deletions src/__/collections/hasKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
function hasKeys($collection = [], array $keys = [], $strict = false)
{
$keyCount = \count($keys);
if ($strict && \count($collection) !== $keyCount) {
$keyCount = count($keys);
if ($strict && count($collection) !== $keyCount) {
return false;
}
return \__::every(
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/last.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function last($iterable, $take = null)
$take = (int)$take;

if (is_array($iterable)) {
return $take ? \array_slice($iterable, -$take) : \array_pop($iterable);
return $take ? array_slice($iterable, -$take) : array_pop($iterable);
}

$result = [];
Expand Down
8 changes: 4 additions & 4 deletions src/__/collections/pluck.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
*/
function pluck($collection, $property)
{
$result = \array_map(function ($value) use ($property) {
$result = array_map(function ($value) use ($property) {
if (is_array($value) && isset($value[$property])) {
return $value[$property];
} elseif (\is_object($value) && isset($value->{$property})) {
} elseif (is_object($value) && isset($value->{$property})) {
return $value->{$property};
}

foreach (\__::split($property, \__::DOT_NOTATION_DELIMITER) as $segment) {
if (\is_object($value)) {
if (is_object($value)) {
if (isset($value->{$segment})) {
$value = $value->{$segment};
} else {
Expand All @@ -57,5 +57,5 @@ function pluck($collection, $property)
return $value;
}, (array)$collection);

return \array_values($result);
return array_values($result);
}
2 changes: 1 addition & 1 deletion src/__/collections/reverseIterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
function reverseIterable($iterable)
{
$iterable_values = is_array($iterable) ? $iterable : \iterator_to_array($iterable, true);
$iterable_values = is_array($iterable) ? $iterable : iterator_to_array($iterable, true);
for (end($iterable_values); ($key = key($iterable_values)) !== null; prev($iterable_values)) {
yield $key => current($iterable_values);
}
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function set($collection, $path, $value = null)
$portions = \__::split($path, \__::DOT_NOTATION_DELIMITER, 2);
$key = $portions[0];

if (\count($portions) === 1) {
if (count($portions) === 1) {
return _universal_set($collection, $key, $value);
}
// Here we manage the case where the portion of the path points to nothing,
Expand Down
2 changes: 1 addition & 1 deletion src/__/collections/unease.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function unease($collection, $separator = '.')
foreach ($collection as $key => $value) {
$map = \__::set(
$map,
$nonDefaultSeparator ? \str_replace($separator, '.', $key) : $key,
$nonDefaultSeparator ? str_replace($separator, '.', $key) : $key,
$value
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/__/functions/slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,32 @@ function slug($str, array $options = [])
];

// Merge options
$options = \array_merge($defaults, $options);
$options = array_merge($defaults, $options);

// Make custom replacements
if ($options['replacements']) {
$str = \preg_replace(\array_keys($options['replacements']), $options['replacements'], $str);
$str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str);
}

// Transliterate characters to ASCII
if ($options['transliterate']) {
$char_map = require(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'charmap.php');
$str = \str_replace(\array_keys($char_map), $char_map, $str);
$str = str_replace(array_keys($char_map), $char_map, $str);
}

// Replace non-alphanumeric characters with our delimiter
$str = \preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);
$str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);

// Remove duplicate delimiters
$str = \preg_replace('/(' . \preg_quote($options['delimiter'], '/') . '){2,}/', $options['delimiter'], $str);
$str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', $options['delimiter'], $str);

// Truncate slug to max. characters
if ($options['limit']) {
$str = $ops->smart_substr($str, 0, ($options['limit'] ?: $ops->smart_strlen($str, 'UTF-8')), 'UTF-8');
}

// Remove delimiter from ends
$str = \trim($str, $options['delimiter']);
$str = trim($str, $options['delimiter']);

return $options['lowercase'] ? $ops->smart_strtolower($str, 'UTF-8') : $str;
}
8 changes: 4 additions & 4 deletions src/__/functions/truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
*/
function truncate($text, $limit)
{
if (\str_word_count($text, 0) > $limit) {
$words = \str_word_count($text, 2);
$pos = \array_keys($words);
$text = \mb_substr($text, 0, $pos[$limit], 'UTF-8') . '...';
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = mb_substr($text, 0, $pos[$limit], 'UTF-8') . '...';
}

return $text;
Expand Down
4 changes: 2 additions & 2 deletions src/__/functions/urlify.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ function urlify($string)
$rexQuery = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';
$rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?';

return \preg_replace_callback(
return preg_replace_callback(
"&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&",
function ($match) {
$completeUrl = $match[1] ? $match[0] : "http://{$match[0]}";

return '<a href="' . $completeUrl . '">' . $match[2] . $match[3] . $match[4] . '</a>';
},
\htmlspecialchars($string)
htmlspecialchars($string)
);
}
2 changes: 1 addition & 1 deletion src/__/objects/isEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
*/
function isEmail($value)
{
return \filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}
Loading

0 comments on commit 73f68be

Please sign in to comment.