stdClass Object

Asked

Viewed 28 times

0

What does oasterisco mean in [*data], when I convert an object to array? What’s different about it compared to array[data] ?

Array
(
    [0] => Source\Models\User Object
        (
            [entity:CoffeeCode\DataLayer\DataLayer:private] => users
            [primary:CoffeeCode\DataLayer\DataLayer:private] => id
            [required:CoffeeCode\DataLayer\DataLayer:private] => Array
                (
                )

            [timestamps:CoffeeCode\DataLayer\DataLayer:private] => 1
            [statement:protected] => 
            [params:protected] => 
            [group:protected] => 
            [order:protected] => 
            [limit:protected] => 
            [offset:protected] => 
            [fail:protected] => 
            [data:protected] => stdClass Object
                (
                    [id] => 30
                    [name] => Elvis
                    [passwd] => $2y$12$xNPOIrCoCS3uWqhudFvjRvkoRkzW
                    [email] => [email protected]
                    [franquia] => 90
                    [created_at] => 2020-02-22 21:33:52
                    [updated_at] => 2020-03-10 18:17:37
                )

        )

)

Converting to array:

$array = $array[0];

print_r((array)$session);

// e obtive

            Array
(
    [CoffeeCode\DataLayer\DataLayerentity] => users
    [CoffeeCode\DataLayer\DataLayerprimary] => id
    [CoffeeCode\DataLayer\DataLayerrequired] => Array
        (
        )

    [CoffeeCode\DataLayer\DataLayertimestamps] => 1
    [*statement] => 
    [*params] => 
    [*group] => 
    [*order] => 
    [*limit] => 
    [*offset] => 
    [*fail] => 
    [*data] => stdClass Object
        (
            [id] => 30
            [name] => Eliseu
            [passwd] => $2y$12$x.2SDn17RMxce0EV3xaoDet/NPOIrC.oCS3uWqhudFvjRv.koRkzW
            [email] => [email protected]
            [franquia] => 94
            [created_at] => 2021-02-22 21:33:52
            [updated_at] => 2021-03-10 18:17:37
        )

)

1 answer

1


It means that the attribute from which it was extracted has no public access.

in the case of "[group:protected]" it shall be so declared:

class User {
    protected $group;
    [...]
}
  • 1

    I created an extended one to extract from protected for public only non-sensitive and it worked, thank you.

  • I returned to comment, today I learned to deal with objects, had a limitation because I used only array’s until then, thanks for the clarification.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.