summaryrefslogtreecommitdiff
path: root/vendor/sebastian/type/src/GenericObjectType.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sebastian/type/src/GenericObjectType.php')
-rw-r--r--vendor/sebastian/type/src/GenericObjectType.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/sebastian/type/src/GenericObjectType.php b/vendor/sebastian/type/src/GenericObjectType.php
new file mode 100644
index 000000000..6871008bd
--- /dev/null
+++ b/vendor/sebastian/type/src/GenericObjectType.php
@@ -0,0 +1,46 @@
+<?php declare(strict_types=1);
+/*
+ * This file is part of sebastian/type.
+ *
+ * (c) Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace SebastianBergmann\Type;
+
+final class GenericObjectType extends Type
+{
+ /**
+ * @var bool
+ */
+ private $allowsNull;
+
+ public function __construct(bool $nullable)
+ {
+ $this->allowsNull = $nullable;
+ }
+
+ public function isAssignable(Type $other): bool
+ {
+ if ($this->allowsNull && $other instanceof NullType) {
+ return true;
+ }
+
+ if (!$other instanceof ObjectType) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public function name(): string
+ {
+ return 'object';
+ }
+
+ public function allowsNull(): bool
+ {
+ return $this->allowsNull;
+ }
+}