{"id":13505148,"url":"https://github.com/thomasbachem/php-short-array-syntax-converter","last_synced_at":"2025-04-09T08:09:26.445Z","repository":{"id":3106188,"uuid":"4132239","full_name":"thomasbachem/php-short-array-syntax-converter","owner":"thomasbachem","description":"Command-line script to convert PHP's array() syntax to PHP 5.4's short array syntax []","archived":false,"fork":false,"pushed_at":"2019-05-10T08:45:41.000Z","size":20,"stargazers_count":372,"open_issues_count":8,"forks_count":34,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-02T00:35:10.790Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasbachem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-25T02:55:51.000Z","updated_at":"2025-02-10T18:26:48.000Z","dependencies_parsed_at":"2022-08-24T17:10:45.110Z","dependency_job_id":null,"html_url":"https://github.com/thomasbachem/php-short-array-syntax-converter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasbachem%2Fphp-short-array-syntax-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasbachem%2Fphp-short-array-syntax-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasbachem%2Fphp-short-array-syntax-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasbachem%2Fphp-short-array-syntax-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasbachem","download_url":"https://codeload.github.com/thomasbachem/php-short-array-syntax-converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999861,"owners_count":21031046,"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":[],"created_at":"2024-08-01T00:00:59.340Z","updated_at":"2025-04-09T08:09:26.424Z","avatar_url":"https://github.com/thomasbachem.png","language":"PHP","readme":"PHP 5.4 Short Array Syntax Converter\n================================\n\nCommand-line script to convert and revert PHP's `array()` syntax to PHP 5.4's short array syntax`[]` using PHP's built-in tokenizer.\n\nBy relying on the PHP tokenizer, nothing but the array syntax itself will be altered. The script was successfully tested against code bases with more than 5.000 PHP files.\n\n\nUsage\n================================\n\n    Usage: php convert.php [-w] \u003cfile\u003e\n\n    \nRun the script with the path of the PHP file you wish to convert as argument. This will print the converted source code to STDOUT. \n    \nYou can add the `-w` switch if you want to override the original file with the converted code.\n\nIf you want the script to process PHP files with short open tags (`\u003c?`) as well, you need to make sure that the [`short_open_tag`](http://php.net/manual/ini.core.php#ini.short-open-tag) setting is enabled in your `php.ini` file.\n    \nIn case of any error, an error message is written to STDERR and the script exits with a return code of 1.\n\nUse `find` to convert a whole directory recursively (on Linux/Mac):\n\n    find \u003cdirectory\u003e -name \"*.php\" -exec php \"convert.php\" -w \"{}\" \\;\n\nOr on Windows (thanks to John Jablonski for suggesting):\n\n    FOR /f \"tokens=*\" %a in ('dir *.php /S/B') DO php convert.php %a -w\n    \nIn case you don't trust the script yet, you can even perform a syntax check after conversion:\n\n    find \u003cdirectory\u003e -name \"*.php\" -exec php -l \"{}\" \\; | grep \"error:\"\n\n\nRevert\n================================\n\n    Usage: php revert.php [-w] \u003cfile\u003e\n\n**Reverting has not yet been thoroughly tested, so use with extreme percaution!**\n\nSince there is no specific token for the short array syntax, it assumes every \"[\" is an aray and relies on checking the previous token for a variable, object property, function return \")\", nested array \"]\" and variable reference \"}\".\n\n\nThanks to\n================================\nThanks to [Lebenslauf.com](https://lebenslauf.com) (German CV editor) for sponsoring the development.\n","funding_links":[],"categories":["Standalone","PHP"],"sub_categories":["Compatibility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasbachem%2Fphp-short-array-syntax-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasbachem%2Fphp-short-array-syntax-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasbachem%2Fphp-short-array-syntax-converter/lists"}