@tolki/utils 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Thrown for an argument out of range, as Laravel's `nth()` throws `'Step value must be at least 1.'`.
3
+ */
4
+ export declare class InvalidArgumentException extends Error {
5
+ /**
6
+ * Create a new exception instance.
7
+ *
8
+ * @param message - The exception message
9
+ */
10
+ constructor(message: string);
11
+ }
12
+ /**
13
+ * Thrown when a lookup that must match exactly one item matches none.
14
+ *
15
+ * Laravel's `Illuminate\Support\ItemNotFoundException` extends `RuntimeException`
16
+ * without a constructor, so it carries no message at all — probed as
17
+ * `docs/php-parity/task-24-data-release-readiness.json`, "sole-empty-no-callback"
18
+ * and `task-23-obj-release-readiness.json`, "sole-none".
19
+ */
20
+ export declare class ItemNotFoundException extends Error {
21
+ /**
22
+ * Create a new exception instance.
23
+ */
24
+ constructor();
25
+ }
26
+ /**
27
+ * Thrown when a lookup that must match exactly one item matches several.
28
+ *
29
+ * The message is Laravel's `"{$count} items were found."` — probed as
30
+ * `docs/php-parity/task-24-data-release-readiness.json`, "sole-multi-no-callback"
31
+ * and `task-23-obj-release-readiness.json`, "sole-multi-list".
32
+ */
33
+ export declare class MultipleItemsFoundException extends Error {
34
+ /** The number of items found, as Laravel's public `$count`. */
35
+ readonly count: number;
36
+ /**
37
+ * Create a new exception instance.
38
+ *
39
+ * @param count - The number of items the lookup matched
40
+ */
41
+ constructor(count: number);
42
+ /**
43
+ * Get the number of items found.
44
+ *
45
+ * @returns The number of items the lookup matched
46
+ */
47
+ getCount(): number;
48
+ }
49
+ /**
50
+ * Thrown for a value of the wrong type, as Laravel's `ensure()` and `reduceSpread()` throw it.
51
+ */
52
+ export declare class UnexpectedValueException extends Error {
53
+ /**
54
+ * Create a new exception instance.
55
+ *
56
+ * @param message - The exception message
57
+ */
58
+ constructor(message: string);
59
+ }
60
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C;;;;OAIG;gBACS,OAAO,EAAE,MAAM;CAK9B;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC5C;;OAEG;;CAMN;AAED;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IAClD,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;gBACS,KAAK,EAAE,MAAM;IAOzB;;;;OAIG;IACH,QAAQ,IAAI,MAAM;CAGrB;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C;;;;OAIG;gBACS,OAAO,EAAE,MAAM;CAK9B"}
@@ -0,0 +1,54 @@
1
+ class n extends Error {
2
+ /**
3
+ * Create a new exception instance.
4
+ *
5
+ * @param message - The exception message
6
+ */
7
+ constructor(e) {
8
+ super(e), this.name = "InvalidArgumentException";
9
+ }
10
+ }
11
+ class o extends Error {
12
+ /**
13
+ * Create a new exception instance.
14
+ */
15
+ constructor() {
16
+ super(""), this.name = "ItemNotFoundException";
17
+ }
18
+ }
19
+ class r extends Error {
20
+ /** The number of items found, as Laravel's public `$count`. */
21
+ count;
22
+ /**
23
+ * Create a new exception instance.
24
+ *
25
+ * @param count - The number of items the lookup matched
26
+ */
27
+ constructor(e) {
28
+ super(`${e} items were found.`), this.name = "MultipleItemsFoundException", this.count = e;
29
+ }
30
+ /**
31
+ * Get the number of items found.
32
+ *
33
+ * @returns The number of items the lookup matched
34
+ */
35
+ getCount() {
36
+ return this.count;
37
+ }
38
+ }
39
+ class s extends Error {
40
+ /**
41
+ * Create a new exception instance.
42
+ *
43
+ * @param message - The exception message
44
+ */
45
+ constructor(e) {
46
+ super(e), this.name = "UnexpectedValueException";
47
+ }
48
+ }
49
+ export {
50
+ n as InvalidArgumentException,
51
+ o as ItemNotFoundException,
52
+ r as MultipleItemsFoundException,
53
+ s as UnexpectedValueException
54
+ };
package/dist/guards.d.ts CHANGED
@@ -19,6 +19,33 @@ export declare function isArray<T>(value: DataItems<T> | T[] | unknown): value i
19
19
  * isObject(null); -> false
