This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('array_is_assoc')) { | |
/** | |
* Determine if the given array is associative or numerically indexed | |
* | |
* @param array $array | |
* @return bool | |
*/ | |
function array_is_assoc(array $array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('get_path')) { | |
function get_path(array $data, $path) | |
{ | |
$nodes = is_string($path) ? explode('.', $path) : $path; | |
$node = array_shift($nodes); | |
$getNext = function ($item) use ($nodes) { | |
return $nodes ? (is_array($item) ? get_path($item, $nodes) : null) : $item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests; | |
class NodePath | |
{ | |
private const string ESCAPED = '\\\\'; | |
private const string UNESCAPED = '(?<!\\\\)'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sortRecursive() | |
{ | |
$sortRecursive = function (callable $sortBy = null, $options = SORT_REGULAR, bool $descending = false): Collection { | |
/** @var Collection|Request $this */ | |
$sort = $sortBy ? fn (array $item): Collection => collect($item)->sortBy($sortBy, $options, $descending) : | |
fn (array $item): Collection => $descending ? collect($item)->sortDesc() : collect($item)->sort(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Database\Seeders; | |
use Str; | |
use File; | |
use SplFileInfo; | |
use ReflectionClass; | |
use ReflectionException; | |
use Illuminate\Database\Seeder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Support\Str; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Artisan; | |
class GenerateTableSupportCommand extends Command | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests; | |
use ArrayAccess; | |
use BackedEnum; | |
use DateTimeInterface; | |
use RecursiveArrayIterator; | |
use RecursiveIteratorIterator; | |
use ReflectionClass; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function stack(\Throwable|array $context = null, string $prune = 'vendor', int $text = 64, int $arr = 4): void { | |
$currentTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
$current = array_shift($currentTrace); | |
$caller = implode(':', [$current['file'] ?? '', $current['line'] ?? '']); | |
$exception = $context instanceof \Throwable ? get_class($context) : ''; | |
$message = $context instanceof \Throwable ? $context->getMessage() : ''; | |
$trace = $context instanceof \Throwable ? $context->getTrace() : ($context ?: $currentTrace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\HighOrderReflection; | |
use BadMethodCallException; | |
use Closure; | |
use ReflectionClass; | |
use ReflectionException; | |
use Throwable; | |
use UnexpectedValueException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function compileQuery(Chess\DoctrineBundle\Doctrine\ORM\HintedQueryDecorator|\Doctrine\ORM\AbstractQuery $query) { | |
$sql = $query->getSQL(); | |
$params = array_column(array_map(function (\Doctrine\ORM\Query\Parameter $parameter) { | |
/** @var mixed|\MyCLabs\Enum\Enum $value */ | |
$value = $parameter->getValue(); | |
$type = $parameter->getType(); | |
$name = $parameter->getName(); |