{"id":19783089,"url":"https://github.com/edmondscommerce/typesafe-functions","last_synced_at":"2025-06-23T03:43:33.706Z","repository":{"id":56975115,"uuid":"139730467","full_name":"edmondscommerce/typesafe-functions","owner":"edmondscommerce","description":"some wrappers around internal functions that allow things to be more strictly typed","archived":false,"fork":false,"pushed_at":"2021-06-24T11:10:48.000Z","size":141,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T02:44:33.472Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edmondscommerce.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":"2018-07-04T14:08:04.000Z","updated_at":"2019-06-13T15:54:01.000Z","dependencies_parsed_at":"2022-08-21T11:50:36.985Z","dependency_job_id":null,"html_url":"https://github.com/edmondscommerce/typesafe-functions","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmondscommerce%2Ftypesafe-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmondscommerce%2Ftypesafe-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmondscommerce%2Ftypesafe-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmondscommerce%2Ftypesafe-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edmondscommerce","download_url":"https://codeload.github.com/edmondscommerce/typesafe-functions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241114085,"owners_count":19912016,"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-11-12T06:07:16.177Z","updated_at":"2025-02-28T06:49:54.864Z","avatar_url":"https://github.com/edmondscommerce.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typesafe Functions\n\nTo assist with boilerplate around working with internal functions but ensuing that your code keeps tools like [phpstan](https://github.com/phpstan/phpstan) and [phpqa](https://github.com/edmondscommerce/phpqa) happy\n\n\n## See Alternative:\nhttps://github.com/thecodingmachine/safe\n\nThis is a more comprehensive library of functions that is auto generated. \n\nI prefer to only include functions that I actually use in this library, the vast majority of functions above will never be used and so I'm reluctant to bring them all in.\n\n## Functions Replaced:\n\n### File Functions\n\n#### `file_get_contents`\n\nreturns false|string by default\n\nreplaced with `\\ts\\file_get_contents`\n\n### String Functions\n\n#### `strpos`\n\nreturns false|int by default\n\nmultiple replacements depending on use case:\n\n`\\ts\\strpos` to get the actual string position when it is known that the haystack contains the needle\n\n`\\ts\\stringContains` to check if the haystack contains the needle\n\n`\\ts\\stringStartsWith` to check if the haystack begins with the needle\n\n#### `stripos`\n\n//TODO - but will be as above, but case insensitive\n\n### Array Functions\n\n#### `in_array`\n\nBy default this is not strict and requires a third parameter of true. \n\nSimply replace with `\\ts\\arrayContains` instead to have this handled automatically.\n\nThis improves readability and also prevents various mutation testing escapees that would be otherwise hard to catch\n\nFind: `(|\\\\)in_array\\((.+?),(.+?),.+?\\)`\n\nReplace: `\\\\ts\\\\arrayContains($2, $3)`\n\n\n### Debug Functions\n\n#### `print_r`\n\nWhen passing true, this returns a string, for example\n```php\n\u003c?php\n$string=\\print_r(['a'=\u003e1], true);\n```\nTo make this type safe, we replace with \n```php\n\u003c?php\n$string = \\ts\\varToString(['a'=\u003e1]);\n```\n\n## Reflection\n\n### ReflectionClass\n\nAlways returns a single type\n\nNormalises the type, for example to empty strings or throws exceptions on failure\n\n#### Find Replace\n| Find  | Replace   |\n|---|---|\n|`new \\ReflectionClass` | `new \\ts\\Reflection\\ReflectionClass` |\n| `: \\ReflectionClass`  | `: \\ts\\Reflection\\ReflectionClass` |\n| `@var \\ReflectionClass` | `@var \\ts\\Reflection\\ReflectionClass ` |\n| `(\\ReflectionClass $` | `(\\ts\\Reflection\\ReflectionClass $` |\n| `@param \\ReflectionClass $` | `@param \\ts\\Reflection\\ReflectionClass $ ` |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedmondscommerce%2Ftypesafe-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedmondscommerce%2Ftypesafe-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedmondscommerce%2Ftypesafe-functions/lists"}