20
20
  */
21
21
  export declare function isObject<T, K extends PropertyKey = PropertyKey>(value: DataItems<T, K> | unknown): value is Record<K, T>;
22
+ /**
23
+ * Check if a value is a plain object: one whose prototype is `Object.prototype`
24
+ * or `null`, the shape this port models a PHP array with.
25
+ *
26
+ * @param value - The value to check
27
+ * @returns True if the value is a plain object
28
+ *
29
+ * @example
30
+ *
31
+ * isPlainObject({ a: 1 }); -> true
32
+ * isPlainObject(Object.create(null)); -> true
33
+ * isPlainObject(new Date()); -> false
34
+ * isPlainObject([1, 2]); -> false
35
+ */
36
+ export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
37
+ /**
38
+ * Check if a value is an `@tolki/enum` case, the shape `from()` and `cases()` build.
39
+ *
40
+ * @param value - The value to check
41
+ * @returns True for a plain object with its own string `name` and its own string or number `value`
42
+ *
43
+ * @example
44
+ *
45
+ * isEnumCase({ value: 1, backed: true, name: "A" }); -> true
46
+ * isEnumCase({ value: 1 }); -> false
47
+ */
48
+ export declare function isEnumCase(value: unknown): value is Record<"name" | "value", string | number>;
22
49
  /**
23
50
  * Check if a value is any object (including arrays, null).
24
51
  *
@@ -133,6 +160,19 @@ export declare function isInteger(value: unknown): value is number;
133
160
  * @returns True if the value is a float
134
161
  */
135
162
  export declare function isFloat(value: unknown): value is number;
163
+ /**
164
+ * Check if a value is a number PHP holds as an int: an integer within its 64-bit range, and never -0.
165
+ *
166
+ * @param value - The value to check
167
+ * @returns True if PHP would hold the number as an int, false for a float PHP holds, such as 1.5, 1e19 or -0.0
168
+ *
169
+ * @example
170
+ *
171
+ * isPhpInt(2 ** 62); -> true
172
+ * isPhpInt(1e19); -> false
173
+ * isPhpInt(-0); -> false
174
+ */
175
+ export declare function isPhpInt(value: unknown): value is number;
136
176
  /**
137
177
  * Check if a value is a positive number.
138
178
  *
@@ -318,8 +358,9 @@ export declare function isTruthy(value: unknown): boolean;
318
358
  * Determine whether a value is falsy the way PHP's `array_filter()` (no
319
359
  * callback) treats it — PHP's own truthiness, not JS's.
320
360
  *
321
- * Drops `false`, `null`/`undefined`, `0`, `""`, `"0"`, and an empty array or
322
- * plain object; keeps `"00"`, `"0.0"`, and `NaN` (all truthy in PHP).
361
+ * Drops `false`, `null`/`undefined`, `0`, `0n`, `""`, `"0"`, and an empty array,
362
+ * plain object, `Map` or `Set`; keeps `"00"`, `"0.0"`, `NaN` and every other
363
+ * object, however empty, as PHP keeps every object.
323
364
  *
324
365
  * @param value - The value to check
325
366
  * @returns True if the value is falsy under PHP's rules
@@ -328,6 +369,7 @@ export declare function isTruthy(value: unknown): boolean;
328
369
  *
329
370
  * isPhpFalsy("0"); -> true
330
371
  * isPhpFalsy("00"); -> false
372
+ * isPhpFalsy(new Date(0)); -> false
331
373
  */
332
374
  export declare function isPhpFalsy(value: unknown): boolean;
333
375
  /**
@@ -401,6 +443,28 @@ export declare function isFiniteNumber(value: unknown): value is number;
401
443
  * isAccessibleData('hello'); -> false
402
444
  */
