// warning: This file is auto generated by `yarn build:tests` // Do not edit by hand! import { createRequire } from 'node:module' import { describe, it, expect } from 'vitest' process.env.TZ = 'UTC' const ini_set = require('../../../../src/php/info/ini_set.ts').ini_set const ini_get = require('../../../../src/php/info/ini_get.ts').ini_get const __locutus_source_fn = require('../../../../src/php/var/var_dump.ts').var_dump const __locutus_source_module_url = new URL("../../../../src/php/var/var_dump.ts", import.meta.url) const __locutus_source_require = createRequire(__locutus_source_module_url) const __locutus_func_name = "var_dump" const __locutus_module_js_code = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.var_dump = var_dump;\nconst visitedObjects = new Map(); // Initialize a map to track visited objects\nconst _phpRuntimeState_ts_1 = require(\"../_helpers/_phpRuntimeState.ts\");\nconst _phpTypes_ts_1 = require(\"../_helpers/_phpTypes.ts\");\nconst echo_ts_1 = require(\"../strings/echo.ts\");\nconst hasNodeName = (value) => {\n return typeof value === 'object' && value !== null && 'nodeName' in value;\n};\nconst isLocutusResource = (value, getFuncName) => {\n if (typeof value !== 'object' || value === null || !('var_dump' in value) || !('constructor' in value)) {\n return false;\n }\n const maybeResource = value;\n const varDump = (0, _phpRuntimeState_ts_1.getPhpObjectEntry)(maybeResource, 'var_dump');\n const constructorValue = (0, _phpRuntimeState_ts_1.getPhpObjectEntry)(maybeResource, 'constructor');\n return (typeof varDump === 'function' &&\n typeof constructorValue === 'function' &&\n getFuncName(constructorValue) === 'LOCUTUS_Resource');\n};\nfunction var_dump(...args) {\n // discuss at: https://locutus.io/php/var_dump/\n // original by: Brett Zamir (https://brett-zamir.me)\n // improved by: Zahlii\n // improved by: Brett Zamir (https://brett-zamir.me)\n // note 1: For returning a string, use var_export() with the second argument set to true\n // example 1: var_dump(1)\n // returns 1: 'int(1)'\n // example 2: const simpleCircular = {}\n // example 2: simpleCircular.self = simpleCircular\n // example 2: var_dump(simpleCircular)\n // returns 2: 'array(1) {\\n [self] =>\\n Circular Reference Detected\\n}\\n'\n let output = '';\n const padChar = ' ';\n const padVal = 4;\n const _getFuncName = function (fn) {\n const name = /\\W*function\\s+([\\w$]+)\\s*\\(/.exec(fn.toString());\n if (!name) {\n return '(Anonymous)';\n }\n return name[1] ?? '(Anonymous)';\n };\n const _repeatChar = function (len, padCharacter) {\n let str = '';\n for (let i = 0; i < len; i++) {\n str += padCharacter;\n }\n return str;\n };\n const _getInnerVal = function (val, thickPad) {\n let ret = '';\n if (val === null) {\n ret = 'NULL';\n }\n else if (typeof val === 'boolean') {\n ret = 'bool(' + val + ')';\n }\n else if (typeof val === 'string') {\n ret = 'string(' + val.length + ') \"' + val + '\"';\n }\n else if (typeof val === 'number') {\n if (Number.isInteger(val)) {\n ret = 'int(' + val + ')';\n }\n else {\n ret = 'float(' + val + ')';\n }\n }\n else if (typeof val === 'undefined') {\n // The remaining are not PHP behavior because these values\n // only exist in this exact form in JavaScript\n ret = 'undefined';\n }\n else if (typeof val === 'function') {\n const funcLines = val.toString().split('\\n');\n ret = '';\n for (let i = 0, fll = funcLines.length; i < fll; i++) {\n const line = funcLines[i] ?? '';\n ret += (i !== 0 ? '\\n' + thickPad : '') + line;\n }\n }\n else if (val instanceof Date) {\n ret = 'Date(' + val + ')';\n }\n else if (val instanceof RegExp) {\n ret = 'RegExp(' + val + ')';\n }\n else if (hasNodeName(val)) {\n // Different than PHP's DOMElement\n switch (val.nodeType) {\n case 1:\n if (typeof val.namespaceURI === 'undefined' || val.namespaceURI === 'https://www.w3.org/1999/xhtml') {\n // Undefined namespace could be plain XML, but namespaceURI not widely supported\n ret = 'HTMLElement(\"' + val.nodeName + '\")';\n }\n else {\n ret = 'XML Element(\"' + val.nodeName + '\")';\n }\n break;\n case 2:\n ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')';\n break;\n case 3:\n ret = 'TEXT_NODE(' + val.nodeValue + ')';\n break;\n case 4:\n ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')';\n break;\n case 5:\n ret = 'ENTITY_REFERENCE_NODE';\n break;\n case 6:\n ret = 'ENTITY_NODE';\n break;\n case 7:\n ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')';\n break;\n case 8:\n ret = 'COMMENT_NODE(' + val.nodeValue + ')';\n break;\n case 9:\n ret = 'DOCUMENT_NODE';\n break;\n case 10:\n ret = 'DOCUMENT_TYPE_NODE';\n break;\n case 11:\n ret = 'DOCUMENT_FRAGMENT_NODE';\n break;\n case 12:\n ret = 'NOTATION_NODE';\n break;\n }\n }\n return ret;\n };\n const _formatArray = function (obj, curDepth, padVal, padChar, visitedObjectMap) {\n if (curDepth > 0) {\n curDepth++;\n }\n const basePad = _repeatChar(padVal * (curDepth - 1), padChar);\n const thickPad = _repeatChar(padVal * (curDepth + 1), padChar);\n let str = '';\n let val = '';\n if (typeof obj === 'object' && obj !== null) {\n if (visitedObjectMap.has(obj)) {\n // Circular reference detected, return a placeholder or a message\n return 'Circular Reference Detected\\n';\n }\n else {\n // Mark this object as visited by adding it to the map\n visitedObjectMap.set(obj, true);\n }\n if (isLocutusResource(obj, _getFuncName)) {\n return obj.var_dump();\n }\n let lgth = 0;\n const objRecord = (0, _phpTypes_ts_1.toPhpArrayObject)(obj);\n for (const someProp in objRecord) {\n if (Object.hasOwn(objRecord, someProp)) {\n lgth++;\n }\n }\n str += 'array(' + lgth + ') {\\n';\n for (const key in objRecord) {\n if (!Object.hasOwn(objRecord, key)) {\n continue;\n }\n const objVal = objRecord[key];\n if (typeof objVal === 'object' &&\n objVal !== null &&\n !(objVal instanceof Date) &&\n !(objVal instanceof RegExp) &&\n !hasNodeName(objVal)) {\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += _formatArray(objVal, curDepth + 1, padVal, padChar, visitedObjectMap);\n }\n else {\n val = _getInnerVal(objVal, thickPad);\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += val;\n str += '\\n';\n }\n }\n str += basePad + '}\\n';\n }\n else {\n str = _getInnerVal(obj, thickPad);\n }\n return str;\n };\n output = _formatArray(args[0], 0, padVal, padChar, visitedObjects);\n for (let i = 1; i < args.length; i++) {\n output += '\\n' + _formatArray(args[i], 0, padVal, padChar, visitedObjects);\n }\n (0, echo_ts_1.echo)(output);\n // Not how PHP does it, but helps us test:\n return output;\n}" const __locutus_standalone_ts_code = "function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nfunction isPhpArrayObject(value) {\n return isObjectLike(value);\n}\nfunction toPhpArrayObject(value) {\n if (isPhpArrayObject(value)) {\n return value;\n }\n return {};\n}\n// php/_helpers/_phpRuntimeState (Locutus helper dependency)\nfunction getPhpObjectEntry(value, key) {\n if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {\n return undefined;\n }\n let current = value;\n while (current) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (descriptor) {\n if (typeof descriptor.get === 'function') {\n const getterValue = descriptor.get.call(value);\n return typeof getterValue === 'undefined' ? undefined : getterValue;\n }\n const directValue = descriptor.value;\n return typeof directValue === 'undefined' ? undefined : directValue;\n }\n current = Object.getPrototypeOf(current);\n }\n return undefined;\n}\nfunction echo(...args) {\n // discuss at: https://locutus.io/php/echo/\n // parity verified: PHP 8.3\n // original by: Philip Peterson\n // improved by: echo is bad\n // improved by: Nate\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Brett Zamir (https://brett-zamir.me)\n // revised by: Der Simon (https://innerdom.sourceforge.net/)\n // bugfixed by: Eugene Bulkin (https://doubleaw.com/)\n // bugfixed by: Brett Zamir (https://brett-zamir.me)\n // bugfixed by: Brett Zamir (https://brett-zamir.me)\n // bugfixed by: EdorFaus\n // note 1: In 1.3.2 and earlier, this function wrote to the body of the document when it\n // note 1: was called in webbrowsers, in addition to supporting XUL.\n // note 1: This involved >100 lines of boilerplate to do this in a safe way.\n // note 1: Since I can't imageine a complelling use-case for this, and XUL is deprecated\n // note 1: I have removed this behavior in favor of just calling `console.log`\n // note 2: You'll see functions depends on `echo` instead of `console.log` as we'll want\n // note 2: to have 1 contact point to interface with the outside world, so that it's easy\n // note 2: to support other ways of printing output.\n // revised by: Kevin van Zonneveld (https://kvz.io)\n // input by: JB\n // example 1: echo('Hello world')\n // returns 1: undefined\n return console.log(args.join(' '));\n}\n// php/var/var_dump (target function module)\nconst visitedObjects = new Map();\nconst hasNodeName = (value) => {\n return typeof value === 'object' && value !== null && 'nodeName' in value;\n};\nconst isLocutusResource = (value, getFuncName) => {\n if (typeof value !== 'object' || value === null || !('var_dump' in value) || !('constructor' in value)) {\n return false;\n }\n const maybeResource = value;\n const varDump = getPhpObjectEntry(maybeResource, 'var_dump');\n const constructorValue = getPhpObjectEntry(maybeResource, 'constructor');\n return (typeof varDump === 'function' &&\n typeof constructorValue === 'function' &&\n getFuncName(constructorValue) === 'LOCUTUS_Resource');\n};\nfunction var_dump(...args) {\n // discuss at: https://locutus.io/php/var_dump/\n // original by: Brett Zamir (https://brett-zamir.me)\n // improved by: Zahlii\n // improved by: Brett Zamir (https://brett-zamir.me)\n // note 1: For returning a string, use var_export() with the second argument set to true\n // example 1: var_dump(1)\n // returns 1: 'int(1)'\n // example 2: const simpleCircular = {}\n // example 2: simpleCircular.self = simpleCircular\n // example 2: var_dump(simpleCircular)\n // returns 2: 'array(1) {\\n [self] =>\\n Circular Reference Detected\\n}\\n'\n let output = '';\n const padChar = ' ';\n const padVal = 4;\n const _getFuncName = function (fn) {\n const name = /\\W*function\\s+([\\w$]+)\\s*\\(/.exec(fn.toString());\n if (!name) {\n return '(Anonymous)';\n }\n return name[1] ?? '(Anonymous)';\n };\n const _repeatChar = function (len, padCharacter) {\n let str = '';\n for (let i = 0; i < len; i++) {\n str += padCharacter;\n }\n return str;\n };\n const _getInnerVal = function (val, thickPad) {\n let ret = '';\n if (val === null) {\n ret = 'NULL';\n }\n else if (typeof val === 'boolean') {\n ret = 'bool(' + val + ')';\n }\n else if (typeof val === 'string') {\n ret = 'string(' + val.length + ') \"' + val + '\"';\n }\n else if (typeof val === 'number') {\n if (Number.isInteger(val)) {\n ret = 'int(' + val + ')';\n }\n else {\n ret = 'float(' + val + ')';\n }\n }\n else if (typeof val === 'undefined') {\n // The remaining are not PHP behavior because these values\n // only exist in this exact form in JavaScript\n ret = 'undefined';\n }\n else if (typeof val === 'function') {\n const funcLines = val.toString().split('\\n');\n ret = '';\n for (let i = 0, fll = funcLines.length; i < fll; i++) {\n const line = funcLines[i] ?? '';\n ret += (i !== 0 ? '\\n' + thickPad : '') + line;\n }\n }\n else if (val instanceof Date) {\n ret = 'Date(' + val + ')';\n }\n else if (val instanceof RegExp) {\n ret = 'RegExp(' + val + ')';\n }\n else if (hasNodeName(val)) {\n // Different than PHP's DOMElement\n switch (val.nodeType) {\n case 1:\n if (typeof val.namespaceURI === 'undefined' || val.namespaceURI === 'https://www.w3.org/1999/xhtml') {\n // Undefined namespace could be plain XML, but namespaceURI not widely supported\n ret = 'HTMLElement(\"' + val.nodeName + '\")';\n }\n else {\n ret = 'XML Element(\"' + val.nodeName + '\")';\n }\n break;\n case 2:\n ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')';\n break;\n case 3:\n ret = 'TEXT_NODE(' + val.nodeValue + ')';\n break;\n case 4:\n ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')';\n break;\n case 5:\n ret = 'ENTITY_REFERENCE_NODE';\n break;\n case 6:\n ret = 'ENTITY_NODE';\n break;\n case 7:\n ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')';\n break;\n case 8:\n ret = 'COMMENT_NODE(' + val.nodeValue + ')';\n break;\n case 9:\n ret = 'DOCUMENT_NODE';\n break;\n case 10:\n ret = 'DOCUMENT_TYPE_NODE';\n break;\n case 11:\n ret = 'DOCUMENT_FRAGMENT_NODE';\n break;\n case 12:\n ret = 'NOTATION_NODE';\n break;\n }\n }\n return ret;\n };\n const _formatArray = function (obj, curDepth, padVal, padChar, visitedObjectMap) {\n if (curDepth > 0) {\n curDepth++;\n }\n const basePad = _repeatChar(padVal * (curDepth - 1), padChar);\n const thickPad = _repeatChar(padVal * (curDepth + 1), padChar);\n let str = '';\n let val = '';\n if (typeof obj === 'object' && obj !== null) {\n if (visitedObjectMap.has(obj)) {\n // Circular reference detected, return a placeholder or a message\n return 'Circular Reference Detected\\n';\n }\n else {\n // Mark this object as visited by adding it to the map\n visitedObjectMap.set(obj, true);\n }\n if (isLocutusResource(obj, _getFuncName)) {\n return obj.var_dump();\n }\n let lgth = 0;\n const objRecord = toPhpArrayObject(obj);\n for (const someProp in objRecord) {\n if (Object.hasOwn(objRecord, someProp)) {\n lgth++;\n }\n }\n str += 'array(' + lgth + ') {\\n';\n for (const key in objRecord) {\n if (!Object.hasOwn(objRecord, key)) {\n continue;\n }\n const objVal = objRecord[key];\n if (typeof objVal === 'object' &&\n objVal !== null &&\n !(objVal instanceof Date) &&\n !(objVal instanceof RegExp) &&\n !hasNodeName(objVal)) {\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += _formatArray(objVal, curDepth + 1, padVal, padChar, visitedObjectMap);\n }\n else {\n val = _getInnerVal(objVal, thickPad);\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += val;\n str += '\\n';\n }\n }\n str += basePad + '}\\n';\n }\n else {\n str = _getInnerVal(obj, thickPad);\n }\n return str;\n };\n output = _formatArray(args[0], 0, padVal, padChar, visitedObjects);\n for (let i = 1; i < args.length; i++) {\n output += '\\n' + _formatArray(args[i], 0, padVal, padChar, visitedObjects);\n }\n echo(output);\n // Not how PHP does it, but helps us test:\n return output;\n}" const __locutus_standalone_js_code = "// php/_helpers/_phpTypes (Locutus helper dependency)\nfunction isPhpArrayObject(value) {\n return typeof value === 'object' && value !== null;\n}\nfunction toPhpArrayObject(value) {\n if (isPhpArrayObject(value)) {\n return value;\n }\n return {};\n}\n// php/_helpers/_phpRuntimeState (Locutus helper dependency)\nfunction getPhpObjectEntry(value, key) {\n if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {\n return undefined;\n }\n let current = value;\n while (current) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (descriptor) {\n if (typeof descriptor.get === 'function') {\n const getterValue = descriptor.get.call(value);\n return typeof getterValue === 'undefined' ? undefined : getterValue;\n }\n const directValue = descriptor.value;\n return typeof directValue === 'undefined' ? undefined : directValue;\n }\n current = Object.getPrototypeOf(current);\n }\n return undefined;\n}\n// php/strings/echo (Locutus dependency module)\nfunction echo(...args) {\n // discuss at: https://locutus.io/php/echo/\n // parity verified: PHP 8.3\n // original by: Philip Peterson\n // improved by: echo is bad\n // improved by: Nate\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Brett Zamir (https://brett-zamir.me)\n // revised by: Der Simon (https://innerdom.sourceforge.net/)\n // bugfixed by: Eugene Bulkin (https://doubleaw.com/)\n // bugfixed by: Brett Zamir (https://brett-zamir.me)\n // bugfixed by: Brett Zamir (https://brett-zamir.me)\n // bugfixed by: EdorFaus\n // note 1: In 1.3.2 and earlier, this function wrote to the body of the document when it\n // note 1: was called in webbrowsers, in addition to supporting XUL.\n // note 1: This involved >100 lines of boilerplate to do this in a safe way.\n // note 1: Since I can't imageine a complelling use-case for this, and XUL is deprecated\n // note 1: I have removed this behavior in favor of just calling `console.log`\n // note 2: You'll see functions depends on `echo` instead of `console.log` as we'll want\n // note 2: to have 1 contact point to interface with the outside world, so that it's easy\n // note 2: to support other ways of printing output.\n // revised by: Kevin van Zonneveld (https://kvz.io)\n // input by: JB\n // example 1: echo('Hello world')\n // returns 1: undefined\n return console.log(args.join(' '));\n}\n// php/var/var_dump (target function module)\nconst visitedObjects = new Map();\nconst hasNodeName = (value) => {\n return typeof value === 'object' && value !== null && 'nodeName' in value;\n};\nconst isLocutusResource = (value, getFuncName) => {\n if (typeof value !== 'object' || value === null || !('var_dump' in value) || !('constructor' in value)) {\n return false;\n }\n const maybeResource = value;\n const varDump = getPhpObjectEntry(maybeResource, 'var_dump');\n const constructorValue = getPhpObjectEntry(maybeResource, 'constructor');\n return (typeof varDump === 'function' &&\n typeof constructorValue === 'function' &&\n getFuncName(constructorValue) === 'LOCUTUS_Resource');\n};\nfunction var_dump(...args) {\n // discuss at: https://locutus.io/php/var_dump/\n // original by: Brett Zamir (https://brett-zamir.me)\n // improved by: Zahlii\n // improved by: Brett Zamir (https://brett-zamir.me)\n // note 1: For returning a string, use var_export() with the second argument set to true\n // example 1: var_dump(1)\n // returns 1: 'int(1)'\n // example 2: const simpleCircular = {}\n // example 2: simpleCircular.self = simpleCircular\n // example 2: var_dump(simpleCircular)\n // returns 2: 'array(1) {\\n [self] =>\\n Circular Reference Detected\\n}\\n'\n let output = '';\n const padChar = ' ';\n const padVal = 4;\n const _getFuncName = function (fn) {\n const name = /\\W*function\\s+([\\w$]+)\\s*\\(/.exec(fn.toString());\n if (!name) {\n return '(Anonymous)';\n }\n return name[1] ?? '(Anonymous)';\n };\n const _repeatChar = function (len, padCharacter) {\n let str = '';\n for (let i = 0; i < len; i++) {\n str += padCharacter;\n }\n return str;\n };\n const _getInnerVal = function (val, thickPad) {\n let ret = '';\n if (val === null) {\n ret = 'NULL';\n }\n else if (typeof val === 'boolean') {\n ret = 'bool(' + val + ')';\n }\n else if (typeof val === 'string') {\n ret = 'string(' + val.length + ') \"' + val + '\"';\n }\n else if (typeof val === 'number') {\n if (Number.isInteger(val)) {\n ret = 'int(' + val + ')';\n }\n else {\n ret = 'float(' + val + ')';\n }\n }\n else if (typeof val === 'undefined') {\n // The remaining are not PHP behavior because these values\n // only exist in this exact form in JavaScript\n ret = 'undefined';\n }\n else if (typeof val === 'function') {\n const funcLines = val.toString().split('\\n');\n ret = '';\n for (let i = 0, fll = funcLines.length; i < fll; i++) {\n const line = funcLines[i] ?? '';\n ret += (i !== 0 ? '\\n' + thickPad : '') + line;\n }\n }\n else if (val instanceof Date) {\n ret = 'Date(' + val + ')';\n }\n else if (val instanceof RegExp) {\n ret = 'RegExp(' + val + ')';\n }\n else if (hasNodeName(val)) {\n // Different than PHP's DOMElement\n switch (val.nodeType) {\n case 1:\n if (typeof val.namespaceURI === 'undefined' || val.namespaceURI === 'https://www.w3.org/1999/xhtml') {\n // Undefined namespace could be plain XML, but namespaceURI not widely supported\n ret = 'HTMLElement(\"' + val.nodeName + '\")';\n }\n else {\n ret = 'XML Element(\"' + val.nodeName + '\")';\n }\n break;\n case 2:\n ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')';\n break;\n case 3:\n ret = 'TEXT_NODE(' + val.nodeValue + ')';\n break;\n case 4:\n ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')';\n break;\n case 5:\n ret = 'ENTITY_REFERENCE_NODE';\n break;\n case 6:\n ret = 'ENTITY_NODE';\n break;\n case 7:\n ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')';\n break;\n case 8:\n ret = 'COMMENT_NODE(' + val.nodeValue + ')';\n break;\n case 9:\n ret = 'DOCUMENT_NODE';\n break;\n case 10:\n ret = 'DOCUMENT_TYPE_NODE';\n break;\n case 11:\n ret = 'DOCUMENT_FRAGMENT_NODE';\n break;\n case 12:\n ret = 'NOTATION_NODE';\n break;\n }\n }\n return ret;\n };\n const _formatArray = function (obj, curDepth, padVal, padChar, visitedObjectMap) {\n if (curDepth > 0) {\n curDepth++;\n }\n const basePad = _repeatChar(padVal * (curDepth - 1), padChar);\n const thickPad = _repeatChar(padVal * (curDepth + 1), padChar);\n let str = '';\n let val = '';\n if (typeof obj === 'object' && obj !== null) {\n if (visitedObjectMap.has(obj)) {\n // Circular reference detected, return a placeholder or a message\n return 'Circular Reference Detected\\n';\n }\n else {\n // Mark this object as visited by adding it to the map\n visitedObjectMap.set(obj, true);\n }\n if (isLocutusResource(obj, _getFuncName)) {\n return obj.var_dump();\n }\n let lgth = 0;\n const objRecord = toPhpArrayObject(obj);\n for (const someProp in objRecord) {\n if (Object.hasOwn(objRecord, someProp)) {\n lgth++;\n }\n }\n str += 'array(' + lgth + ') {\\n';\n for (const key in objRecord) {\n if (!Object.hasOwn(objRecord, key)) {\n continue;\n }\n const objVal = objRecord[key];\n if (typeof objVal === 'object' &&\n objVal !== null &&\n !(objVal instanceof Date) &&\n !(objVal instanceof RegExp) &&\n !hasNodeName(objVal)) {\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += _formatArray(objVal, curDepth + 1, padVal, padChar, visitedObjectMap);\n }\n else {\n val = _getInnerVal(objVal, thickPad);\n str += thickPad;\n str += '[';\n str += key;\n str += '] =>\\n';\n str += thickPad;\n str += val;\n str += '\\n';\n }\n }\n str += basePad + '}\\n';\n }\n else {\n str = _getInnerVal(obj, thickPad);\n }\n return str;\n };\n output = _formatArray(args[0], 0, padVal, padChar, visitedObjects);\n for (let i = 1; i < args.length; i++) {\n output += '\\n' + _formatArray(args[i], 0, padVal, padChar, visitedObjects);\n }\n echo(output);\n // Not how PHP does it, but helps us test:\n return output;\n}" const __locutus_eval_function = (compiledCode: string): ((...args: unknown[]) => unknown) => { const evaluator = new Function('require', compiledCode + '\nreturn ' + __locutus_func_name + ';') return evaluator(__locutus_source_require) as (...args: unknown[]) => unknown } const __locutus_eval_module_export = (compiledCode: string, exportName: string): ((...args: unknown[]) => unknown) => { const module = { exports: {} as { [key: string]: unknown } } const exports = module.exports const evaluator = new Function('exports', 'module', 'require', compiledCode) evaluator(exports, module, __locutus_source_require) return module.exports[exportName] as (...args: unknown[]) => unknown } const __locutus_module_js_fn = __locutus_eval_module_export(__locutus_module_js_code, __locutus_func_name) const __locutus_standalone_ts_fn = __locutus_eval_function(__locutus_standalone_ts_code) const __locutus_standalone_js_fn = __locutus_eval_function(__locutus_standalone_js_code) describe('src/php/var/var_dump.ts (tested in test/generated/php/var/var_dump.vitest.ts)', function () { it('should pass example 1', function () { const expected = 'int(1)' const __locutus_variants: Array<{ name: string; fn: (...args: unknown[]) => unknown }> = [ { name: "source", fn: __locutus_source_fn }, { name: "module-js", fn: __locutus_module_js_fn }, { name: "standalone-ts", fn: __locutus_standalone_ts_fn }, { name: "standalone-js", fn: __locutus_standalone_js_fn }, ] const __locutus_run_example = (var_dump: typeof __locutus_source_fn) => { return var_dump(1) } for (const __locutus_variant of __locutus_variants) { ;(globalThis as { $locutus?: unknown }).$locutus = undefined const result = __locutus_run_example(__locutus_variant.fn as typeof __locutus_source_fn) expect(result).toEqual(expected) } }) it('should pass example 2', function () { const expected = 'array(1) {\n [self] =>\n Circular Reference Detected\n}\n' const __locutus_variants: Array<{ name: string; fn: (...args: unknown[]) => unknown }> = [ { name: "source", fn: __locutus_source_fn }, { name: "module-js", fn: __locutus_module_js_fn }, { name: "standalone-ts", fn: __locutus_standalone_ts_fn }, { name: "standalone-js", fn: __locutus_standalone_js_fn }, ] const __locutus_run_example = (var_dump: typeof __locutus_source_fn) => { const simpleCircular = {} simpleCircular.self = simpleCircular return var_dump(simpleCircular) } for (const __locutus_variant of __locutus_variants) { ;(globalThis as { $locutus?: unknown }).$locutus = undefined const result = __locutus_run_example(__locutus_variant.fn as typeof __locutus_source_fn) expect(result).toEqual(expected) } }) })