PHPackages                             edmondscommerce/typesafe-functions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. edmondscommerce/typesafe-functions

ActiveProject

edmondscommerce/typesafe-functions
==================================

Type safe wrappers around internal functions that return mixed types

0.2(6y ago)016.2k↓25%[1 issues](https://github.com/edmondscommerce/typesafe-functions/issues)3MITPHPPHP ^7.2

Since Jul 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/edmondscommerce/typesafe-functions)[ Packagist](https://packagist.org/packages/edmondscommerce/typesafe-functions)[ RSS](/packages/edmondscommerce-typesafe-functions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (20)Used By (3)

Typesafe Functions
==================

[](#typesafe-functions)

To 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

See Alternative:
----------------

[](#see-alternative)

This is a more comprehensive library of functions that is auto generated.

I 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.

Functions Replaced:
-------------------

[](#functions-replaced)

### File Functions

[](#file-functions)

#### `file_get_contents`

[](#file_get_contents)

returns false|string by default

replaced with `\ts\file_get_contents`

### String Functions

[](#string-functions)

#### `strpos`

[](#strpos)

returns false|int by default

multiple replacements depending on use case:

`\ts\strpos` to get the actual string position when it is known that the haystack contains the needle

`\ts\stringContains` to check if the haystack contains the needle

`\ts\stringStartsWith` to check if the haystack begins with the needle

#### `stripos`

[](#stripos)

//TODO - but will be as above, but case insensitive

### Array Functions

[](#array-functions)

#### `in_array`

[](#in_array)

By default this is not strict and requires a third parameter of true.

Simply replace with `\ts\arrayContains` instead to have this handled automatically.

This improves readability and also prevents various mutation testing escapees that would be otherwise hard to catch

Find: `(|\\)in_array\((.+?),(.+?),.+?\)`

Replace: `\\ts\\arrayContains($2, $3)`

### Debug Functions

[](#debug-functions)

#### `print_r`

[](#print_r)

When passing true, this returns a string, for example

```