403
445
  export declare function isAccessibleData(data: unknown): boolean;
446
+ /**
447
+ * Check whether a value is one PHP's `Arr::accessible` would walk: a value that
448
+ * carries array entries rather than object state.
449
+ *
450
+ * An array and a plain object both model a PHP array; a `Map` is the JavaScript
451
+ * shape for a PHP array with non-string keys. A `Date`, a `Set`, a class instance
452
+ * or any other exotic object keeps its state somewhere other than its own
453
+ * enumerable keys, so walking it reads nothing — PHP rejects a `DateTime` the
454
+ * same way, because it does not implement `ArrayAccess`.
455
+ *
456
+ * @param value - The value to check
457
+ * @returns True if the value's own entries are its data
458
+ *
459
+ * @example
460
+ *
461
+ * isPhpAccessible({ a: 1 }); -> true
462
+ * isPhpAccessible([1, 2]); -> true
463
+ * isPhpAccessible(new Map()); -> true
464
+ * isPhpAccessible(new Date()); -> false
465
+ * isPhpAccessible(new Set()); -> false
466
+ */
467
+ export declare function isPhpAccessible(value: unknown): value is object;
404
468
  /**
405
469
  * Determine whether two values match the way PHP's `array_diff`/`array_intersect`
406
470
  * do: `(string) $a === (string) $b`. Only `string`, `boolean`, `null`, and plain
@@ -1 +1 @@
1
- {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,IAAI,CAAC,EAAE,CAE5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,GAAG,WAAW,EAC3D,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,GACjC,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAEvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAczD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,MAAM,GAAG;IAAE,QAAQ,IAAI,MA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O,CAAC,MAAM,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAsChE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA4BlD;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAYpD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAEvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAe7D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,SAAS,OAAO,EAAE,GAC3B,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAuB7B"}
package/dist/guards.js CHANGED
@@ -1,165 +1,184 @@
1
- function p(t) {
1
+ function b(t) {
2
2
  return Array.isArray(t);
3
3
  }
4
- function b(t) {
5
- return !i(t) && typeof t == "object" && !p(t);
4
+ function y(t) {
5
+ return !o(t) && typeof t == "object" && !b(t);
6
6
  }
7
- function g(t) {
7
+ function m(t) {
8
+ if (!y(t))
9
+ return !1;
10
+ const n = Object.getPrototypeOf(t);
11
+ return n === Object.prototype || n === null;
12
+ }
13
+ function w(t) {
14
+ return m(t) && Object.hasOwn(t, "name") && e(t.name) && Object.hasOwn(t, "value") && (e(t.value) || r(t.value));
15
+ }
16
+ function j(t) {
8
17
  return typeof t == "object";
9
18
  }
10
- function h(t) {
11
- return !i(t) && !u(t) && g(t);
19
+ function P(t) {
20
+ return !o(t) && !c(t) && j(t);
12
21
  }
13
- function I(t) {
14
- if (!h(t) && !c(t))
22
+ function E(t) {
23
+ if (!P(t) && !u(t))
15
24
  return !1;
16
25
  const n = Object.getOwnPropertyDescriptor(
17
26
  t,
18
27
  "constructor"
19
28
  )?.value;
20
- return c(n) && n.prototype === t;
29
+ return u(n) && n.prototype === t;
21
30
  }
22
- function o(t) {
31
+ function e(t) {
23
32
  return typeof t == "string";
24
33
  }
25
- function T(t) {
26
- return !!(o(t) || e(t) || S(t));
34
+ function W(t) {
35
+ return !!(e(t) || r(t) || S(t));
27
36
  }
28
37
  function S(t) {
29
- return !!(b(t) && c(t.toString));
38
+ return !!(y(t) && u(t.toString));
30
39
  }
31
- function e(t) {
40
+ function r(t) {
32
41
  return typeof t == "number" && !isNaN(t);
33
42
  }
34
- function W(t) {
35
- return e(t) && Number.isInteger(t);
43
+ function d(t) {
44
+ return r(t) && Number.isInteger(t);
36
45
  }
37
- function E(t) {
38
- return e(t) && !Number.isInteger(t);
46
+ function z(t) {
47
+ return r(t) && !Number.isInteger(t);
39
48
  }
40
49
  function R(t) {
41
- return e(t) && t >= 0;
50
+ return d(t) && t >= -9223372036854776e3 && t < 2 ** 63 && !Object.is(t, -0);
42
51
  }
43
52
  function _(t) {
44
- return e(t) && t < 0;
53
+ return r(t) && t >= 0;
54
+ }
55
+ function B(t) {
56
+ return r(t) && t < 0;
45
57
  }
46
58
  function N(t) {
47
59
  return typeof t == "boolean";
48
60
  }
49
- function c(t) {
61
+ function u(t) {
50
62
  return typeof t == "function";
51
63
  }
52
- function u(t) {
64
+ function c(t) {
53
65
  return typeof t > "u";
54
66
  }
55
- function d(t) {
67
+ function A(t) {
56
68
  return typeof t == "symbol";
57
69
  }
58
- function i(t) {
70
+ function o(t) {
59
71
  return t === null;
60
72
  }
61
- function P(t) {
73
+ function h(t) {
62
74
  return t instanceof Map;
63
75
  }
64
- function j(t) {
76
+ function g(t) {
65
77
  return t instanceof Set;
66
78
  }
67
- function w(t) {
68
- return i(t) || u(t) || o(t) ? !1 : c(
79
+ function C(t) {
80
+ return o(t) || c(t) || e(t) ? !1 : u(
69
81
  t[Symbol.iterator]
70
82
  );
71
83
  }
72
- function z(t) {
84
+ function D(t) {
73
85
  return t instanceof WeakMap;
74
86
  }
75
- function B(t) {
87
+ function U(t) {
76
88
  return t instanceof WeakSet;
77
89
  }
78
- function A(t) {
79
- return Number.isNaN(t) ? !0 : e(t) ? t === 0 : u(t) || i(t) ? !0 : N(t) ? t === !1 : o(t) ? t.trim() === "" : P(t) || j(t) ? t.size === 0 : p(t) ? t.length === 0 : b(t) ? Object.keys(t).length === 0 : !1;
80
- }
81
- function D(t) {
82
- return !A(t);
83
- }
84
- function U(t) {
85
- return t === !1 || t === null || u(t) || t === 0 || t === "" || t === "0" ? !0 : p(t) ? t.length === 0 : b(t) ? Object.keys(t).length === 0 : !1;
90
+ function k(t) {
91
+ return Number.isNaN(t) ? !0 : r(t) ? t === 0 : c(t) || o(t) ? !0 : N(t) ? t === !1 : e(t) ? t.trim() === "" : h(t) || g(t) ? t.size === 0 : b(t) ? t.length === 0 : y(t) ? Object.keys(t).length === 0 : !1;
86
92
  }
87
- const k = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
88
93
  function V(t) {
89
- return typeof t == "number" ? !0 : o(t) ? k.test(t) : !1;
90
- }
91
- function O(t) {
92
- return i(t) || N(t) || e(t) || o(t) || d(t) || u(t);
94
+ return !k(t);
93
95
  }
94
96
  function x(t) {
95
- return !O(t);
97
+ return t === !1 || t === null || c(t) || t === 0 || t === 0n || t === "" || t === "0" ? !0 : b(t) ? t.length === 0 : h(t) || g(t) ? t.size === 0 : m(t) ? Object.keys(t).length === 0 : !1;
98
+ }
99
+ const I = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
100
+ function G(t) {
101
+ return typeof t == "number" ? !0 : e(t) ? I.test(t) : !1;
96
102
  }
97
103
  function M(t) {
98
- return e(t) && Number.isFinite(t);
104
+ return o(t) || N(t) || r(t) || e(t) || A(t) || c(t);
99
105
  }
100
- function C(t) {
106
+ function H(t) {
107
+ return !M(t);
108
+ }
109
+ function F(t) {
110
+ return r(t) && Number.isFinite(t);
111
+ }
112
+ function $(t) {
101
113
  return Array.isArray(t);
102
114
  }
103
- function y(t) {
104
- if (o(t))
115
+ function q(t) {
116
+ return b(t) || m(t) || h(t);
117
+ }
118
+ function p(t) {
119
+ if (e(t))
105
120
  return t;
106
121
  if (N(t))
107
122
  return t ? "1" : "";
108
- if (i(t))
123
+ if (o(t))
109
124
  return "";
110
- if (M(t)) {
125
+ if (F(t)) {
111
126
  const n = String(t);
112
127
  return n.includes("e") ? null : n;
113
128
  }
114
129
  return null;
115
130
  }
116
- function F(t, n) {
117
- const f = y(t), r = y(n);
118
- return f !== null && r !== null ? f === r : t === n || typeof t == "number" && typeof n == "number" && Number.isNaN(t) && Number.isNaN(n);
131
+ function T(t, n) {
132
+ const f = p(t), i = p(n);
133
+ return f !== null && i !== null ? f === i : t === n || typeof t == "number" && typeof n == "number" && Number.isNaN(t) && Number.isNaN(n);
119
134
  }
120
- function G(t) {
135
+ function J(t) {
121
136
  const n = /* @__PURE__ */ new Set(), f = [];
