Skip to content

Commit

Permalink
Merge branch '6.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Mar 13, 2022
2 parents 003bd21 + 77c2e39 commit 2ae8cff
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 70 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ return PhpCsFixer\Config::create()
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
'no_extra_blank_lines' => false,
'no_empty_comment' => false,
'no_extra_consecutive_blank_lines' => false,
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ abstract class CommandServiceProvider extends BaseServiceProvider implements Def
*/
public function register()
{
foreach (\array_keys($this->commands) as $command) {
foreach (array_keys($this->commands) as $command) {
$method = "register{$command}Command";

$this->{$method}();
}

$this->commands(\array_values($this->commands));
$this->commands(array_values($this->commands));
}

/**
Expand All @@ -44,6 +44,6 @@ public function register()
*/
public function provides()
{
return \array_merge(\array_values($this->commands), $this->provides);
return array_merge(array_values($this->commands), $this->provides);
}
}
2 changes: 1 addition & 1 deletion src/Providers/Concerns/DiscoverableEventProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function discoverEvents()

return Collection::make($this->discoverEventsWithin())
->reduce(static function ($discovered, $directory) use ($basePath) {
return \array_merge_recursive(
return array_merge_recursive(
$discovered,
DiscoverEvents::within($directory, $basePath)
);
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/Concerns/EventProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ trait EventProvider
*/
public function registerEventListeners(DispatcherContract $dispatcher): void
{
$events = \array_merge_recursive(
(\method_exists($this, 'discoveredEvents') ? $this->discoveredEvents() : []),
$events = array_merge_recursive(
(method_exists($this, 'discoveredEvents') ? $this->discoveredEvents() : []),
$this->listens()
);

foreach ($events as $event => $listeners) {
foreach (\array_unique($listeners) as $listener) {
foreach (array_unique($listeners) as $listener) {
$dispatcher->listen($event, $listener);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/Concerns/PackageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function guessPackagePath(): string
{
$path = (new ReflectionClass($this))->getFileName();

return \realpath(\dirname($path).'/../../');
return realpath(\dirname($path).'/../../');
}

/**
Expand All @@ -129,7 +129,7 @@ public function guessPackagePath(): string
protected function getPackageNamespace(string $package, string $namespace): string
{
if (\is_null($namespace)) {
[, $namespace] = \explode('/', $package);
[, $namespace] = explode('/', $package);
}

return $namespace;
Expand All @@ -144,7 +144,7 @@ protected function getPackageNamespace(string $package, string $namespace): stri
*/
protected function getAppViewPaths(string $package): array
{
return \array_map(static function ($path) use ($package) {
return array_map(static function ($path) use ($package) {
return "{$path}/packages/{$package}";
}, $this->app->make('config')->get('view.paths', []));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class ServiceProvider extends BaseServiceProvider
*/
protected function loadFactoriesFrom($paths)
{
if (\method_exists($this->app, 'runningUnitTests') && $this->app->runningUnitTests()) {
if (method_exists($this->app, 'runningUnitTests') && $this->app->runningUnitTests()) {
$this->callAfterResolving(EloquentFactory::class, function ($factory) use ($paths) {
foreach ((array) $paths as $path) {
$factory->load($path);
Expand Down
14 changes: 7 additions & 7 deletions src/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class Collection extends BaseCollection implements Csvable, Transformable
*/
public function toCsv(): string
{
\ob_start();
ob_start();

$stream = $this->streamCsv();
\fclose($stream);
fclose($stream);

return \ob_get_clean();
return ob_get_clean();
}

/**
Expand All @@ -32,12 +32,12 @@ public function streamCsv()
$enclosure = '"';
$header = $this->resolveCsvHeader();

$stream = \fopen('php://output', 'r+');
$stream = fopen('php://output', 'r+');

\fputcsv($stream, $header, $delimiter, $enclosure);
fputcsv($stream, $header, $delimiter, $enclosure);

foreach ($this->items as $key => $item) {
\fputcsv($stream, Arr::dot($item), $delimiter, $enclosure);
fputcsv($stream, Arr::dot($item), $delimiter, $enclosure);
}

return $stream;
Expand All @@ -54,7 +54,7 @@ protected function resolveCsvHeader(): array

if (! $this->isEmpty()) {
$single = $this->first();
$header = \array_keys(Arr::dot($single));
$header = array_keys(Arr::dot($single));
}

return $header;
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Concerns/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function secureGet(string $key, $default = null)
*/
public function set(string $key, $value = null)
{
return Arr::set($this->items, $key, \value($value));
return Arr::set($this->items, $key, value($value));
}

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ public function forget(string $key): bool
{
$items = $this->items;

\array_push($this->removedItems, $key);
array_push($this->removedItems, $key);
Arr::forget($items, $key);

$this->items = $items;
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Concerns/Descendible.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ protected function descendants(array $array, ?string $key = null)
return $array;
}

$keys = \explode('.', $key);
$first = \array_shift($keys);
$keys = explode('.', $key);
$first = array_shift($keys);

if (! isset($array[$first])) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Concerns/Observable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function observe($class): void
$className = \get_class($class);

foreach ($instance->getObservableEvents() as $event) {
if (\method_exists($class, $event)) {
if (method_exists($class, $event)) {
static::registerObservableEvent($event, "{$className}@{$event}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Concerns/Uploadable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ protected function getUploadedFilename(UploadedFile $file): string
{
$extension = $file->getClientOriginalExtension();

return \sprintf('%s.%s', Str::random(10), $extension);
return sprintf('%s.%s', Str::random(10), $extension);
}
}
14 changes: 7 additions & 7 deletions src/Support/Concerns/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final public function onValidationScenario(string $scenario, array $parameters =
{
[$on, $extend] = $this->getValidationSchemasName($scenario);

$this->validationScenarios = \compact('on', 'extend', 'parameters');
$this->validationScenarios = compact('on', 'extend', 'parameters');

return $this;
}
Expand All @@ -52,7 +52,7 @@ final public function onValidationScenario(string $scenario, array $parameters =
*/
final public function bindToValidation(array $bindings): self
{
$this->validationBindings = \array_merge($this->validationBindings, $bindings);
$this->validationBindings = array_merge($this->validationBindings, $bindings);

return $this;
}
Expand All @@ -78,7 +78,7 @@ final public function runValidation($request, array $phrases = [], $events = [])

[$rules, $phrases] = $this->runValidationEvents($events, $phrases);

return \tap(Validator::make($input, $rules, $phrases), function (ValidatorContract $validator) {
return tap(Validator::make($input, $rules, $phrases), function (ValidatorContract $validator) {
$this->runExtendedScenario($validator);
});
}
Expand Down Expand Up @@ -144,12 +144,12 @@ final protected function runExtendedScenario(ValidatorContract $validator): void
final protected function runValidationEvents($events, array $phrases): array
{
// Merge all the events.
$events = \array_merge($this->getValidationEvents(), Arr::wrap($events));
$events = array_merge($this->getValidationEvents(), Arr::wrap($events));

// Convert rules array to Fluent, in order to pass it by references
// in all event listening to this validation.
$rules = new Fluent($this->getBindedRules());
$phrases = new Fluent(\array_merge($this->getValidationPhrases(), $phrases));
$phrases = new Fluent(array_merge($this->getValidationPhrases(), $phrases));

foreach ((array) $events as $event) {
Event::dispatch($event, [&$rules, &$phrases]);
Expand Down Expand Up @@ -206,8 +206,8 @@ protected function getValidationSchemasName(string $scenario): array
$extend = "extend{$scenario}";

return [
\method_exists($this, $on) ? $on : null,
\method_exists($this, $extend) ? $extend : null,
method_exists($this, $on) ? $on : null,
method_exists($this, $extend) ? $extend : null,
];
}
}
6 changes: 3 additions & 3 deletions src/Support/Keyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct($value)
$this->value = $value;

if (\is_string($value)) {
$this->slug = \trim(Str::slug($value, '-'));
$this->slug = trim(Str::slug($value, '-'));
}
}

Expand Down Expand Up @@ -78,10 +78,10 @@ public function getSlug(): ?string
public function searchIn(array $items = [])
{
if (\is_null($slug = $this->slug)) {
return \array_search($this->value, $items);
return array_search($this->value, $items);
}

return \array_search($slug, $items);
return array_search($slug, $items);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function createDriver($driverName)
// creator Closure to create it.
if (isset($this->customCreators[$driver])) {
return $this->callCustomCreator($driverName);
} elseif (\method_exists($this, $method)) {
} elseif (method_exists($this, $method)) {
return $this->{$method}($name);
}

Expand Down Expand Up @@ -75,11 +75,11 @@ protected function callCustomCreator($driverName)
*/
protected function getDriverName(string $driverName): array
{
if (false === \strpos($driverName, '.')) {
if (false === strpos($driverName, '.')) {
$driverName = "{$driverName}.default";
}

[$driver, $name] = \explode('.', $driverName, 2);
[$driver, $name] = explode('.', $driverName, 2);

$this->checkNameIsNotBlacklisted($name);

Expand Down
18 changes: 9 additions & 9 deletions src/Support/Nesty.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function toFluent($id): Fluent
$defaults = $this->config['defaults'] ?? [];
$class = $this->config['fluent'] ?? Fluent::class;

return new $class(\array_merge($defaults, [
return new $class(array_merge($defaults, [
'id' => $id,
'childs' => [],
]));
Expand All @@ -60,8 +60,8 @@ protected function addBefore(string $id, string $before): Fluent
{
$items = [];
$item = $this->toFluent($id);
$keys = \array_keys($this->items);
$position = \array_search($before, $keys);
$keys = array_keys($this->items);
$position = array_search($before, $keys);

if ($position === false) {
return $this->addParent($id);
Expand Down Expand Up @@ -92,8 +92,8 @@ protected function addAfter(string $id, string $after): Fluent
{
$items = [];
$item = $this->toFluent($id);
$keys = \array_keys($this->items);
$position = \array_search($after, $keys);
$keys = array_keys($this->items);
$position = array_search($after, $keys);

if ($position === false) {
return $this->addParent($id);
Expand Down Expand Up @@ -161,9 +161,9 @@ protected function addParent(string $id): Fluent
*/
public function add(string $id, string $location = '#'): ?Fluent
{
if ($location === '<' && count($keys = array_keys($this->items)) > 0) {
if ($location === '<' && \count($keys = array_keys($this->items)) > 0) {
return $this->addBefore($id, $keys[0]);
} elseif (\preg_match('/^(<|>|\^):(.+)$/', $location, $matches) && count($matches) >= 3) {
} elseif (preg_match('/^(<|>|\^):(.+)$/', $location, $matches) && \count($matches) >= 3) {
return $this->pickTraverseFromMatchedExpression($id, $matches[1], $matches[2]);
}

Expand Down Expand Up @@ -201,9 +201,9 @@ protected function pickTraverseFromMatchedExpression(string $id, string $key, st
*/
public function has(string $key): bool
{
$key = \implode('.childs.', \explode('.', $key));
$key = implode('.childs.', explode('.', $key));

return ! \is_null(\data_get($this->items, $key));
return ! \is_null(data_get($this->items, $key));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class Serializer
*/
public function __invoke(...$parameters)
{
if (\method_exists($this, 'serialize')) {
if (method_exists($this, 'serialize')) {
return $this->serialize(...$parameters);
}

Expand Down
Loading

0 comments on commit 2ae8cff

Please sign in to comment.