{"id":36978762,"url":"https://github.com/simivar/reverse-print-r","last_synced_at":"2026-01-13T22:48:17.758Z","repository":{"id":40439179,"uuid":"248752698","full_name":"simivar/reverse-print-r","owner":"simivar","description":"Library to reverse print_r output to PHP objects, arrays and scalar values","archived":false,"fork":false,"pushed_at":"2023-12-15T08:43:46.000Z","size":36,"stargazers_count":15,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T06:35:11.740Z","etag":null,"topics":["casting","hacktoberfest","php","php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simivar.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-20T12:42:41.000Z","updated_at":"2023-08-30T00:42:39.000Z","dependencies_parsed_at":"2022-08-24T05:10:49.797Z","dependency_job_id":null,"html_url":"https://github.com/simivar/reverse-print-r","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/simivar/reverse-print-r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simivar%2Freverse-print-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simivar%2Freverse-print-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simivar%2Freverse-print-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simivar%2Freverse-print-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simivar","download_url":"https://codeload.github.com/simivar/reverse-print-r/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simivar%2Freverse-print-r/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["casting","hacktoberfest","php","php-library"],"created_at":"2026-01-13T22:48:16.957Z","updated_at":"2026-01-13T22:48:17.745Z","avatar_url":"https://github.com/simivar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reverse print_r\r\nThis library provides six different handlers for reversing output of PHP's `print_r` function back to original variables.\r\nIf there's no handler available for a type it's returned as `string`.\r\n\r\n## Assumptions\r\n- all values should be type-casted, not returned as `string`\r\n- empty string (`\"\"`) is treated as `null` (see `NullHandler`)\r\n- integers are treated as integers (no `boolean` support)\r\n- multi-level `array` MUST be supported with type-casting\r\n- `public`, `protected` and `private` properties of Objects MUST be supported with type-casting\r\n\r\n## Known issues\r\n- no support for Object Inheritance \r\n\r\n# Installation\r\nPackage is available via  [Composer](https://getcomposer.org/).\r\n\r\n```\r\ncomposer require simivar/reverse-print-r\r\n```\r\n\r\n# Usage\r\n```php\r\n\u003c?php\r\n\r\n$print_r_output = print_r([\r\n    'string' =\u003e 'some text',\r\n    'integer' =\u003e 1,\r\n    'float' =\u003e 2.3,\r\n    'subArray' =\u003e [\r\n        'Hello World.',\r\n    ],\r\n], true);\r\n\r\n$reverser = new \\ReversePrintR\\ReversePrintR($print_r_output);\r\necho $reverser-\u003ereverse()['float']; \r\n// outputs \"2.3\"\r\n```\r\n\r\n## Changing behavior of Handlers\r\nAll handlers are defined as `final`, but thanks to Dependency Injection it's easy to change the behavior of library \r\nand it's type-casting. Let's say you want to keep all the empty strings `\"\"` as string, not `null`. All you have to do \r\nis create your own `HandlerRunner` without `NullHandler`.\r\n\r\n```php\r\n\u003c?php\r\n\r\n$print_r_output = print_r([\r\n    'string' =\u003e '',\r\n    'null' =\u003e null,\r\n], true);\r\n\r\n$handlerRunner = new \\ReversePrintR\\HandlerRunner(\r\n    new \\ReversePrintR\\Handler\\FloatHandler(),\r\n    new \\ReversePrintR\\Handler\\IntegerHandler(),\r\n    new \\ReversePrintR\\Handler\\ArrayHandler(),\r\n    new \\ReversePrintR\\Handler\\ObjectHandler()\r\n);\r\n\r\n$reverser = new \\ReversePrintR\\ReversePrintR($print_r_output, $handlerRunner);\r\nvar_dump($reverser-\u003ereverse()['null']); \r\n// outputs \"\"\r\n```\r\n\r\n## Own Handlers\r\nThe same way to removed `NullHandler` you can add your own handlers. All you have to do is make sure that it implements\r\n`\\ReversePrintR\\Handler\\HandlerInterface` and you are good to go.\r\n\r\n# Versioning\r\nLibrary is following [Semver](http://semver.org/). All minor and patch updates are backwards compatible.\r\n \r\n# License\r\nPlease see the [license file](https://github.com/simivar/reverse-print-r/blob/master/LICENSE) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimivar%2Freverse-print-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimivar%2Freverse-print-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimivar%2Freverse-print-r/lists"}