{"id":15018701,"url":"https://github.com/endermanbugzjfc/configstruct","last_synced_at":"2025-10-23T20:31:42.904Z","repository":{"id":41060510,"uuid":"445583543","full_name":"Endermanbugzjfc/ConfigStruct","owner":"Endermanbugzjfc","description":"Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.","archived":false,"fork":false,"pushed_at":"2022-06-20T18:28:57.000Z","size":662,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T21:04:09.503Z","etag":null,"topics":["array","config","data","pm","pmmp","pocketmine","shape","struct","structure","virion"],"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/Endermanbugzjfc.png","metadata":{"files":{"readme":"README.md","changelog":"changelogs/2.0.md","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":"2022-01-07T16:27:03.000Z","updated_at":"2024-11-04T04:23:59.000Z","dependencies_parsed_at":"2022-08-21T01:50:30.060Z","dependency_job_id":null,"html_url":"https://github.com/Endermanbugzjfc/ConfigStruct","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FConfigStruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FConfigStruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FConfigStruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FConfigStruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Endermanbugzjfc","download_url":"https://codeload.github.com/Endermanbugzjfc/ConfigStruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237882172,"owners_count":19381176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["array","config","data","pm","pmmp","pocketmine","shape","struct","structure","virion"],"created_at":"2024-09-24T19:52:18.143Z","updated_at":"2025-10-23T20:31:37.598Z","avatar_url":"https://github.com/Endermanbugzjfc.png","language":"PHP","readme":"# Gave up maintenance （不羈放縱愛自由）\nUse https://github.com/sylvrs/libMarshal instead.\n# ConfigStruct\n\nType and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or\ncomposer project.\n\nIt also generates more human-readable errors when something is wrong with the data. Encouraging and guiding the user (especially some PocketMine-MP server owners) to read the error and fix their mess.\n\n\n![](https://i.imgflip.com/67yyc9.jpg)\n\nhttps://github.com/Sandertv/Marshal is an alternative that supports lower versions of PHP. However, it is not as ~~bloat~~ feature-rich as this library.\n# The section that everyone is looking for\n## Installation\nVia Composer:\n```\ncomposer require endermanbugzjfc/configstruct\n```\nVia PocketMine-MP virion infection:\nhttps://poggit.pmmp.io/v.dl/Endermanbugzjfc/ConfigStruct/ConfigStruct/%5E2.0.0\n## Preview\n### Parse errors\n```\n2 errors in /Users/Shoghi/Documents/shog chips.yml\n    1 errors in element \"a\"\n        1 errors in index \"0\"\n            1 errors in element \"c\"\n                Element is array while it should be string\n    1 errors in element \"b\"\n        Element is null while it should be bool\n\n ```\n Notice there is a trailing line break.\n\u003c!-- TODO: In an uncaught PHP error message and PocketMine-MP server log. --\u003e\n# Developer guide\n## Parsing data\n```php\nuse Endermanbugzjfc\\ConfigStruct\\Parse;\n```\n```php\n$context = Parse::object($object, $data);\n$context-\u003ecopyToObject($object, $dataFilePath);\n```\n`$dataFilePath` will be displayed in error messages if there is any.\n\nThe errors will be wrapped and thrown with a [ParseErrorsWrapper](https://github.com/Endermanbugzjfc/ConfigStruct/blob/master/ConfigStruct/src/Endermanbugzjfc/ConfigStruct/ParseErrorsWrapper.php) when calling `copyToObject()`. Although it is recommended to catch it, you can yet ignore it. Because the errors can still be displayed well in a PHP uncaught error message.\n\nYou may use `Parse::objectByReflection()` if you don't have an object but instead, its ReflectionClass instance. And use `$context-\u003ecopyToNewObject()` to copy the parsed data to a new object.\n## Customising error message\n### Changing the root header label\n`/Users/Shoghi/Documents/shog chips.yml` is the root header label in the following errors tree:\n```\n2 errors in /Users/Shoghi/Documents/shog chips.yml\n    1 errors in element \"a\"\n        1 errors in index \"0\"\n            1 errors in element \"c\"\n                Element is array while it should be string\n    1 errors in element \"b\"\n        Element is null while it should be bool\n ```\n You can change it in the first argument of `ParseErrorsWrapper::regenerateErrorMessage()`:\n```php\n$parseErrorsWrapper-\u003eregenerateErrorMessage('C:\\Windows\\System32\\ntoskrnl.exe');\n```\n### Changing the indentation\n You can change it in the second argument of `ParseErrorsWrapper::regenerateErrorMessage()`\n ### Filtering errors\n You can hide certain errors from the errors tree by filtering them out.\nApply an error filter with the third argument of `ParseErrorsWrapper::regenerateErrorMessage()`:\n```php\n$parseErrorsWrapper-\u003eregenerateErrorMessage(\n    $parseErrorsWrapper-\u003egetRootHeaderLabel(),\n    $parseErrorsWrapper-\u003egetIndentation(),\n    fn (array $keys, BaseParseError $parseError) : bool =\u003e !$parseError instanceof TypeMismatchError\n);\n```\nThis filters out all the [TypeMismatchError](https://github.com/Endermanbugzjfc/ConfigStruct/blob/master/ConfigStruct/src/Endermanbugzjfc/ConfigStruct/ParseError/TypeMismatchError.php). Although `$parseError-\u003egetErrorsTree()` will still have them, they will not be shown in the error message.\n### Print the updated error message\nSimply throw the parse errors wrapper again. Or you may choose to `echo $parseErrorsWrapper-\u003egetMessage()`. By default, the error message has a trailing line break (`\\n`). You can get an error message without the trailing line break (and other whitespaces) by calling `$parseErrorsWrapper-\u003egetMessageRtrim()` instead.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendermanbugzjfc%2Fconfigstruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendermanbugzjfc%2Fconfigstruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendermanbugzjfc%2Fconfigstruct/lists"}