We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Нет доступа к свойству объекта через $obj->{'some-property'}.
$obj->{'some-property'}
Например, в сниппете:
$obj = new \StdClass(); $obj->{1} = 'test1'; $obj->{'property-with-hyphen'} = 'test2';
И при выводе:
{$obj->{'1'}} {$obj->{'property-with-hyphen'}}
Получается ошибка Unexpected token '{' in expression in ... line 1773, near '{$obj->{'
Unexpected token '{' in expression in ... line 1773, near '{$obj->{'
The text was updated successfully, but these errors were encountered:
Да, такой возможности нет и пока не планируется. Добавте геттеры через ArrayAcces что бы можно было как с массивом работать
Sorry, something went wrong.
Для гибкости было бы неплохо. Свойства с дефисами можно преобразовывать в свойства с нижними подчеркиваниями:
function replaceDashes (&$obj) { $vars = get_object_vars($obj); foreach ($vars as $key => $val) { if (strpos($key, "-") !== false) { $newKey = str_replace("-", "_", $key); $obj->{$newKey} = $val; unset($obj->{$key}); } } }
Источник: https://stackoverflow.com/questions/1436166/php-replace-dashes-in-object-variables-with-underscores/1436187#1436187
Добавлю в следующей версии
{$object->"some-prope+rty"}
No branches or pull requests
Нет доступа к свойству объекта через
$obj->{'some-property'}
.Например, в сниппете:
И при выводе:
Получается ошибка
Unexpected token '{' in expression in ... line 1773, near '{$obj->{'
The text was updated successfully, but these errors were encountered: