PHP 8.3.31
Preview: classes.inc Size: 1.55 KB
/proc/self/root/opt/alt/tests/alt-php85-pecl-mongodb_2.3.1-1.el8/utils/classes.inc

<?php

class Person implements MongoDB\BSON\Persistable {
    protected $name;
    protected $age;
    protected $addresses = array();
    protected $friends = array();
    protected $secret = "none";

    public function __construct($name, $age) {
        $this->name = $name;
        $this->age  = $age;
        $this->addresses = array();
        $this->secret = "$name confidential info";
    }
    public function addAddress(Address $address) {
        $this->addresses[] = $address;
    }
    public function addFriend(Person $friend) {
        $this->friends[] = $friend;
    }
    public function bsonSerialize(): array {
        return array(
            "name"    => $this->name,
            "age"     => $this->age,
            "addresses" => $this->addresses,
            "friends" => $this->friends,
        );
    }
    public function bsonUnserialize(array $data): void {
        $this->name    = $data["name"];
        $this->age     = $data["age"];
        $this->addresses = $data["addresses"];
        $this->friends = $data["friends"];
    }
}
class Address implements MongoDB\BSON\Persistable {
    protected $zip;
    protected $country;

    public function __construct($zip, $country) {
        $this->zip = $zip;
        $this->country = $country;
    }
    public function bsonSerialize(): array {
        return array(
            "zip"     => $this->zip,
            "country" => $this->country,
        );
    }
    public function bsonUnserialize(array $data): void {
        $this->zip = $data["zip"];
        $this->country = $data["country"];
    }
}


Directory Contents

Dirs: 0 × Files: 7

Name Size Perms Modified Actions
795 B lrw-r--r-- 2026-05-18 14:35:45
Edit Download
855 B lrw-r--r-- 2026-05-18 14:35:45
Edit Download
1.55 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
1.09 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
73.94 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
12.44 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
24.22 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).