122
- for (const r of t) {
123
- const s = y(r);
124
- i(s) ? f.push(r) : n.add(s);
137
+ for (const i of t) {
138
+ const s = p(i);
139
+ o(s) ? f.push(i) : n.add(s);
125
140
  }
126
- return (r) => {
127
- const s = y(r);
128
- return i(s) ? f.some((m) => F(r, m)) : n.has(s);
141
+ return (i) => {
142
+ const s = p(i);
143
+ return o(s) ? f.some((O) => T(i, O)) : n.has(s);
129
144
  };
130
145
  }
131
146
  export {
132
- C as isAccessibleData,
133
- p as isArray,
147
+ $ as isAccessibleData,
148
+ b as isArray,
134
149
  N as isBoolean,
135
- A as isFalsy,
136
- M as isFiniteNumber,
137
- E as isFloat,
138
- c as isFunction,
139
- W as isInteger,
140
- w as isIterable,
141
- P as isMap,
142
- _ as isNegativeNumber,
143
- x as isNonPrimitive,
144
- i as isNull,
145
- e as isNumber,
146
- b as isObject,
147
- g as isObjectAny,
148
- U as isPhpFalsy,
149
- V as isPhpNumeric,
150
- R as isPositiveNumber,
151
- O as isPrimitive,
152
- I as isPrototypeObject,
153
- j as isSet,
154
- o as isString,
155
- T as isStringable,
156
- d as isSymbol,
157
- D as isTruthy,
158
- h as isTruthyObject,
159
- u as isUndefined,
160
- z as isWeakMap,
161
- B as isWeakSet,
150
+ w as isEnumCase,
151
+ k as isFalsy,
152
+ F as isFiniteNumber,
153
+ z as isFloat,
154
+ u as isFunction,
155
+ d as isInteger,
156
+ C as isIterable,
157
+ h as isMap,
158
+ B as isNegativeNumber,
159
+ H as isNonPrimitive,
160
+ o as isNull,
161
+ r as isNumber,
162
+ y as isObject,
163
+ j as isObjectAny,
164
+ q as isPhpAccessible,
165
+ x as isPhpFalsy,
166
+ R as isPhpInt,
167
+ G as isPhpNumeric,
168
+ m as isPlainObject,
169
+ _ as isPositiveNumber,
170
+ M as isPrimitive,
171
+ E as isPrototypeObject,
172
+ g as isSet,
173
+ e as isString,
174
+ W as isStringable,
175
+ A as isSymbol,
176
+ V as isTruthy,
177
+ P as isTruthyObject,
178
+ c as isUndefined,
179
+ D as isWeakMap,
180
+ U as isWeakSet,
162
181
  S as objectToString,
163
- F as phpValueMatch,
164
- G as phpValueMatcher
182
+ T as phpValueMatch,
183
+ J as phpValueMatcher
165
184
  };