Skip to content

Instantly share code, notes, and snippets.

@absent1706
Created January 11, 2017 13:27
Show Gist options
  • Save absent1706/3764d7ce308c215fe4408c2d188a0672 to your computer and use it in GitHub Desktop.
Save absent1706/3764d7ce308c215fe4408c2d188a0672 to your computer and use it in GitHub Desktop.
psysh/config.php
<?php
/*
PsySh config file (see http://psysh.org/#configure)
!!!
Copy this file to ~\.config\psysh\config.php, where ~ is your home dir
for example (Windows): C:\Users\MY_USER\.config\psysh\config.php
Result dump will look like http://www.qopy.me/D6R2fYEQSw6wjV7NDaPMxw
*/
return [
'casters' => [
'Illuminate\Support\Collection' => 'Illuminate\Foundation\Console\IlluminateCaster::castCollection',
'Illuminate\Database\Eloquent\Model' => 'Illuminate\Foundation\Console\IlluminateCaster::castModel',
'AppBundle\Entity\Base' => function ($obj) {
$skipProps = [];
if (strpos(get_class($obj), 'Proxies\__CG__') === 0) {
$skipProps[] = '__initializer__';
$skipProps[] = '__cloner__';
}
$reflect = new \ReflectionClass($obj);
$props = $reflect->getProperties();
$result = [];
foreach ($props as $prop) {
$name = $prop->name;
if (!in_array($name, $skipProps)) {
// if (strpos($name, '__') === false) {
$prop->setAccessible(true);
$result[$prop->name] = $prop->getValue($obj);
}
}
return $result;
}
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment