All PHP functions, rewritten to throw exceptions instead of returning false

Overview

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Continuous Integration codecov

Safe PHP

This project is deprecated

Because of how this project needs to be in sync with the official PHP documentation, maintaining a set of functions for PHP 7 is simply too difficult, which means we have to drop support for versions below PHP 8.

On the other hand, because this project is used in other libraries, I cannot actually change the PHP dependency in composer.json to ^8.0 without risking some huge versions conflicts.

So the only solution I see is to create a new project: Safe8.

The old safe library will stay on Packagist, but it won't be updated anymore.

Work in progress

A set of core PHP functions rewritten to throw exceptions instead of returning false when an error is encountered.

The problem

Most PHP core functions were written before exception handling was added to the language. Therefore, most PHP functions do not throw exceptions. Instead, they return false in case of error.

But most of us are too lazy to check explicitly for every single return of every core PHP function.

// This code is incorrect. Twice.
// "file_get_contents" can return false if the file does not exists
// "json_decode" can return false if the file content is not valid JSON
$content = file_get_contents('foobar.json');
$foobar = json_decode($content);

The correct version of this code would be:

$content = file_get_contents('foobar.json');
if ($content === false) {
    throw new FileLoadingException('Could not load file foobar.json');
}
$foobar = json_decode($content);
if (json_last_error() !== JSON_ERROR_NONE) {
    throw new FileLoadingException('foobar.json does not contain valid JSON: '.json_last_error_msg());
}

Obviously, while this snippet is correct, it is less easy to read.

The solution

Enter thecodingmachine/safe aka Safe-PHP.

Safe-PHP redeclares all core PHP functions. The new PHP functions act exactly as the old ones, except they throw exceptions properly when an error is encountered. The "safe" functions have the same name as the core PHP functions, except they are in the Safe namespace.

use function Safe\file_get_contents;
use function Safe\json_decode;

// This code is both safe and simple!
$content = file_get_contents('foobar.json');
$foobar = json_decode($content);

All PHP functions that can return false on error are part of Safe. In addition, Safe also provide 2 'Safe' classes: Safe\DateTime and Safe\DateTimeImmutable whose methods will throw exceptions instead of returning false.

PHPStan integration

Yeah... but I must explicitly think about importing the "safe" variant of the function, for each and every file of my application. I'm sure I will forget some "use function" statements!

Fear not! thecodingmachine/safe comes with a PHPStan rule.

Never heard of PHPStan before? Check it out, it's an amazing code analyzer for PHP.

Simply install the Safe rule in your PHPStan setup (explained in the "Installation" section) and PHPStan will let you know each time you are using an "unsafe" function.

The code below will trigger this warning:

$content = file_get_contents('foobar.json');

Function file_get_contents is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\file_get_contents;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.

Installation

Use composer to install Safe-PHP:

$ composer require thecodingmachine/safe

Highly recommended: install PHPStan and PHPStan extension:

$ composer require --dev thecodingmachine/phpstan-safe-rule

Now, edit your phpstan.neon file and add these rules:

includes:
    - vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon

Automated refactoring

You have a large legacy codebase and want to use "Safe-PHP" functions throughout your project? PHPStan will help you find these functions but changing the namespace of the functions one function at a time might be a tedious task.

Fortunately, Safe comes bundled with a "Rector" configuration file. Rector is a command-line tool that performs instant refactoring of your application.

Run

$ composer require --dev rector/rector:^0.7

to install rector/rector.

Run

vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate-0.7.php

to run rector/rector.

Note: do not forget to replace "src/" with the path to your source directory.

Important: the refactoring only performs a "dumb" replacement of functions. It will not modify the way "false" return values are handled. So if your code was already performing error handling, you will have to deal with it manually.

Especially, you should look for error handling that was already performed, like:

if (!mkdir($dirPath)) {
    // Do something on error
}

This code will be refactored by Rector to:

if (!\Safe\mkdir($dirPath)) {
    // Do something on error
}

You should then (manually) refactor it to:

try {
    \Safe\mkdir($dirPath));
} catch (\Safe\FilesystemException $e) {
    // Do something on error
}

Performance impact

Safe is loading 1000+ functions from ~85 files on each request. Yet, the performance impact of this loading is quite low.

In case you worry, using Safe will "cost" you ~700ยตs on each request. The performance section contains more information regarding the way we tested the performance impact of Safe.

Learn more

