NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #218 most downloaded on Packagist
PHP core functions that throw exceptions instead of returning FALSE on error
Latest stable
v3.4.0
Last release 3 days ago
18 Nov 2026
Ships unpredictably
gaps range from 2 weeks to 1.8 years
Nearly every release is documented
notes for 54 of 56 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
69 releases · first in 2018
Drag across the ruler to compare, or tap a release to open it.
Fix PHP 8.6 deprecations from DateTimeImmutable tentative return types by @dhrupo in #767
preg_replace() use generics by @alexchexes in #705Full Changelog: v3.4.0...v3.5.0-beta1
Your coding agent can read these notes before it upgrades. Set up the MCP server →
The major things are the first three changes - removing and deduplicating content so that new versions of PHP can be supported with relatively small i
The major things are the first three changes - removing and deduplicating content so that new versions of PHP can be supported with relatively small increases to the total package size (and the corresponding addition of initial php8.6 support)
passthru on PHP 8.1 by @silasjoisten in #691hash_file() and hash_hmac_file() functions by @cedric-anne in #694download-docs command by @silasjoisten in #697ftp_raw by @silasjoisten in #693composer.json by @silasjoisten in #698scan-objects command by @silasjoisten in #699Full Changelog: v3.3.0...v3.4.0
Add safe wrapper fo unserialize
Add safe wrapper fo unserialize
Fix mktime() on PHP 8.2 and 8.3 by @cedric-anne in #670
mktime() on PHP 8.2 and 8.3 by @cedric-anne in #670long2ip() that is actually safe by @cedric-anne in #671array_combine() on PHP 8.1 by @cedric-anne in #672array_flip() on PHP 8.1 by @cedric-anne in #673array_replace() / array_replace_recursive() on PHP 8.1 by @cedric-anne in #674gmp_random_seed() on PHP 8.1 by @cedric-anne in #677hash_hkdf() on PHP 8.1 by @cedric-anne in #678sleep() on PHP 8.1 by @cedric-anne in #679imagecolorsforindex() on PHP 8.1 by @cedric-anne in #680mysqli_get_client_stats() on PHP 8.1 by @cedric-anne in #681stream_socket_get_name() on PHP 8.1 by @cedric-anne in #683apache_request_headers()/apache_response_headers() on PHP < 8.4 by @cedric-anne in #684shuffle() on PHP < 8.4 by @cedric-anne in #685curl_share_errno() on PHP < 8.4 by @cedric-anne in #686date_parse() on PHP < 8.4 by @cedric-anne in #688date_sun_info() on PHP < 8.4 by @cedric-anne in #689openssl_random_pseudo_bytes() on PHP 8.1 by @cedric-anne in #682date_create() on PHP < 8.4 by @cedric-anne in #687Full Changelog: v3.2.0...v3.3.0
fix typehint for ini_set, see #133 by @shish in #661
pack() function by @cedric-anne in #664gmmktime()/mktime() on PHP 8.4+ by @cedric-anne in #667array_walk_recursive() function by @cedric-anne in #666getallheaders() function by @cedric-anne in #668imagesx()/imagesy() functions by @cedric-anne in #669date() function by @cedric-anne in #665Full Changelog: v3.1.1...v3.2.0
Automatically regenerate the files by @github-actions in #652
openssl_random_pseudo_bytes always returns string (closes #654) by @mvhirsch in #658Full Changelog: v3.1.0...v3.1.1
Automatically regenerate the files by @github-actions in #639
Full Changelog: v3.0.2...v3.0.3
Be consistent in using more-specific types in docblocks by @shish in #635
What's Changed (Externally visible)
pg_copy_from) by @shish in #632Full Changelog: v3.0.0...v3.0.1
Compatibility with PHP 8.4 - no more syntax deprecation warnings
-1 on error)json_last_error check when JSON_THROW_ON_ERROR flag is set in json_decode by @marmichalski in #451non-empty-string / non-falsey-string in docblocks, fixes #398 by @shish in #577Note truncated.
add return statements to functionsList.php
add return statements to functionsList.php
Nothing published for this version
Nothing published for this version
Nothing published for this version
Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/397
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.4.0...v2.5.0
Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/394
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.3.1...v2.4.0
Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/391
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.3.0...v2.3.1
deprecated mktime and regenerated the files by @Kharhamel in https://github.com/thecodingmachine/safe/pull/385
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.3...v2.3.0
Bump guzzlehttp/guzzle from 7.4.3 to 7.4.5 in /generator by @dependabot in https://github.com/thecodingmachine/safe/pull/367
export-ignore additional files by @TimWolla in https://github.com/thecodingmachine/safe/pull/371Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.2...v2.2.3
FIX: Deprecated array_replace and array_replace_recursive by @Kharhamel in https://github.com/thecodingmachine/safe/pull/369
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.1...v2.2.2
FIX: regenerated the files without losing support for date by @Kharhamel in https://github.com/thecodingmachine/safe/pull/362
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.0...v2.2.1
Replace PSR-4 with classmap autoloader by @j3j5 in https://github.com/thecodingmachine/safe/pull/350
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.4...v2.2.0
FEATURE: array_combine is now deprecated by @Kharhamel in https://github.com/thecodingmachine/safe/pull/346
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.3...v2.1.4
Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/326
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.2...v2.1.3
bring in curl handles by @mmoll in https://github.com/thecodingmachine/safe/pull/322
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.1...v2.1.2
Fixed return type of DateTimeImmutable by @nusje2000 in https://github.com/thecodingmachine/safe/pull/323
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.0...v2.1.1
Adding back some removed functions for PHP 8 (adding as deprecated) by @jaydiablo in https://github.com/thecodingmachine/safe/pull/320
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.0.2...v2.1.0
Fix fputcsv annotation by @Jean85 in https://github.com/thecodingmachine/safe/pull/318
Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.0.1...v2.0.2
Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/311
Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0...v2.0.1
Empty strings functions by @Kharhamel in https://github.com/thecodingmachine/safe/pull/303
Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0.0-alpha.2...2.0.0-alpha.3
Prevent generic syntax from messing up php native types by @dbrekelmans in https://github.com/thecodingmachine/safe/pull/290
Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0.0-alpha.1...2.0.0-alpha.2
This release adds support for PHP8 and drops support for PHP7.x and lower.
This release adds support for PHP8 and drops support for PHP7.x and lower.
Give it a try and let us know through github issues if you encounter any problems!
Changelog: * Fixed a bug with socket_write * Updated the readme
Changelog:
added the date and gmdate functions
Changelog:
Changelog: * jdtounix was added
Changelog:
A lot of functions were removed from the php doc. Rather than also removing them from safe, I decided to move them to a deprecated folder. The functio…
Changelog:
A lot of functions were removed from the php doc. Rather than also removing them from safe, I decided to move them to a deprecated folder. The functions should still be usables, although they should be flagged as deprecated in a future feature.
'imagepsencodefont', 'imagepsextendfont', 'imagepsfreefont', 'imagepsslantfont' were removed because their corresponding functions were removed in php7.0 , meaning theses safe functions never actually worked.
pack and unpack were added
Changelog: * Improved the github workflow * Regenerated the files
Changelog:
Added DateTimeImmutable->getInnerDateTime() and DateTimeImmutable::createFromRegular() (technically already existed but it is now a public method) to
Changelog:
Added DateTimeImmutable->getInnerDateTime() and DateTimeImmutable::createFromRegular() (technically already existed but it is now a public method) to switch easily between safe and regular versions (see #229 ) This is because a bug with DatePeriod was found (thanks @rodnaph in #227). Since the bug comes fromphp itself, we can only add workarounds: like reverting to a regular DateTimeImmutable with ->getInnerDateTime()
Fixed a bug with rector0.7 (the RenameFunction rule was, ironically, renamed) (#234 )
improved our github workflows (for example #230 )
Fixed an error where 'ressource' was used as a typehint ( #226 ). Thanks @fezfez
Added appropriates @throw tags in our custom DateTime and DateTimeImmutable
Changelog:
Nothing published for this version
fix an issue with ldap_bind() (#187) thanks @localheinz
Changelog:
Include microseconds in Date objects (#183) (thanks @kunicmarko20 )
Changelog:
fixed a bug with safe/datetimeimmutable
Changelog:
Thanks to @localheinz and @bdsl for the help!
Updated both phpstan dependancies to version 12
Changelog:
Fixs an error in the exception generation introduced in beta2
Changelog:
updated both phpstan dependancies to version 12
Changelog:
Deleted apcu_delete from the library
Changelog:
Updated the internal php doc and phpstan package used to generate our functions
Changelog:
Updated the internal php doc and phpstan package used to generate our functions
Rewrote the way parameter types and return types (both doc-block and typehints) are extracted and parsed. We now use the phpstan functionMap.php as our source of reference before falling back to the php doc (it was the oposite before). We also have a file to overwrite phpstan doc when it contains errors. As a result a lot of functions have their typehints changed, hopefully for the best. (#134 #147)
Added array_replace and array_replace_recursive. (#145 )
OpensslException now use openssl_error_string to print its error message. (#148)
Added Imagick functions (#132 )
Added ini_get (#131)
Created safe equivalents for the class DateTime and DateTimeImmutable. Theses will overload all functions in order to throw exception on errors if needed. (#138 )
Remove forward_static_call and forward_static_call_array from supported functions (#129)
Add .gitattributes (#127)
Improvements: - #114 Migrating from Rector 0.3 to Rector 0.4 file format New safe functions added: - #121 Added support for readfile, fbird_blob_cance
Improvements:
New safe functions added:
readfile, fbird_blob_cancel, ibase_backup, ibase_backup, ibase_service_attach, socket_wsaprotocol_info_export, socket_wsaprotocol_info_import, socket_wsaprotocol_info_release, readgzfilearray_flip, sapi_windows_cp_conv, socket_addrinfo_bind, socket_addrinfo_connect,socket_import_streamgethostname, getimagesizeImprovements: - #112 Added file and ssh2_sftp functions to the list of Safe functions // @j6s
Improvements:
file and ssh2_sftp functions to the list of Safe functions // @j6sThanks a lot to @jderusse for most of the issues of this release!
Bugfix:
Improvements:
Thanks a lot to @jderusse for most of the issues of this release!
Bugfix: - #91 #86 Making parameters that are passed by reference and used only for output nullable.
Bugfix:
Breaking changes: - #90 Removing array_search and mb_check_encoding from supported functions Added functions: - #84 fsockopen - #85 pspell_new_config
Breaking changes:
array_search and mb_check_encoding from supported functionsAdded functions:
fsockopenpspell_new_configBugfixes:
Minor:
Note: I exceptionally include a breaking change in this minor release. The issue is too big not to be noticed so if users are already using \Safe\call…
Breaking changes:
call_user_func_array from the list of Safe methodsNote: I exceptionally include a breaking change in this minor release. The issue is too big not to be noticed so if users are already using \Safe\call_user_func_array, they should stop at once.
New feature: - #72 #71 Added preg_replace to the list of wrapped functions (preg_replace returns null on error).
New feature:
Added array_search, filter_input_array, ldap_add_ext, ldap_bind_ext, ldap_delete_ext, ldap_mod_add_ext, ldap_mod_del_ext, ldap_mod_replace_ext, ldap_r
Bug fixes:
mktime signaturearray_search, filter_input_array, ldap_add_ext, ldap_bind_ext, ldap_delete_ext, ldap_mod_add_ext, ldap_mod_del_ext, ldap_mod_replace_ext, ldap_rename_ext, libxml_get_last_error, mysqli_get_cache_stats, mysqli_get_client_stats, oci_set_call_timeout, oci_set_db_operation, sqlsrv_client_info, sqlsrv_get_field, sqlsrv_num_fields, ssdeep_fuzzy_compare, ssdeep_fuzzy_hash_filename, ssdeep_fuzzy_hash, md5_file, sha1_file.Improvements: - #59 Adding array_combine to the list of wrapped functions
Improvements:
array_combine to the list of wrapped functionsBugfixes: - #56 preg_split $limit argument was not nullable - #57 func_get_arg cannot be wrapped because it is context-aware
Bugfixes:
func_get_arg cannot be wrapped because it is context-awareImprovements: - #52 #54 Added filesize to Safe functions.
Improvements:
filesize to Safe functions.One column per quarter.