Skip to content

Commit

Permalink
Merge pull request #164 from Kharhamel/phpstanGenerator12
Browse files Browse the repository at this point in the history
Phpstan generator12
Kharhamel authored Dec 16, 2019
2 parents b80c8ef + 7bda47a commit 50f1e60
Showing 110 changed files with 726 additions and 1,089 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ matrix:
env: PREFER_LOWEST=""
- php: 7.2
env: PREFER_LOWEST=""
- php: 7.1
env: PREFER_LOWEST=""

cache:
directories:
@@ -61,4 +59,4 @@ script:
- cd generator/tests/rector/0.5 && composer install && composer rector && composer test && cd ../../../..

after_script:
- cd generator && travis_retry php vendor/bin/php-coveralls -v
- cd generator && travis_retry php vendor/bin/php-coveralls -v --root_dir="./generator"
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@
"php": ">=7.1"
},
"require-dev": {
"phpstan/phpstan": "^0.10.3",
"thecodingmachine/phpstan-strict-rules": "^0.10.3",
"phpstan/phpstan": "^0.12",
"thecodingmachine/phpstan-strict-rules": "^0.12",
"squizlabs/php_codesniffer": "^3.2"
},
"scripts": {
6 changes: 5 additions & 1 deletion generated/Exceptions/ApacheException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ApacheException extends AbstractSafeException
class ApacheException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ApcException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ApcException extends AbstractSafeException
class ApcException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ApcuException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ApcuException extends AbstractSafeException
class ApcuException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ArrayException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ArrayException extends AbstractSafeException
class ArrayException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/Bzip2Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class Bzip2Exception extends AbstractSafeException
class Bzip2Exception extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ClassobjException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ClassobjException extends AbstractSafeException
class ClassobjException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ComException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ComException extends AbstractSafeException
class ComException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/CubridException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class CubridException extends AbstractSafeException
class CubridException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/DatetimeException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class DatetimeException extends AbstractSafeException
class DatetimeException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/DirException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class DirException extends AbstractSafeException
class DirException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/EioException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class EioException extends AbstractSafeException
class EioException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ErrorfuncException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ErrorfuncException extends AbstractSafeException
class ErrorfuncException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ExecException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ExecException extends AbstractSafeException
class ExecException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FileinfoException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FileinfoException extends AbstractSafeException
class FileinfoException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FilesystemException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FilesystemException extends AbstractSafeException
class FilesystemException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FilterException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FilterException extends AbstractSafeException
class FilterException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FpmException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FpmException extends AbstractSafeException
class FpmException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FtpException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FtpException extends AbstractSafeException
class FtpException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/FunchandException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class FunchandException extends AbstractSafeException
class FunchandException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/GmpException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class GmpException extends AbstractSafeException
class GmpException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/GnupgException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class GnupgException extends AbstractSafeException
class GnupgException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/HashException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class HashException extends AbstractSafeException
class HashException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/IbaseException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class IbaseException extends AbstractSafeException
class IbaseException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/IbmDb2Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class IbmDb2Exception extends AbstractSafeException
class IbmDb2Exception extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/IconvException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class IconvException extends AbstractSafeException
class IconvException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ImageException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ImageException extends AbstractSafeException
class ImageException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ImapException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ImapException extends AbstractSafeException
class ImapException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/InfoException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class InfoException extends AbstractSafeException
class InfoException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/IngresiiException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class IngresiiException extends AbstractSafeException
class IngresiiException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/InotifyException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class InotifyException extends AbstractSafeException
class InotifyException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/LdapException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class LdapException extends AbstractSafeException
class LdapException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/LibeventException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class LibeventException extends AbstractSafeException
class LibeventException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/LibxmlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class LibxmlException extends AbstractSafeException
class LibxmlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/LzfException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class LzfException extends AbstractSafeException
class LzfException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MailparseException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MailparseException extends AbstractSafeException
class MailparseException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MbstringException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MbstringException extends AbstractSafeException
class MbstringException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MiscException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MiscException extends AbstractSafeException
class MiscException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MsqlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MsqlException extends AbstractSafeException
class MsqlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MssqlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MssqlException extends AbstractSafeException
class MssqlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MysqlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MysqlException extends AbstractSafeException
class MysqlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MysqliException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MysqliException extends AbstractSafeException
class MysqliException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MysqlndMsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MysqlndMsException extends AbstractSafeException
class MysqlndMsException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/MysqlndQcException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class MysqlndQcException extends AbstractSafeException
class MysqlndQcException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/NetworkException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class NetworkException extends AbstractSafeException
class NetworkException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/Oci8Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class Oci8Exception extends AbstractSafeException
class Oci8Exception extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/OpcacheException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class OpcacheException extends AbstractSafeException
class OpcacheException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/OutcontrolException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class OutcontrolException extends AbstractSafeException
class OutcontrolException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PasswordException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PasswordException extends AbstractSafeException
class PasswordException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PcntlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PcntlException extends AbstractSafeException
class PcntlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PdfException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PdfException extends AbstractSafeException
class PdfException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PgsqlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PgsqlException extends AbstractSafeException
class PgsqlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PosixException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PosixException extends AbstractSafeException
class PosixException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PsException extends AbstractSafeException
class PsException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/PspellException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class PspellException extends AbstractSafeException
class PspellException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ReadlineException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ReadlineException extends AbstractSafeException
class ReadlineException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/RrdException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class RrdException extends AbstractSafeException
class RrdException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SemException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SemException extends AbstractSafeException
class SemException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SessionException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SessionException extends AbstractSafeException
class SessionException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ShmopException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ShmopException extends AbstractSafeException
class ShmopException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SimplexmlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SimplexmlException extends AbstractSafeException
class SimplexmlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SocketsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SocketsException extends AbstractSafeException
class SocketsException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SodiumException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SodiumException extends AbstractSafeException
class SodiumException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SolrException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SolrException extends AbstractSafeException
class SolrException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SplException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SplException extends AbstractSafeException
class SplException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SqlsrvException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SqlsrvException extends AbstractSafeException
class SqlsrvException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SsdeepException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SsdeepException extends AbstractSafeException
class SsdeepException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/Ssh2Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class Ssh2Exception extends AbstractSafeException
class Ssh2Exception extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/StatsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class StatsException extends AbstractSafeException
class StatsException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/StreamException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class StreamException extends AbstractSafeException
class StreamException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/StringsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class StringsException extends AbstractSafeException
class StringsException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/SwooleException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class SwooleException extends AbstractSafeException
class SwooleException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/UodbcException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class UodbcException extends AbstractSafeException
class UodbcException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/UopzException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class UopzException extends AbstractSafeException
class UopzException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/UrlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class UrlException extends AbstractSafeException
class UrlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/VarException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class VarException extends AbstractSafeException
class VarException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/XdiffException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class XdiffException extends AbstractSafeException
class XdiffException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/XmlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class XmlException extends AbstractSafeException
class XmlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/XmlrpcException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class XmlrpcException extends AbstractSafeException
class XmlrpcException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/YamlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class YamlException extends AbstractSafeException
class YamlException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/YazException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class YazException extends AbstractSafeException
class YazException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ZipException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ZipException extends AbstractSafeException
class ZipException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
6 changes: 5 additions & 1 deletion generated/Exceptions/ZlibException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
namespace Safe\Exceptions;

class ZlibException extends AbstractSafeException
class ZlibException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}
18 changes: 9 additions & 9 deletions generated/ldap.php
Original file line number Diff line number Diff line change
@@ -59,14 +59,14 @@ function ldap_add($link_identifier, string $dn, array $entry, array $serverctrls
* Does the same thing as ldap_bind but returns the LDAP result resource to be parsed with ldap_parse_result.
*
* @param resource $link_identifier
* @param string $bind_rdn
* @param string $bind_password
* @param string|null $bind_rdn
* @param string|null $bind_password
* @param array $serverctrls
* @return resource Returns an LDAP result identifier.
* @throws LdapException
*
*/
function ldap_bind_ext($link_identifier, string $bind_rdn = null, string $bind_password = null, array $serverctrls = null)
function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, array $serverctrls = null)
{
error_clear_last();
$result = \ldap_bind_ext($link_identifier, $bind_rdn, $bind_password, $serverctrls);
@@ -81,13 +81,13 @@ function ldap_bind_ext($link_identifier, string $bind_rdn = null, string $bind_p
* Binds to the LDAP directory with specified RDN and password.
*
* @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
* @param string $bind_rdn
* @param string $bind_password
* @param string|null $bind_rdn
* @param string|null $bind_password
* @param array $serverctrls Array of LDAP Controls to send with the request.
* @throws LdapException
*
*/
function ldap_bind($link_identifier, string $bind_rdn = null, string $bind_password = null, array $serverctrls = null): void
function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, array $serverctrls = null): void
{
error_clear_last();
$result = \ldap_bind($link_identifier, $bind_rdn, $bind_password, $serverctrls);
@@ -254,7 +254,7 @@ function ldap_exop_whoami($link): string
* @param resource $link An LDAP link identifier, returned by ldap_connect.
* @param string $reqoid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send.
* @param string $reqdata The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded.
* @param array $serverctrls Array of LDAP Controls to send with the request.
* @param array|null $serverctrls Array of LDAP Controls to send with the request.
* @param string|null $retdata Will be filled with the extended operation response data if provided.
* If not provided you may use ldap_parse_exop on the result object
* later to get this data.
@@ -264,7 +264,7 @@ function ldap_exop_whoami($link): string
* @throws LdapException
*
*/
function ldap_exop($link, string $reqoid, string $reqdata = null, array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null)
function ldap_exop($link, string $reqoid, string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null)
{
error_clear_last();
$result = \ldap_exop($link, $reqoid, $reqdata, $serverctrls, $retdata, $retoid);
@@ -1404,7 +1404,7 @@ function ldap_search($link_identifier, string $base_dn, string $filter, array $a
/**
* Sets the value of the specified option to be newval.
*
* @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
* @param resource|null $link_identifier An LDAP link identifier, returned by ldap_connect.
* @param int $option The parameter option can be one of:
*
*
4 changes: 2 additions & 2 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
@@ -418,7 +418,7 @@ function mb_regex_encoding(string $encoding = null)
* This parameter is not automatically encoded.
* @param string $subject The subject of the mail.
* @param string $message The message of the mail.
* @param string $additional_headers String or array to be inserted at the end of the email header.
* @param string|array|null $additional_headers String or array to be inserted at the end of the email header.
*
* This is typically used to add extra headers (From, Cc, and Bcc).
* Multiple extra headers should be separated with a CRLF (\r\n).
@@ -464,7 +464,7 @@ function mb_regex_encoding(string $encoding = null)
* @throws MbstringException
*
*/
function mb_send_mail(string $to, string $subject, string $message, string $additional_headers = null, string $additional_parameter = null): void
function mb_send_mail(string $to, string $subject, string $message, $additional_headers = null, string $additional_parameter = null): void
{
error_clear_last();
$result = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_parameter);
6 changes: 3 additions & 3 deletions generated/mysql.php
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ function mysql_db_name($result, int $row, $field = null): string
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource Returns a positive MySQL result resource to the query result. The function also returns TRUE/FALSE for
* @return resource|bool Returns a positive MySQL result resource to the query result. The function also returns TRUE/FALSE for
* INSERT/UPDATE/DELETE
* queries to indicate success/failure.
* @throws MysqlException
@@ -684,7 +684,7 @@ function mysql_num_rows($result): int
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset,
* @return resource|bool For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset,
* mysql_query
* returns a resource on success.
*
@@ -918,7 +918,7 @@ function mysql_thread_id($link_identifier = null): int
* will try to create one as if mysql_connect had been called
* with no arguments. If no connection is found or established, an
* E_WARNING level error is generated.
* @return resource For SELECT, SHOW, DESCRIBE or EXPLAIN statements,
* @return resource|bool For SELECT, SHOW, DESCRIBE or EXPLAIN statements,
* mysql_unbuffered_query
* returns a resource on success.
*
10 changes: 8 additions & 2 deletions generated/strings.php
Original file line number Diff line number Diff line change
@@ -184,7 +184,10 @@ function soundex(string $str): string
* own parameter.
*
* A conversion specification follows this prototype:
* %[flags][width][.precision]specifier.
* %[argnum$][flags][width][.precision]specifier.
*
* An integer followed by a dollar sign $,
* to specify which number argument to treat in the conversion.
*
*
* Flags
@@ -552,7 +555,10 @@ function substr(string $string, int $start, int $length = null): string
* own parameter.
*
* A conversion specification follows this prototype:
* %[flags][width][.precision]specifier.
* %[argnum$][flags][width][.precision]specifier.
*
* An integer followed by a dollar sign $,
* to specify which number argument to treat in the conversion.
*
*
* Flags
4 changes: 2 additions & 2 deletions generator/composer.json
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpstan/phpstan": "^0.11.16",
"thecodingmachine/phpstan-strict-rules": "^0.10.3",
"phpstan/phpstan": "^0.12",
"thecodingmachine/phpstan-strict-rules": "^0.12",
"squizlabs/php_codesniffer": "^3.2",
"php-coveralls/php-coveralls": "^2.1"
},
1,130 changes: 194 additions & 936 deletions generator/composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generator/src/DocPage.php
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

class DocPage
{
/*
/**
* @var string
*/
private $path;
6 changes: 5 additions & 1 deletion generator/src/FileCreator.php
Original file line number Diff line number Diff line change
@@ -150,8 +150,12 @@ public function createExceptionFile(string $moduleName): void
<?php
namespace Safe\Exceptions;

class {$exceptionName} extends AbstractSafeException
class {$exceptionName} extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new self(\json_last_error_msg(), \json_last_error());
}
}

EOF
5 changes: 3 additions & 2 deletions generator/src/GenerateCommand.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

class GenerateCommand extends Command
{
protected function configure()
protected function configure(): void
{
$this
->setName('generate')
@@ -68,14 +68,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

require_once __DIR__.'/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__.'/../../lib/Exceptions/AbstractSafeException.php';
foreach ($files as $file) {
require($file);
}

// Finally, let's edit the composer.json file
$output->writeln('Editing composer.json');
ComposerJsonEditor::editFiles(\array_values($modules));

return 0;
}

private function rmGenerated(): void
2 changes: 1 addition & 1 deletion generator/src/Method.php
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ private function getStringForXPath(string $xpath): string
return trim($str);
}

private function getDocBlockReturnType(): ?string
private function getDocBlockReturnType(): string
{
return $this->returnType->getDocBlockType($this->errorType);
}
2 changes: 0 additions & 2 deletions generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@
*/

return [
'mb_ereg_replace_callback' => ['string|false', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'option='=>'string'],
'swoole_async_writefile' => ['bool', 'filename'=>'string', 'content'=>'string', 'callback='=>'callable', 'flags='=>'int'],
'libxml_get_last_error' => ['LibXMLError|false'], //LibXMLError need to be uppercase
'gmp_random_seed' => ['void', 'seed'=>'GMP|string|int'], //gmp_random_seed doesn't return
'imageconvolution' => ['bool', 'src_im'=>'resource', 'matrix3x3'=>'array', 'div'=>'float', 'offset'=>'float'], //imageconvolution return a bool
4 changes: 2 additions & 2 deletions generator/src/PhpStanFunctions/PhpStanFunctionMapReader.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class PhpStanFunctionMapReader

public function __construct()
{
$this->functionMap = require __DIR__.'/../../vendor/phpstan/phpstan/src/Reflection/SignatureMap/functionMap.php';
$this->functionMap = require 'phar://'.__DIR__.'/../../vendor/phpstan/phpstan/phpstan.phar/src/Reflection/SignatureMap/functionMap.php';
$this->customFunctionMap = require __DIR__.'/CustomPhpStanFunctionMap.php';
}

@@ -31,7 +31,7 @@ public function getFunction(string $functionName): PhpStanFunction
$customMap = $this->customFunctionMap[$functionName] ?? null;
if ($map && $customMap) {
if ($customMap === $map) {
throw new \RuntimeException('Useless custom function map: '.var_export($customMap, true)."\nPlease delete this line from the custom file");
throw new \RuntimeException("Useless custom function map $functionName: ".var_export($customMap, true)."\nPlease delete this line from the custom file");
}
$map = $customMap;
}
3 changes: 2 additions & 1 deletion generator/src/ScanObjectsCommand.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

class ScanObjectsCommand extends Command
{
protected function configure()
protected function configure(): void
{
$this
->setName('scan-objects')
@@ -34,5 +34,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$output->writeln('These methods are overloaded: '.\implode(', ', $overloadedFunctions));
return 0;
}
}
16 changes: 11 additions & 5 deletions generator/src/Scanner.php
Original file line number Diff line number Diff line change
@@ -10,11 +10,21 @@

class Scanner
{
/*
/**
* @var string
*/
private $path;

/**
* @var string[]
*/
private $ignoredFunctions;

/**
* @var string[]
*/
private $ignoredModules;

public function __construct(string $path)
{
$this->path = $path;
@@ -42,8 +52,6 @@ public function getMethodsPaths(): array
return iterator_to_array($finder);
}

private $ignoredFunctions;

/**
* Returns the list of functions that must be ignored.
* @return string[]
@@ -59,8 +67,6 @@ private function getIgnoredFunctions(): array
return $this->ignoredFunctions;
}

private $ignoredModules;

/**
* Returns the list of modules that must be ignored.
* @return string[]
1 change: 0 additions & 1 deletion generator/tests/DateTimeImmutableTest.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ class DateTimeImmutableTest extends TestCase
protected function setUp()
{
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../generated/Exceptions/DatetimeException.php';
require_once __DIR__ . '/../../lib/DateTimeImmutable.php';
}
1 change: 0 additions & 1 deletion generator/tests/DateTimeTest.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ class DateTimeTest extends TestCase
protected function setUp()
{
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../generated/Exceptions/DatetimeException.php';
require_once __DIR__ . '/../../lib/DateTime.php';
}
6 changes: 0 additions & 6 deletions generator/tests/GeneratedFilesTest.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ public function testSprintf()
{
require_once __DIR__ . '/../../generated/strings.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../generated/Exceptions/StringsException.php';

$this->assertSame('foo', sprintf('foo'));
@@ -37,7 +36,6 @@ public function testPregMatch()
{
require_once __DIR__ . '/../../generated/pcre.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../lib/Exceptions/PcreException.php';


@@ -52,7 +50,6 @@ public function testObjects()
{
require_once __DIR__ . '/../../generated/simplexml.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../generated/Exceptions/SimplexmlException.php';

$xmlStr = <<<XML
@@ -83,7 +80,6 @@ public function testPregSplit()
{
require_once __DIR__ . '/../../generated/pcre.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../lib/Exceptions/PcreException.php';

$keywords = preg_split("/[\s,]+/", "hypertext language, programming", null);
@@ -98,7 +94,6 @@ public function testStrtotime()
{
require_once __DIR__ . '/../../generated/datetime.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../generated/Exceptions/DatetimeException.php';

$this->assertSame(\strtotime('+1 day'), strtotime('+1 day'));
@@ -111,7 +106,6 @@ public function testOpenSslSign()
{
require_once __DIR__ . '/../../generated/openssl.php';
require_once __DIR__ . '/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__ . '/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__ . '/../../lib/Exceptions/OpensslException.php';

\openssl_sign('foo', $signature, file_get_contents(__DIR__ . '/fixtures/id_rsa'));
1 change: 0 additions & 1 deletion generator/tests/SpecialCasesTest.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ public function testPregReplace()
{
require_once __DIR__.'/../../lib/special_cases.php';
require_once __DIR__.'/../../lib/Exceptions/SafeExceptionInterface.php';
require_once __DIR__.'/../../lib/Exceptions/AbstractSafeException.php';
require_once __DIR__.'/../../lib/Exceptions/PcreException.php';

$this->expectException(PcreException::class);
62 changes: 62 additions & 0 deletions lib/DateTimeImmutable.php
Original file line number Diff line number Diff line change
@@ -20,6 +20,12 @@ class DateTimeImmutable extends \DateTimeImmutable
*/
private $innerDateTime;

/**
* DateTimeImmutable constructor.
* @param string $time
* @param DateTimeZone|null $timezone
* @throws \Exception
*/
public function __construct($time = 'now', $timezone = null)
{
parent::__construct();
@@ -51,6 +57,10 @@ public static function createFromFormat($format, $time, $timezone = null): self
return self::createFromRegular($datetime);
}

/**
* @param string $format
* @return string
*/
public function format($format): string
{
/** @var string|false $result */
@@ -61,6 +71,11 @@ public function format($format): string
return $result;
}

/**
* @param DateTimeInterface $datetime2
* @param bool $absolute
* @return DateInterval
*/
public function diff($datetime2, $absolute = false): DateInterval
{
/** @var \DateInterval|false $result */
@@ -71,6 +86,10 @@ public function diff($datetime2, $absolute = false): DateInterval
return $result;
}

/**
* @param string $modify
* @return DateTimeImmutable
*/
public function modify($modify): self
{
/** @var \DateTimeImmutable|false $result */
@@ -81,6 +100,12 @@ public function modify($modify): self
return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable
}

/**
* @param int $year
* @param int $month
* @param int $day
* @return DateTimeImmutable
*/
public function setDate($year, $month, $day): self
{
/** @var \DateTimeImmutable|false $result */
@@ -91,6 +116,12 @@ public function setDate($year, $month, $day): self
return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable
}

/**
* @param int $year
* @param int $week
* @param int $day
* @return DateTimeImmutable
*/
public function setISODate($year, $week, $day = 1): self
{
/** @var \DateTimeImmutable|false $result */
@@ -101,6 +132,13 @@ public function setISODate($year, $week, $day = 1): self
return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable
}

/**
* @param int $hour
* @param int $minute
* @param int $second
* @param int $microseconds
* @return DateTimeImmutable
*/
public function setTime($hour, $minute, $second = 0, $microseconds = 0): self
{
/** @var \DateTimeImmutable|false $result */
@@ -111,6 +149,10 @@ public function setTime($hour, $minute, $second = 0, $microseconds = 0): self
return self::createFromRegular($result);
}

/**
* @param int $unixtimestamp
* @return DateTimeImmutable
*/
public function setTimestamp($unixtimestamp): self
{
/** @var \DateTimeImmutable|false $result */
@@ -121,6 +163,10 @@ public function setTimestamp($unixtimestamp): self
return self::createFromRegular($result);
}

/**
* @param DateTimeZone $timezone
* @return DateTimeImmutable
*/
public function setTimezone($timezone): self
{
/** @var \DateTimeImmutable|false $result */
@@ -131,6 +177,10 @@ public function setTimezone($timezone): self
return self::createFromRegular($result);
}

/**
* @param DateInterval $interval
* @return DateTimeImmutable
*/
public function sub($interval): self
{
/** @var \DateTimeImmutable|false $result */
@@ -154,16 +204,28 @@ public function getOffset(): int
//////////////////////////////////////////////////////////////////////////////////////////
//overload getters to use the inner datetime immutable instead of itself

/**
* @param DateInterval $interval
* @return DateTimeImmutable
*/
public function add($interval): self
{
return self::createFromRegular($this->innerDateTime->add($interval));
}

/**
* @param DateTime $dateTime
* @return DateTimeImmutable
*/
public static function createFromMutable($dateTime): self
{
return self::createFromRegular(parent::createFromMutable($dateTime));
}

/**
* @param mixed[] $array
* @return DateTimeImmutable
*/
public static function __set_state(array $array): self
{
return self::createFromRegular(parent::__set_state($array));
14 changes: 0 additions & 14 deletions lib/Exceptions/AbstractSafeException.php

This file was deleted.

4 changes: 2 additions & 2 deletions lib/Exceptions/CurlException.php
Original file line number Diff line number Diff line change
@@ -3,13 +3,13 @@

namespace Safe\Exceptions;

class CurlException extends AbstractSafeException
class CurlException extends \Exception implements SafeExceptionInterface
{
/**
* @param resource $ch
*/
public static function createFromCurlResource($ch): self
{
return new static(\curl_error($ch), \curl_errno($ch));
return new self(\curl_error($ch), \curl_errno($ch));
}
}
2 changes: 1 addition & 1 deletion lib/Exceptions/JsonException.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ class JsonException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new static(\json_last_error_msg(), \json_last_error());
return new self(\json_last_error_msg(), \json_last_error());
}
}
2 changes: 1 addition & 1 deletion lib/Exceptions/OpensslException.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ class OpensslException extends \Exception implements SafeExceptionInterface
{
public static function createFromPhpError(): self
{
return new static(\openssl_error_string(), 0);
return new self(\openssl_error_string() ?: '', 0);
}
}
2 changes: 1 addition & 1 deletion lib/Exceptions/PcreException.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,6 @@ public static function createFromPhpError(): self
PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR',
];
$errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: '.preg_last_error();
return new static($errMsg, \preg_last_error());
return new self($errMsg, \preg_last_error());
}
}
6 changes: 3 additions & 3 deletions lib/special_cases.php
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ function apc_fetch($key)
* @param string|string[] $key The key used to store the value (with
* apcu_store). If an array is passed then each
* element is fetched and returned.
* @return mixed The stored variable or array of variables on success; FALSE on failure
* @return mixed The stored variable or array of variables on success
* @throws ApcuException
*
*/
@@ -130,7 +130,7 @@ function apcu_fetch($key)
* 'strlen(\'$1\')+strlen("$2")'). Make sure you are
* aware of PHP's string
* syntax to know exactly how the interpreted string will look.
* @param string|array $subject The string or an array with strings to search and replace.
* @param string|array|string[] $subject The string or an array with strings to search and replace.
*
* If subject is an array, then the search and
* replace is performed on every entry of subject,
@@ -140,7 +140,7 @@ function apcu_fetch($key)
* -1 (no limit).
* @param int $count If specified, this variable will be filled with the number of
* replacements done.
* @return string|array preg_replace returns an array if the
* @return string|array|string[] preg_replace returns an array if the
* subject parameter is an array, or a string
* otherwise.
*
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
parameters:
ignoreErrors:
# A lot of functions are in extensions so it is ok not to find those
- "#Function .* not found#"
- "#Undefined variable: \\$success#"
includes:
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

0 comments on commit 50f1e60

Please sign in to comment.