Read the release article on TheCodingMachine's blog if you want to learn more about what triggered the development of Safe-PHP.

Contributing

The files that contain all the functions are auto-generated from the PHP doc. Read the CONTRIBUTING.md file to learn how to regenerate these files and to contribute to this library.

Comments
  • Cannot redeclare Safe\array_combine()

    Cannot redeclare Safe\array_combine()

    Hi there, congrats on the project, I just discovered it and I think is great.

    Now, I've tried to add it to one of my libraries and now when I run phpstan (with our without the rule) I get the following error:

    PHP Fatal error:  Cannot redeclare Safe\array_combine() (previously declared in /home/user/project/vendor/thecodingmachine/safe/generated/array.php:20) in /home/user/project/vendor/thecodingmachine/safe/generated/array.php on line 20
    
    Fatal error: Cannot redeclare Safe\array_combine() (previously declared in /home/user/project/vendor/thecodingmachine/safe/generated/array.php:20) in /home/user/project/vendor/thecodingmachine/safe/generated/array.php on line 20
    
    In array.php line 20:
                                                                                                                                                                  
      Cannot redeclare Safe\array_combine() (previously declared in /home/user/project/vendor/thecodingmachine/safe/generated/array.php:20)  
                                                                                                                                                                  
    

    The file obviously don't have the function declared twice and I'm completely lost as for where it could be coming from. Any ideas? I'm on 1.3.3.

    Thanks!

    opened by j3j5 21
  • Safe\DateTimeImmutable is incompatible with PHP 8

    Safe\DateTimeImmutable is incompatible with PHP 8

    \Safe\DateTimeImmutable::createFromFormat(
        DateTime::ATOM,
        '2020-04-26T07:32:25+00:00'
    );
    

    Results in the following on PHP 8:

    Error: Call to a member function format() on null
    vendor/thecodingmachine/safe/lib/DateTimeImmutable.php:75
    vendor/thecodingmachine/safe/lib/DateTimeImmutable.php:38
    vendor/thecodingmachine/safe/lib/DateTimeImmutable.php:64
    

    Tested on v1.3.2.

    opened by sanmai 15
  • Rename file functions by adding a suffix

    Rename file functions by adding a suffix

    As mentioned on #333 , this is different approach at fixing #253. I believe this approach is better, cleaner and more scalable since it makes it impossible to confuse the autoloader with the filename and its PSR4 file path.

    I've tested it on https://github.com/nepda/phpstan-larastan-bug and it works perfectly.

    Let me know your thoughts.

    opened by j3j5 10
  • Performance issue

    Performance issue

    Scanning of lib.php by PHPStorm alone takes several minutes. We should also check performance for PHP.

    TODO: try to split the file in several smaller files?

    opened by moufmouf 9
  • Fix fputcsv annotation

    Fix fputcsv annotation

    During #316 I restricted the type of the $field argument, and that triggered my static analysis tools while importing the fix.

    As shown in https://3v4l.org/ahdmn, the original fputcsv function will try to cast everything to string, so every scalar is safe, array are risky (they become Array), objects explode, with the exception of stringable ones.

    opened by Jean85 8
  • Date Period Iteration

    Date Period Iteration

    This test-case is a bit indirect, but it looks like doing iteration with a \DatePeriod object messes up the internal state (so calling any methods that depend on it will fail, format in this example).

    I don't have a fix... suggestions?

    opened by rodnaph 8
  • \array is not array

    \array is not array

    #333 introduces change where return type with array is defined as:

    @return \array Returns an array.
    

    phpstan doesn't recognize now it as array, so it's break things

    opened by snapshotpl 7
  • Fix generator

    Fix generator

    This fix generate the functions with the last data. Recent changes in https://github.com/php/doc-en have been made, especially on the variadic arguments.

    You will find multiple changes here:

    • trim phpdoc: this remove trailing right space on the phpdoc
    • add a position parameter to PhpStanFunction::getParameter so we can find the right parameter using the position, instead of the name, because sometimes parameter name differs between phpstan and php/doc-en.
    • change the way to detect variadic parameters, since it has change in php/doc-en
    • fix com_load_typelib and sem_get function definition, because their definition is wrong in phpstan
    • add a test in MethodTest
    opened by asbiin 7
  • Hard-coding coveralls secret

    Hard-coding coveralls secret

    Putting the Coveralls secret in clear text (to be able to have coveralls info in forks) This means anyone can push information in Safe coveralls. We are ok with that "risk"

    opened by moufmouf 7
  • Replace PSR-4 with classmap autoloader

    Replace PSR-4 with classmap autoloader

    I am once again ~asking for your support~ trying to fix #253.

    I think this is the best approach (as discussed on the phpdocparser issue ) and it's also much less disruptive than the renaming of all files done in #338.

    I've tested the code with this repo, but please, test it yourselves to make sure I don't break anything else again :stuck_out_tongue:

    Hope this is the good one!

    opened by j3j5 6
  • Add .gitattributes

    Add .gitattributes

    Hello!

    Is it possible to get a .gitattributes file added to this repo?

    See https://medium.com/@pablorsk/be-a-git-ninja-the-gitattributes-file-e58c07c9e915 and https://madewithlove.be/gitattributes/ for more information

    Thanks!

    opened by reedy 6
  • specify Safe\createFromMutable return changing type for php8.2

    specify Safe\createFromMutable return changing type for php8.2

    When migrating to PHP8.2 I have the following issue with Safe\createFromMutable

    Capture dโ€™eฬcran 2022-12-28 aฬ€ 15 07 43

    Adding #[\ReturnTypeWillChange] fixes it.

    I don't know if it's the best solution, but it's my proposition.

    Feel free to tell me what should be done if this not the appropriate solution

    opened by MarvinCourcier 0
  • Fix: the json_last_error will not reset when using JSON_THROW_ON_ERROR flag

    Fix: the json_last_error will not reset when using JSON_THROW_ON_ERROR flag

    The PHP has a problem that the json_last_error will not reset when turning on the JSON_THROW_ON_ERROR flag.

    • see: https://github.com/php/php-src/issues/10166

    When I call \Safe\json_decode(...,JSON_THROW_ON_ERROR) after \json_decode("\00 invalid json"), and then the \Safe\json_decode() function throws an exception always because json_last_error was not reset.

    I fixed the problem with this pull request. And I did add tests.

    opened by m3m0r7 0
  • mktime (and gmmktime) may still return false in PHP 8+

    mktime (and gmmktime) may still return false in PHP 8+

    In #385, mktime was deprecated in this lib, but technically I think mktime will still return false in an unusual situation:

    https://github.com/php/php-src/blob/master/ext/date/php_date.c#L1156

    Before digging into php-src to see if it would still return false I explored changing the stubs in phpstan (because with the change in #385 in place, I get phpstan errors about using deprecated functions, but if I remove use function Safe\mktime; then I get the possible false return type, which PHPStan catches in other places, like when passed to the date function).

    https://github.com/phpstan/phpstan-src/pull/1768

    While it does seem to be an unusual situation (I can't make it return false on 3v4l.org https://3v4l.org/SZSk4), it's still technically correct.

    We have to pin this lib at 2.3.7 to avoid these phpstan errors, should mktime and gmmktime be "undeprecated"?

    opened by jaydiablo 0
  • preg_match_all wrongfully returns null

    preg_match_all wrongfully returns null

    preg_match_all returns ?int

    This is (as far as I can tell) not correct, this method could only ever return an integer.

    This seems to have been introduced by https://github.com/thecodingmachine/safe/pull/335 in this commit https://github.com/thecodingmachine/safe/pull/335/commits/e87c187d649a1a1afd524ed52f0f56a6981c40af

    opened by nreynis 0
Releases(v2.4.0)
  • v2.4.0(Oct 7, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/394
    • stream_filter_append & stream_filter_prepend use mixed instead of array by @ildyria in https://github.com/thecodingmachine/safe/pull/395

    New Contributors

    • @ildyria made their first contribution in https://github.com/thecodingmachine/safe/pull/395

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.3.1...v2.4.0

    Source code(tar.gz)
    Source code(zip)
  • v2.3.1(Sep 20, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/391
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/393
    • Fix undefined sleep() function due to autoloading issue by @colinodell in https://github.com/thecodingmachine/safe/pull/390

    New Contributors

    • @colinodell made their first contribution in https://github.com/thecodingmachine/safe/pull/390

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.3.0...v2.3.1

    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Sep 13, 2022)

    What's Changed

    • Link to step 1 rather then svn update by @alexandreelise in https://github.com/thecodingmachine/safe/pull/378
    • Update rector-migrate.php to support latest Rector by @alexandreelise in https://github.com/thecodingmachine/safe/pull/372
    • Use specific result variable name by @szepeviktor in https://github.com/thecodingmachine/safe/pull/377
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/379
    • Update README.md by @msng in https://github.com/thecodingmachine/safe/pull/383
    • deprecated mktime and regenerated the files by @Kharhamel in https://github.com/thecodingmachine/safe/pull/385
    • WIP: FIX: changed openssl functions typehinting from ressource to OpenSSLCertificate by @Kharhamel in https://github.com/thecodingmachine/safe/pull/381
    • deprecated sleep() by @Kharhamel in https://github.com/thecodingmachine/safe/pull/387
    • FEATURE: fgetcsv now returns false on end of file by @Kharhamel in https://github.com/thecodingmachine/safe/pull/388

    New Contributors

    • @alexandreelise made their first contribution in https://github.com/thecodingmachine/safe/pull/378
    • @msng made their first contribution in https://github.com/thecodingmachine/safe/pull/383

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.3...v2.3.0

    Source code(tar.gz)
    Source code(zip)
  • v2.2.3(Aug 4, 2022)

    What's Changed

    • Bump guzzlehttp/guzzle from 7.4.3 to 7.4.5 in /generator by @dependabot in https://github.com/thecodingmachine/safe/pull/367
    • Update .gitattributes to export-ignore additional files by @TimWolla in https://github.com/thecodingmachine/safe/pull/371
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/373
    • issue 324: change parameter name from options to flags by @MarcinGladkowski in https://github.com/thecodingmachine/safe/pull/376
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/374

    New Contributors

    • @TimWolla made their first contribution in https://github.com/thecodingmachine/safe/pull/371
    • @MarcinGladkowski made their first contribution in https://github.com/thecodingmachine/safe/pull/376

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.2...v2.2.3

    Source code(tar.gz)
    Source code(zip)
  • v2.2.2(Jul 20, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/364
    • FIX: Deprecated array_replace and array_replace_recursive by @Kharhamel in https://github.com/thecodingmachine/safe/pull/369
    • Fixed an error with the CurlException by @Kharhamel in https://github.com/thecodingmachine/safe/pull/370

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.1...v2.2.2

    Source code(tar.gz)
    Source code(zip)
  • v2.2.1(Jun 9, 2022)

    What's Changed

    • FIX: regenerated the files without losing support for date by @Kharhamel in https://github.com/thecodingmachine/safe/pull/362
    • Bump guzzlehttp/guzzle from 7.4.2 to 7.4.3 in /generator by @dependabot in https://github.com/thecodingmachine/safe/pull/359

    New Contributors

    • @dependabot made their first contribution in https://github.com/thecodingmachine/safe/pull/359

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.2.0...v2.2.1

    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(May 25, 2022)

    What's Changed

    • Replace PSR-4 with classmap autoloader by @j3j5 in https://github.com/thecodingmachine/safe/pull/350
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/354
    • Updating the dev-master alias by @moufmouf in https://github.com/thecodingmachine/safe/pull/347
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/355
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/358
    • Make Safe\Exceptions\JsonException inherits from \JsonException by @jdecool in https://github.com/thecodingmachine/safe/pull/357

    New Contributors

    • @jdecool made their first contribution in https://github.com/thecodingmachine/safe/pull/357

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.4...v2.2.0

    Source code(tar.gz)
    Source code(zip)
  • v2.2-alpha(May 9, 2022)

    This is an alpha to test @j3j5 new autoloading structure to try to fix #235 once and for all.

    This shouldn't break anything but better safe than sorry

    Source code(tar.gz)
    Source code(zip)
  • v2.1.4(May 2, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/339
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/340
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/341
    • FEATURE: array_combine is now deprecated by @Kharhamel in https://github.com/thecodingmachine/safe/pull/346
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/342
    • Fix CS in rector-migrate.php by @szepeviktor in https://github.com/thecodingmachine/safe/pull/349
    • FEATURE: added back imagecreatefromstring by @Kharhamel in https://github.com/thecodingmachine/safe/pull/353

    New Contributors

    • @j3j5 made their first contribution in https://github.com/thecodingmachine/safe/pull/333

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.3...v2.1.4

    Source code(tar.gz)
    Source code(zip)
  • v2.1.3(Mar 30, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/326
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/329
    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/330
    • Phpstan/update by @Kharhamel in https://github.com/thecodingmachine/safe/pull/335
    • FIX: the generator now ignore the number typehints from phpstan by @Kharhamel in https://github.com/thecodingmachine/safe/pull/336

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.2...v2.1.3

    Source code(tar.gz)
    Source code(zip)
  • v2.1.2(Feb 1, 2022)

    What's Changed

    • bring in curl handles by @mmoll in https://github.com/thecodingmachine/safe/pull/322

    New Contributors

    • @mmoll made their first contribution in https://github.com/thecodingmachine/safe/pull/322

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.1.1...v2.1.2

    Source code(tar.gz)
    Source code(zip)
  • v2.1.1(Jan 25, 2022)

    What's Changed

    • 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

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Jan 18, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/321
    • Adding back some removed functions for PHP 8 (adding as deprecated) by @jaydiablo in https://github.com/thecodingmachine/safe/pull/320

    New Contributors

    • @jaydiablo made their first contribution in https://github.com/thecodingmachine/safe/pull/320

    Full Changelog: https://github.com/thecodingmachine/safe/compare/v2.0.2...v2.1.0

    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(Jan 11, 2022)

    What's Changed

    • 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

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Jan 11, 2022)

    What's Changed

    • Automatically regenerate the files by @github-actions in https://github.com/thecodingmachine/safe/pull/311
    • Curl init by @Kharhamel in https://github.com/thecodingmachine/safe/pull/315
    • FEATURE: move the file CustomPhpStanFunctionMap to the config directory and improved the cache CI by @Kharhamel in https://github.com/thecodingmachine/safe/pull/319

    Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0...v2.0.1

    Source code(tar.gz)
    Source code(zip)
  • 2.0(Jan 3, 2022)

    This release finally brings PHP8 support! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

    If you find any issues, please report them and feel free to contribute your own PRs as well!

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.3(Oct 17, 2021)

    What's Changed

    • Empty strings functions by @Kharhamel in https://github.com/thecodingmachine/safe/pull/303
    • Improved scanner to only look at the "returnvalues" sections by @Duroth in https://github.com/thecodingmachine/safe/pull/305

    Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0.0-alpha.2...2.0.0-alpha.3

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.2(Oct 16, 2021)

    What's Changed

    • Prevent generic syntax from messing up php native types by @dbrekelmans in https://github.com/thecodingmachine/safe/pull/290
    • FIX: updated the regexp to detect class_implements by @Kharhamel in https://github.com/thecodingmachine/safe/pull/296
    • FIX: updated the generator phpstan to 0.12.99 by @Kharhamel in https://github.com/thecodingmachine/safe/pull/299
    • Fix createFromMutable error by @dbrekelmans in https://github.com/thecodingmachine/safe/pull/298
    • Fixed else statement code style by @nusje2000 in https://github.com/thecodingmachine/safe/pull/297
    • Fixed function definition from containing unnecessary spaces by @nusje2000 in https://github.com/thecodingmachine/safe/pull/300
    • Fix whitespace by @dbrekelmans in https://github.com/thecodingmachine/safe/pull/301
    • generate imagegrabwindow by @dbrekelmans in https://github.com/thecodingmachine/safe/pull/302

    New Contributors

    • @nusje2000 made their first contribution in https://github.com/thecodingmachine/safe/pull/297

    Special thanks

    • Special thanks to @Duroth for checking which generated files require fixes

    Full Changelog: https://github.com/thecodingmachine/safe/compare/2.0.0-alpha.1...2.0.0-alpha.2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.1(Oct 1, 2021)

    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!

    Source code(tar.gz)
    Source code(zip)
  • v1.3.3(Oct 28, 2020)

  • v1.3.2(Oct 22, 2020)

    Changelog:

    • added the date and gmdate functions ( #246 )
    • imap_fetchstructure, imap_mail_compose and imap_sort were automatically added because of the updated documentation.
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Oct 8, 2020)

  • v1.3.0(Oct 6, 2020)

    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

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Sep 25, 2020)

  • v1.2.0(Sep 3, 2020)

    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 )

    Source code(tar.gz)
    Source code(zip)
  • v1.1.3(Jul 10, 2020)

  • v1.1.2(Jun 24, 2020)

  • v1.1.1(May 4, 2020)

  • v1.1(Mar 24, 2020)

    Changelog:

    • Now depends on the github mirror for the PHP documentation (https://github.com/salathe/phpdoc-base and https://github.com/php/doc-en)

    • Drop support for unsupported versions of rector/rector (#209)

    • Regenerated files

    • Switch our CI environment to github actions

    • Now actually run the pipelines on php7.4 (#212)

    A big thanks to @localheinz for basically everything in this release!

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jan 21, 2020)

Owner
TheCodingMachine
TheCodingMachine
A beautiful, fully open-source, tunneling service - written in pure PHP

Expose A completely open-source ngrok alternative - written in pure PHP. Documentation For installation instructions, in-depth usage and deployment de

Beyond Code 3.9k Dec 29, 2022
PHP client library for the Square Connect APIs

Square Connect PHP SDK - RETIRED replaced by square/square-php-sdk NOTICE: Square Connect PHP SDK retired The Square Connect PHP SDK is retired (EOL)

Square 113 Dec 30, 2022
A PHP parser for TOML

TOML parser for PHP A PHP parser for TOML compatible with TOML v0.4.0. Support: Installation Requires PHP >= 7.1. Use Composer to install this package

Yo! Symfony 175 Dec 26, 2022
Simple yet expressive schema-based configuration library for PHP apps

league/config helps you define nested configuration arrays with strict schemas and access configuration values with dot notation.

The League of Extraordinary Packages 282 Jan 6, 2023
This library can parse a TypeSchema specification either from a JSON file, or from PHP classes using reflection and annotations.

This library can parse a TypeSchema specification either from a JSON file, or from PHP classes using reflection and annotations. Based on this schema it can generate source code and transform raw JSON data into DTO objects. Through this you can work with fully typed objects in your API for incoming and outgoing data.

Apioo 54 Jul 14, 2022
LOAD is a PHP library for configuration loading to APCu

LOAD LOAD is a PHP library for configuration loading to APCu Sources Available sources for configuration loading are: PHP file Consul Environment vari

Beat Labs 4 Jan 18, 2022
An object-oriented option parser library for PHP, which supports type constraints, flag, multiple flag, multiple values, required value checking

GetOptionKit Code Quality Versions & Stats A powerful option parser toolkit for PHP, supporting type constraints, flag, multiple flag, multiple values

Yo-An Lin 140 Sep 28, 2022
Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and string

Config Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and strings. Requirements Config

Hassan Khan 946 Jan 1, 2023
All PHP functions, rewritten to throw exceptions instead of returning false

Safe PHP This project is deprecated Because of how this project needs to be in sync with the official PHP documentation, maintaining a set of function

TheCodingMachine 2.1k Dec 28, 2022
All PHP functions, rewritten to throw exceptions instead of returning false, now for php8

A set of core PHP functions rewritten to throw exceptions instead of returning false when an error is encountered.

TheCodingMachine 106 Nov 21, 2022
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.

Phan is a static analyzer for PHP that prefers to minimize false-positives. Phan attempts to prove incorrectness rather than correctness. Phan looks f

null 5.4k Jan 7, 2023
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Zeeshan Ahmad 20 Dec 8, 2018
This is a plugin for pocketmine-mp, when locking a player's items helps players not to lose items or throw things around causing server lag.

[] LockedItem| v1.0.0 Player's item lock Features Player's item lock Players aren't afraid of losing items For Devolopers You can access to LockedItem

JeroGamingYT 3 Jan 4, 2022
๐Ÿ† Learn You PHP! - An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

Learn You PHP! The very first PHP School workshop. A revolutionary new way to learn PHP Bring your imagination to life in an open learning eco-system

PHP School 311 Dec 30, 2022
Here is the top 100 PHP functions: it is the list of the most often used PHP native functions

Here is the top 100 PHP functions: it is the list of the most often used PHP native functions. If you are a PHP developer, you must know the Top 100 PHP Functions deeply.

Max Base 16 Dec 11, 2022
Laravel Jsonable - Well-Formated Responses & Exceptions.

Laravel Jsonable Well-Formated Responses & Exceptions. Documentation You can find the detailed documentation here in Laravel Jsonable Documentation. C

Pharaonic 1 Aug 7, 2022
A PocketMine-MP plugin for logging Exceptions to a Sentry server

Sentry A PocketMine-MP plugin for logging Exceptions to a Sentry server. Asynchronous logging If you want to log exceptions in a thread-safe way, you

null 4 Apr 9, 2022
LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

Tyler Arbon 437 Nov 17, 2022
Service that helps you to send notifications for a series of failed exceptions.

Laravel Failure Notifier This package helps you to track your exceptions and do what you want to do with them such as sending an SMS or and Email. You

Kamyar Gerami 7 Nov 26, 2022
Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Kodols 9 Dec 22, 2022