We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8e63791 commit 72896bcCopy full SHA for 72896bc
src/Operators/typeof.php
@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
5
+/** @param mixed $value TODO: Specify type */
6
+function typeof($value): string {
7
+ if ($value instanceof JSString) {
8
+ $reflectionClass = new ReflectionClass($value);
9
+ $isPrimitiveProperty = $reflectionClass->getProperty('isPrimitive');
10
+ $isPrimitiveProperty->setAccessible(true);
11
+ $isPrimitive = (bool) $isPrimitiveProperty->getValue($value);
12
13
+ if ($isPrimitive) {
14
+ return 'string';
15
+ }
16
17
18
+ return 'object';
19
+}
0 commit comments