safe icon indicating copy to clipboard operation
safe copied to clipboard

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

Results 109 safe issues
Sort by recently updated
recently updated
newest added

Just like we do with functions, it would be great to be able to overload objects that have methods returning false instead of throwing exceptions.

enhancement
missing function

This code ``` /** @test */ public function it_fails_with_bad_message(): void { \Safe\DateTime::createFromFormat('U',$this->generate_error()); } public function generate_error() { @include "non_exist_file.php"; //some soppred error return (new \DateTime())->getTimestamp().'x'; } ``` Produce this otput...

enhancement

As seen in #227, DatePeriod can take Safe\DateTimeImmutable as parameter but will mess its internal state and overall won't work correctly. The only workaround is to switch batch to \DateTimeImmutable...

enhancement

| Q | A | ---------------- | --- | Safe version | ^0.11.12 | PHP version | 7.4.0 | PHP Strict Type? | True | | Operating system | MacOS...

`preg_replace_callback` and `preg_replace_callback_array` can return null on error. Looks like job for safe lib

In order to more easily solve #175 and #141, it may be easier to simply extract the needed infos from psalm's functions stubs instead of trying to recalculate them. This...

Currently methods like `preg_replace` have a return type of `string|array` specified. When in reality that return type is dependant on the input. Static analysis tools, like PHPStan and Psalm can...

Hi, it looks like common file functions such as `fread()` and `fwrite()` are present, but not `fgets()`. Could you please add it? Thanks!

question
missing function

> ErrorException/src/Mail/ImapManager.php in App\Mail\ImapManager::connect > Warning: imap_open(): Couldn't open stream {mail.foo-bar.de:993/ssl/novalidate-cert} Hi,. the following code results in a warning before using `\Safe\imap_open`: ```php $stream = imap_open( sprintf('{%s:%d/ssl/novalidate-cert}', $this->host, $this->port), $this->username,...

https://psalm.dev/articles/immutability-and-beyond#purity