ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilRuntime.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26final class ilRuntime implements Stringable
27{
28 private static ?self $instance = null;
30
34 private function __construct()
35 {
36 $this->server = new PhpServerConfiguration();
37 }
38
39 public static function getInstance(): self
40 {
41 if (self::$instance === null) {
42 self::$instance = new self();
43 }
44
45 return self::$instance;
46 }
47
48 public function isHHVM(): bool
49 {
50 return defined('HHVM_VERSION');
51 }
52
53 public function isPHP(): bool
54 {
55 return !$this->isHHVM();
56 }
57
58 public function isFPM(): bool
59 {
60 return $this->server->isFpm();
61 }
62
63 public function getVersion(): string
64 {
65 if ($this->isHHVM()) {
66 return HHVM_VERSION;
67 }
68
69 return $this->server->getPhpVersion();
70 }
71
72 public function getName(): string
73 {
74 if ($this->isHHVM()) {
75 return 'HHVM';
76 }
77
78 return 'PHP';
79 }
80
81 public function __toString(): string
82 {
83 return $this->getName() . ' ' . $this->getVersion();
84 }
85
86 public function getReportedErrorLevels(): int
87 {
88 if ($this->isHHVM()) {
89 return (int) ini_get('hhvm.log.runtime_error_reporting_level');
90 }
91
92 return $this->server->getErrorReportingLevel();
93 }
94
95 public function shouldLogErrors(): bool
96 {
97 if ($this->isHHVM()) {
98 return (bool) ini_get('hhvm.log.use_log_file');
99 }
100
101 return $this->server->isErrorLoggingEnabled();
102 }
103
104 public function shouldDisplayErrors(): bool
105 {
106 if ($this->isHHVM()) {
107 return (bool) ini_get('hhvm.debug.server_error_message');
108 }
109
110 return $this->server->isErrorDisplayEnabled();
111 }
112
113 public function getBinary(): string
114 {
115 return $this->server->getPhpBinary();
116 }
117}
__construct()
The runtime is a constant state during one request, so please use the public static getInstance() to ...
static self $instance
PhpServerConfiguration $server
getReportedErrorLevels()
static getInstance()