Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi there!

I have some AccountCollection defined as

/**
 * @extends  AbstractCollection<array-key,\App\Model\Account>
 */
class AccountCollection extends AbstractCollection
{
    public function getType(): string
    {
        return Account::class;
    }
}

and some GetAccountsResponse defined as

/**
 * @property \App\Model\AccountCollection $accounts
 *
 * @extends  \Arrayy\Arrayy<array-key,mixed>
 */
class GetAccountsResponse extends Arrayy
{
}

I call

$res = GetAccountsResponse::createFromJsonMapper($json)
  ->accounts
  ->each(function (Account $a) {
            print_r($a->accountName);
        });

and I get

TypeError : Invalid type: expected to be of type {App\Model\Account}, instead got value `stdClass Object
(
    [id] => 4998881
    ...
)
` with type {object}.
 /opt/project/vendor/voku/arrayy/src/TypeCheck/TypeCheckSimple.php:31
 /opt/project/vendor/voku/arrayy/src/TypeCheck/AbstractTypeCheck.php:59
 /opt/project/vendor/voku/arrayy/src/Arrayy.php:8077
 /opt/project/vendor/voku/arrayy/src/Arrayy.php:7826
 /opt/project/vendor/voku/arrayy/src/Collection/AbstractCollection.php:361
 /opt/project/vendor/voku/arrayy/src/Arrayy.php:805
 /opt/project/vendor/voku/arrayy/src/Collection/AbstractCollection.php:157
 /opt/project/vendor/voku/arrayy/src/Mapper/Json.php:279
 /opt/project/vendor/voku/arrayy/src/Mapper/Json.php:212
 /opt/project/vendor/voku/arrayy/src/Arrayy.php:3213

Do you have suggestions? Am I getting it wrong?

Thanks a lot!

You must be logged in to vote

Hi, thanks for the good error report, I just put your example into the "/test/" directory and fixed the code in version 7.9.6. Please check if it's works for you.

Replies: 2 comments

Comment options

Hi, thanks for the good error report, I just put your example into the "/test/" directory and fixed the code in version 7.9.6. Please check if it's works for you.

You must be logged in to vote
0 replies
Answer selected by voku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.