HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/payments-gateway/vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php
<?php

declare(strict_types=1);

namespace Doctrine\ORM\Mapping;

use ArrayAccess;

use function property_exists;

/** @template-implements ArrayAccess<string, mixed> */
final class JoinColumnMapping implements ArrayAccess
{
    use ArrayAccessImplementation;

    public bool|null $unique             = null;
    public bool|null $quoted             = null;
    public string|null $fieldName        = null;
    public string|null $onDelete         = null;
    public string|null $columnDefinition = null;
    public bool|null $nullable           = null;

    /** @var array<string, mixed>|null */
    public array|null $options = null;

    public function __construct(
        public string $name,
        public string $referencedColumnName,
    ) {
    }

    /**
     * @param array<string, mixed> $mappingArray
     * @phpstan-param array{
     *     name: string,
     *     referencedColumnName: string,
     *     unique?: bool|null,
     *     quoted?: bool|null,
     *     fieldName?: string|null,
     *     onDelete?: string|null,
     *     columnDefinition?: string|null,
     *     nullable?: bool|null,
     *     options?: array<string, mixed>|null,
     * } $mappingArray
     */
    public static function fromMappingArray(array $mappingArray): self
    {
        $mapping = new self($mappingArray['name'], $mappingArray['referencedColumnName']);
        foreach ($mappingArray as $key => $value) {
            if (property_exists($mapping, $key) && $value !== null) {
                $mapping->$key = $value;
            }
        }

        return $mapping;
    }

    /** @return list<string> */
    public function __sleep(): array
    {
        $serialized = [];

        foreach (['name', 'fieldName', 'onDelete', 'columnDefinition', 'referencedColumnName', 'options'] as $stringOrArrayKey) {
            if ($this->$stringOrArrayKey !== null) {
                $serialized[] = $stringOrArrayKey;
            }
        }

        foreach (['unique', 'quoted', 'nullable'] as $boolKey) {
            if ($this->$boolKey !== null) {
                $serialized[] = $boolKey;
            }
        }

        return $serialized;
    }
}