Add vendor files to dist

This commit is contained in:
FreeScout
2022-11-16 23:30:17 -08:00
parent c51ee20010
commit 7813210078
41 changed files with 1301 additions and 715 deletions

View File

@@ -61,7 +61,7 @@ return array(
'App\\Http\\Controllers\\CustomersController' => $baseDir . '/app/Http/Controllers/CustomersController.php',
'App\\Http\\Controllers\\MailboxesController' => $baseDir . '/app/Http/Controllers/MailboxesController.php',
'App\\Http\\Controllers\\ModulesController' => $baseDir . '/app/Http/Controllers/ModulesController.php',
'App\\Http\\Controllers\\PublicController' => $baseDir . '/app/Http/Controllers/PublicController.php',
'App\\Http\\Controllers\\OpenController' => $baseDir . '/app/Http/Controllers/OpenController.php',
'App\\Http\\Controllers\\SecureController' => $baseDir . '/app/Http/Controllers/SecureController.php',
'App\\Http\\Controllers\\SettingsController' => $baseDir . '/app/Http/Controllers/SettingsController.php',
'App\\Http\\Controllers\\SystemController' => $baseDir . '/app/Http/Controllers/SystemController.php',
@@ -300,9 +300,9 @@ return array(
'Doctrine\\Common\\Cache\\WinCacheCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php',
'Doctrine\\Common\\Cache\\XcacheCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php',
'Doctrine\\Common\\Cache\\ZendDataCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php',
'Doctrine\\Common\\EventArgs' => $vendorDir . '/doctrine/event-manager/lib/Doctrine/Common/EventArgs.php',
'Doctrine\\Common\\EventManager' => $vendorDir . '/doctrine/event-manager/lib/Doctrine/Common/EventManager.php',
'Doctrine\\Common\\EventSubscriber' => $vendorDir . '/doctrine/event-manager/lib/Doctrine/Common/EventSubscriber.php',
'Doctrine\\Common\\EventArgs' => $vendorDir . '/doctrine/event-manager/src/EventArgs.php',
'Doctrine\\Common\\EventManager' => $vendorDir . '/doctrine/event-manager/src/EventManager.php',
'Doctrine\\Common\\EventSubscriber' => $vendorDir . '/doctrine/event-manager/src/EventSubscriber.php',
'Doctrine\\Common\\Inflector\\Inflector' => $vendorDir . '/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php',
'Doctrine\\Common\\Lexer\\AbstractLexer' => $vendorDir . '/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php',
'Doctrine\\DBAL\\Abstraction\\Result' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Abstraction/Result.php',
@@ -611,6 +611,8 @@ return array(
'Doctrine\\DBAL\\Types\\VarDateTimeType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php',
'Doctrine\\DBAL\\Version' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Version.php',
'Doctrine\\DBAL\\VersionAwarePlatformDriver' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php',
'Doctrine\\Deprecations\\Deprecation' => $vendorDir . '/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php',
'Doctrine\\Deprecations\\PHPUnit\\VerifyDeprecations' => $vendorDir . '/doctrine/deprecations/lib/Doctrine/Deprecations/PHPUnit/VerifyDeprecations.php',
'Dotenv\\Dotenv' => $vendorDir . '/vlucas/phpdotenv/src/Dotenv.php',
'Dotenv\\Exception\\ExceptionInterface' => $vendorDir . '/vlucas/phpdotenv/src/Exception/ExceptionInterface.php',
'Dotenv\\Exception\\InvalidCallbackException' => $vendorDir . '/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php',
@@ -2485,6 +2487,7 @@ return array(
'Spatie\\String\\Str' => $baseDir . '/overrides/spatie/string/src/Str.php',
'Swift_MailTransport' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php',
'Swift_Mime_ContentEncoder_Base64ContentEncoder' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php',
'Swift_Mime_MimePart' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php',
'Swift_Transport_EsmtpTransport' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php',
'Swift_Transport_Esmtp_AuthHandler' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php',
'Swift_Transport_MailInvoker' => $baseDir . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php',

View File

@@ -12,10 +12,10 @@ return array(
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'801c31d8ed748cfa537fa45402288c95' => $vendorDir . '/psy/psysh/src/functions.php',

View File

@@ -85,11 +85,12 @@ return array(
'Fideloper\\Proxy\\' => array($vendorDir . '/fideloper/proxy/src'),
'Egulias\\EmailValidator\\' => array($vendorDir . '/egulias/email-validator/EmailValidator'),
'Dotenv\\' => array($baseDir . '/overrides/vlucas/phpdotenv/src', $vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Deprecations\\' => array($vendorDir . '/doctrine/deprecations/lib/Doctrine/Deprecations'),
'Doctrine\\DBAL\\Driver\\' => array($baseDir . '/overrides/doctrine/dbal/lib/Doctrine/DBAL/Driver'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Common/Inflector'),
'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
'Doctrine\\Common\\' => array($vendorDir . '/doctrine/event-manager/lib/Doctrine/Common'),
'Doctrine\\Common\\' => array($vendorDir . '/doctrine/event-manager/src'),
'Devfactory\\Minify\\Providers\\' => array($baseDir . '/overrides/devfactory/minify/src/Providers'),
'Devfactory\\Minify\\' => array($vendorDir . '/devfactory/minify/src'),
'DebugBar\\' => array($baseDir . '/overrides/maximebf/debugbar/src/DebugBar'),

View File

@@ -13,10 +13,10 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'801c31d8ed748cfa537fa45402288c95' => __DIR__ . '/..' . '/psy/psysh/src/functions.php',
@@ -157,6 +157,7 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'D' =>
array (
'Dotenv\\' => 7,
'Doctrine\\Deprecations\\' => 22,
'Doctrine\\DBAL\\Driver\\' => 21,
'Doctrine\\DBAL\\' => 14,
'Doctrine\\Common\\Inflector\\' => 26,
@@ -520,6 +521,10 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
0 => __DIR__ . '/../..' . '/overrides/vlucas/phpdotenv/src',
1 => __DIR__ . '/..' . '/vlucas/phpdotenv/src',
),
'Doctrine\\Deprecations\\' =>
array (
0 => __DIR__ . '/..' . '/doctrine/deprecations/lib/Doctrine/Deprecations',
),
'Doctrine\\DBAL\\Driver\\' =>
array (
0 => __DIR__ . '/../..' . '/overrides/doctrine/dbal/lib/Doctrine/DBAL/Driver',
@@ -538,7 +543,7 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
),
'Doctrine\\Common\\' =>
array (
0 => __DIR__ . '/..' . '/doctrine/event-manager/lib/Doctrine/Common',
0 => __DIR__ . '/..' . '/doctrine/event-manager/src',
),
'Devfactory\\Minify\\Providers\\' =>
array (
@@ -712,7 +717,7 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'App\\Http\\Controllers\\CustomersController' => __DIR__ . '/../..' . '/app/Http/Controllers/CustomersController.php',
'App\\Http\\Controllers\\MailboxesController' => __DIR__ . '/../..' . '/app/Http/Controllers/MailboxesController.php',
'App\\Http\\Controllers\\ModulesController' => __DIR__ . '/../..' . '/app/Http/Controllers/ModulesController.php',
'App\\Http\\Controllers\\PublicController' => __DIR__ . '/../..' . '/app/Http/Controllers/PublicController.php',
'App\\Http\\Controllers\\OpenController' => __DIR__ . '/../..' . '/app/Http/Controllers/OpenController.php',
'App\\Http\\Controllers\\SecureController' => __DIR__ . '/../..' . '/app/Http/Controllers/SecureController.php',
'App\\Http\\Controllers\\SettingsController' => __DIR__ . '/../..' . '/app/Http/Controllers/SettingsController.php',
'App\\Http\\Controllers\\SystemController' => __DIR__ . '/../..' . '/app/Http/Controllers/SystemController.php',
@@ -951,9 +956,9 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'Doctrine\\Common\\Cache\\WinCacheCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php',
'Doctrine\\Common\\Cache\\XcacheCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php',
'Doctrine\\Common\\Cache\\ZendDataCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php',
'Doctrine\\Common\\EventArgs' => __DIR__ . '/..' . '/doctrine/event-manager/lib/Doctrine/Common/EventArgs.php',
'Doctrine\\Common\\EventManager' => __DIR__ . '/..' . '/doctrine/event-manager/lib/Doctrine/Common/EventManager.php',
'Doctrine\\Common\\EventSubscriber' => __DIR__ . '/..' . '/doctrine/event-manager/lib/Doctrine/Common/EventSubscriber.php',
'Doctrine\\Common\\EventArgs' => __DIR__ . '/..' . '/doctrine/event-manager/src/EventArgs.php',
'Doctrine\\Common\\EventManager' => __DIR__ . '/..' . '/doctrine/event-manager/src/EventManager.php',
'Doctrine\\Common\\EventSubscriber' => __DIR__ . '/..' . '/doctrine/event-manager/src/EventSubscriber.php',
'Doctrine\\Common\\Inflector\\Inflector' => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php',
'Doctrine\\Common\\Lexer\\AbstractLexer' => __DIR__ . '/..' . '/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php',
'Doctrine\\DBAL\\Abstraction\\Result' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Abstraction/Result.php',
@@ -1262,6 +1267,8 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'Doctrine\\DBAL\\Types\\VarDateTimeType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php',
'Doctrine\\DBAL\\Version' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Version.php',
'Doctrine\\DBAL\\VersionAwarePlatformDriver' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php',
'Doctrine\\Deprecations\\Deprecation' => __DIR__ . '/..' . '/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php',
'Doctrine\\Deprecations\\PHPUnit\\VerifyDeprecations' => __DIR__ . '/..' . '/doctrine/deprecations/lib/Doctrine/Deprecations/PHPUnit/VerifyDeprecations.php',
'Dotenv\\Dotenv' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Dotenv.php',
'Dotenv\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/ExceptionInterface.php',
'Dotenv\\Exception\\InvalidCallbackException' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php',
@@ -3136,6 +3143,7 @@ class ComposerStaticInitbf8dc242a640d7c740f283f226d0bdb4
'Spatie\\String\\Str' => __DIR__ . '/../..' . '/overrides/spatie/string/src/Str.php',
'Swift_MailTransport' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php',
'Swift_Mime_ContentEncoder_Base64ContentEncoder' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php',
'Swift_Mime_MimePart' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php',
'Swift_Transport_EsmtpTransport' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php',
'Swift_Transport_Esmtp_AuthHandler' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php',
'Swift_Transport_MailInvoker' => __DIR__ . '/../..' . '/overrides/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php',

View File

@@ -589,41 +589,85 @@
"install-path": "../doctrine/dbal"
},
{
"name": "doctrine/event-manager",
"version": "1.1.1",
"version_normalized": "1.1.1.0",
"name": "doctrine/deprecations",
"version": "v1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f"
"url": "https://github.com/doctrine/deprecations.git",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/common": "<2.9@dev"
"php": "^7.1|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"phpunit/phpunit": "^7.0"
"doctrine/coding-standard": "^9",
"phpunit/phpunit": "^7.5|^8.5|^9.5",
"psr/log": "^1|^2|^3"
},
"time": "2020-05-29T18:28:51+00:00",
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"time": "2022-05-02T15:47:09+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
},
"install-path": "../doctrine/deprecations"
},
{
"name": "doctrine/event-manager",
"version": "1.2.0",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520",
"reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520",
"shasum": ""
},
"require": {
"doctrine/deprecations": "^0.5.3 || ^1",
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/common": "<2.9"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^10",
"phpstan/phpstan": "~1.4.10 || ^1.8.8",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.24"
},
"time": "2022-10-12T20:51:15+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -667,7 +711,7 @@
],
"support": {
"issues": "https://github.com/doctrine/event-manager/issues",
"source": "https://github.com/doctrine/event-manager/tree/1.1.x"
"source": "https://github.com/doctrine/event-manager/tree/1.2.0"
},
"funding": [
{
@@ -1128,17 +1172,17 @@
},
{
"name": "guzzlehttp/promises",
"version": "1.5.1",
"version_normalized": "1.5.1.0",
"version": "1.5.2",
"version_normalized": "1.5.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da"
"reference": "b94b2807d85443f9719887892882d0329d1e2598"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
"reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598",
"reference": "b94b2807d85443f9719887892882d0329d1e2598",
"shasum": ""
},
"require": {
@@ -1147,7 +1191,7 @@
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.1"
},
"time": "2021-10-22T20:56:57+00:00",
"time": "2022-08-28T14:55:35+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -1156,12 +1200,12 @@
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
],
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1195,7 +1239,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/1.5.1"
"source": "https://github.com/guzzle/promises/tree/1.5.2"
},
"funding": [
{
@@ -1934,17 +1978,17 @@
},
{
"name": "monolog/monolog",
"version": "1.26.1",
"version_normalized": "1.26.1.0",
"version": "1.27.1",
"version_normalized": "1.27.1.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5"
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/c6b00f05152ae2c9b04a448f99c7590beb6042f5",
"reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/904713c5929655dc9b97288b69cfeedad610c9a1",
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1",
"shasum": ""
},
"require": {
@@ -1979,7 +2023,7 @@
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"time": "2021-05-28T08:32:12+00:00",
"time": "2022-06-09T08:53:42+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -2007,7 +2051,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/1.26.1"
"source": "https://github.com/Seldaek/monolog/tree/1.27.1"
},
"funding": [
{
@@ -4249,17 +4293,17 @@
},
{
"name": "tijsverkoyen/css-to-inline-styles",
"version": "2.2.4",
"version_normalized": "2.2.4.0",
"version": "2.2.5",
"version_normalized": "2.2.5.0",
"source": {
"type": "git",
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
"reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c"
"reference": "4348a3a06651827a27d989ad1d13efec6bb49b19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/da444caae6aca7a19c0c140f68c6182e337d5b1c",
"reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/4348a3a06651827a27d989ad1d13efec6bb49b19",
"reference": "4348a3a06651827a27d989ad1d13efec6bb49b19",
"shasum": ""
},
"require": {
@@ -4271,7 +4315,7 @@
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
},
"time": "2021-12-08T09:12:39+00:00",
"time": "2022-09-12T13:28:28+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -4299,7 +4343,7 @@
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"support": {
"issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues",
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.4"
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.5"
},
"install-path": "../tijsverkoyen/css-to-inline-styles"
},
@@ -4558,17 +4602,17 @@
},
{
"name": "webklex/php-imap",
"version": "dev-master",
"version_normalized": "dev-master",
"version": "4.1.1",
"version_normalized": "4.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/Webklex/php-imap.git",
"reference": "f565c3b2510238191981dec92840bfcf3cc8b7e8"
"reference": "5415d520d235ce8585e7f3c03c2b937bd8662a3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Webklex/php-imap/zipball/f565c3b2510238191981dec92840bfcf3cc8b7e8",
"reference": "f565c3b2510238191981dec92840bfcf3cc8b7e8",
"url": "https://api.github.com/repos/Webklex/php-imap/zipball/5415d520d235ce8585e7f3c03c2b937bd8662a3e",
"reference": "5415d520d235ce8585e7f3c03c2b937bd8662a3e",
"shasum": ""
},
"require": {
@@ -4585,8 +4629,10 @@
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"time": "2022-03-10T22:38:04+00:00",
"default-branch": true,
"suggest": {
"symfony/mime": "Recomended for better extension support"
},
"time": "2022-11-16T07:27:09+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -4621,8 +4667,18 @@
],
"support": {
"issues": "https://github.com/Webklex/php-imap/issues",
"source": "https://github.com/Webklex/php-imap/tree/master"
"source": "https://github.com/Webklex/php-imap/tree/4.1.1"
},
"funding": [
{
"url": "https://www.buymeacoffee.com/webklex",
"type": "custom"
},
{
"url": "https://ko-fi.com/webklex",
"type": "ko_fi"
}
],
"install-path": "../webklex/php-imap"
}
],

View File

@@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '4f65bbc7236fb51ae7a29244f590dc59862d16f0',
'reference' => 'c51ee20010e2354d97ac4ae8af213d0e49822d59',
'name' => 'freescout-helpdesk/freescout',
'dev' => false,
),
@@ -91,13 +91,22 @@
'reference' => 'adce7a954a1c2f14f85e94aed90c8489af204086',
'dev_requirement' => false,
),
'doctrine/deprecations' => array(
'pretty_version' => 'v1.0.0',
'version' => '1.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/deprecations',
'aliases' => array(),
'reference' => '0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de',
'dev_requirement' => false,
),
'doctrine/event-manager' => array(
'pretty_version' => '1.1.1',
'version' => '1.1.1.0',
'pretty_version' => '1.2.0',
'version' => '1.2.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/event-manager',
'aliases' => array(),
'reference' => '41370af6a30faa9dc0368c4a6814d596e81aba7f',
'reference' => '95aa4cb529f1e96576f3fda9f5705ada4056a520',
'dev_requirement' => false,
),
'doctrine/inflector' => array(
@@ -160,7 +169,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '4f65bbc7236fb51ae7a29244f590dc59862d16f0',
'reference' => 'c51ee20010e2354d97ac4ae8af213d0e49822d59',
'dev_requirement' => false,
),
'guzzlehttp/guzzle' => array(
@@ -173,12 +182,12 @@
'dev_requirement' => false,
),
'guzzlehttp/promises' => array(
'pretty_version' => '1.5.1',
'version' => '1.5.1.0',
'pretty_version' => '1.5.2',
'version' => '1.5.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/promises',
'aliases' => array(),
'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da',
'reference' => 'b94b2807d85443f9719887892882d0329d1e2598',
'dev_requirement' => false,
),
'guzzlehttp/psr7' => array(
@@ -440,12 +449,12 @@
'dev_requirement' => false,
),
'monolog/monolog' => array(
'pretty_version' => '1.26.1',
'version' => '1.26.1.0',
'pretty_version' => '1.27.1',
'version' => '1.27.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../monolog/monolog',
'aliases' => array(),
'reference' => 'c6b00f05152ae2c9b04a448f99c7590beb6042f5',
'reference' => '904713c5929655dc9b97288b69cfeedad610c9a1',
'dev_requirement' => false,
),
'mtdowling/cron-expression' => array(
@@ -547,8 +556,8 @@
'psr/log-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0.0',
1 => '1.0',
0 => '1.0',
1 => '1.0.0',
),
),
'psr/simple-cache' => array(
@@ -771,12 +780,12 @@
),
),
'tijsverkoyen/css-to-inline-styles' => array(
'pretty_version' => '2.2.4',
'version' => '2.2.4.0',
'pretty_version' => '2.2.5',
'version' => '2.2.5.0',
'type' => 'library',
'install_path' => __DIR__ . '/../tijsverkoyen/css-to-inline-styles',
'aliases' => array(),
'reference' => 'da444caae6aca7a19c0c140f68c6182e337d5b1c',
'reference' => '4348a3a06651827a27d989ad1d13efec6bb49b19',
'dev_requirement' => false,
),
'tormjens/eventy' => array(
@@ -816,14 +825,12 @@
'dev_requirement' => false,
),
'webklex/php-imap' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => '4.1.1',
'version' => '4.1.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../webklex/php-imap',
'aliases' => array(
0 => '1.0.x-dev',
),
'reference' => 'f565c3b2510238191981dec92840bfcf3cc8b7e8',
'aliases' => array(),
'reference' => '5415d520d235ce8585e7f3c03c2b937bd8662a3e',
'dev_requirement' => false,
),
),

View File

@@ -0,0 +1,266 @@
<?php
declare(strict_types=1);
namespace Doctrine\Deprecations;
use Psr\Log\LoggerInterface;
use function array_key_exists;
use function array_reduce;
use function debug_backtrace;
use function sprintf;
use function strpos;
use function strrpos;
use function substr;
use function trigger_error;
use const DEBUG_BACKTRACE_IGNORE_ARGS;
use const DIRECTORY_SEPARATOR;
use const E_USER_DEPRECATED;
/**
* Manages Deprecation logging in different ways.
*
* By default triggered exceptions are not logged.
*
* To enable different deprecation logging mechanisms you can call the
* following methods:
*
* - Minimal collection of deprecations via getTriggeredDeprecations()
* \Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
*
* - Uses @trigger_error with E_USER_DEPRECATED
* \Doctrine\Deprecations\Deprecation::enableWithTriggerError();
*
* - Sends deprecation messages via a PSR-3 logger
* \Doctrine\Deprecations\Deprecation::enableWithPsrLogger($logger);
*
* Packages that trigger deprecations should use the `trigger()` or
* `triggerIfCalledFromOutside()` methods.
*/
class Deprecation
{
private const TYPE_NONE = 0;
private const TYPE_TRACK_DEPRECATIONS = 1;
private const TYPE_TRIGGER_ERROR = 2;
private const TYPE_PSR_LOGGER = 4;
/** @var int */
private static $type = self::TYPE_NONE;
/** @var LoggerInterface|null */
private static $logger;
/** @var array<string,bool> */
private static $ignoredPackages = [];
/** @var array<string,int> */
private static $ignoredLinks = [];
/** @var bool */
private static $deduplication = true;
/**
* Trigger a deprecation for the given package and identfier.
*
* The link should point to a Github issue or Wiki entry detailing the
* deprecation. It is additionally used to de-duplicate the trigger of the
* same deprecation during a request.
*
* @param mixed $args
*/
public static function trigger(string $package, string $link, string $message, ...$args): void
{
if (self::$type === self::TYPE_NONE) {
return;
}
if (array_key_exists($link, self::$ignoredLinks)) {
self::$ignoredLinks[$link]++;
} else {
self::$ignoredLinks[$link] = 1;
}
if (self::$deduplication === true && self::$ignoredLinks[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
/**
* Trigger a deprecation for the given package and identifier when called from outside.
*
* "Outside" means we assume that $package is currently installed as a
* dependency and the caller is not a file in that package. When $package
* is installed as a root package then deprecations triggered from the
* tests folder are also considered "outside".
*
* This deprecation method assumes that you are using Composer to install
* the dependency and are using the default /vendor/ folder and not a
* Composer plugin to change the install location. The assumption is also
* that $package is the exact composer packge name.
*
* Compared to {@link trigger()} this method causes some overhead when
* deprecation tracking is enabled even during deduplication, because it
* needs to call {@link debug_backtrace()}
*
* @param mixed $args
*/
public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args): void
{
if (self::$type === self::TYPE_NONE) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
// first check that the caller is not from a tests folder, in which case we always let deprecations pass
if (strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) {
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR;
if (strpos($backtrace[0]['file'], $path) === false) {
return;
}
if (strpos($backtrace[1]['file'], $path) !== false) {
return;
}
}
if (array_key_exists($link, self::$ignoredLinks)) {
self::$ignoredLinks[$link]++;
} else {
self::$ignoredLinks[$link] = 1;
}
if (self::$deduplication === true && self::$ignoredLinks[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
/**
* @param array<mixed> $backtrace
*/
private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package): void
{
if ((self::$type & self::TYPE_PSR_LOGGER) > 0) {
$context = [
'file' => $backtrace[0]['file'],
'line' => $backtrace[0]['line'],
'package' => $package,
'link' => $link,
];
self::$logger->notice($message, $context);
}
if (! ((self::$type & self::TYPE_TRIGGER_ERROR) > 0)) {
return;
}
$message .= sprintf(
' (%s:%d called by %s:%d, %s, package %s)',
self::basename($backtrace[0]['file']),
$backtrace[0]['line'],
self::basename($backtrace[1]['file']),
$backtrace[1]['line'],
$link,
$package
);
@trigger_error($message, E_USER_DEPRECATED);
}
/**
* A non-local-aware version of PHPs basename function.
*/
private static function basename(string $filename): string
{
$pos = strrpos($filename, DIRECTORY_SEPARATOR);
if ($pos === false) {
return $filename;
}
return substr($filename, $pos + 1);
}
public static function enableTrackingDeprecations(): void
{
self::$type |= self::TYPE_TRACK_DEPRECATIONS;
}
public static function enableWithTriggerError(): void
{
self::$type |= self::TYPE_TRIGGER_ERROR;
}
public static function enableWithPsrLogger(LoggerInterface $logger): void
{
self::$type |= self::TYPE_PSR_LOGGER;
self::$logger = $logger;
}
public static function withoutDeduplication(): void
{
self::$deduplication = false;
}
public static function disable(): void
{
self::$type = self::TYPE_NONE;
self::$logger = null;
self::$deduplication = true;
foreach (self::$ignoredLinks as $link => $count) {
self::$ignoredLinks[$link] = 0;
}
}
public static function ignorePackage(string $packageName): void
{
self::$ignoredPackages[$packageName] = true;
}
public static function ignoreDeprecations(string ...$links): void
{
foreach ($links as $link) {
self::$ignoredLinks[$link] = 0;
}
}
public static function getUniqueTriggeredDeprecationsCount(): int
{
return array_reduce(self::$ignoredLinks, static function (int $carry, int $count) {
return $carry + $count;
}, 0);
}
/**
* Returns each triggered deprecation link identifier and the amount of occurrences.
*
* @return array<string,int>
*/
public static function getTriggeredDeprecations(): array
{
return self::$ignoredLinks;
}
}

View File

@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Doctrine\Deprecations\PHPUnit;
use Doctrine\Deprecations\Deprecation;
use function sprintf;
trait VerifyDeprecations
{
/** @var array<string,int> */
private $doctrineDeprecationsExpectations = [];
/** @var array<string,int> */
private $doctrineNoDeprecationsExpectations = [];
public function expectDeprecationWithIdentifier(string $identifier): void
{
$this->doctrineDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
}
public function expectNoDeprecationWithIdentifier(string $identifier): void
{
$this->doctrineNoDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
}
/**
* @before
*/
public function enableDeprecationTracking(): void
{
Deprecation::enableTrackingDeprecations();
}
/**
* @after
*/
public function verifyDeprecationsAreTriggered(): void
{
foreach ($this->doctrineDeprecationsExpectations as $identifier => $expectation) {
$actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
$this->assertTrue(
$actualCount > $expectation,
sprintf(
"Expected deprecation with identifier '%s' was not triggered by code executed in test.",
$identifier
)
);
}
foreach ($this->doctrineNoDeprecationsExpectations as $identifier => $expectation) {
$actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
$this->assertTrue(
$actualCount === $expectation,
sprintf(
"Expected deprecation with identifier '%s' was triggered by code executed in test, but expected not to.",
$identifier
)
);
}
}
}

View File

@@ -1,18 +0,0 @@
{
"active": true,
"name": "Event Manager",
"slug": "event-manager",
"docsSlug": "doctrine-event-manager",
"versions": [
{
"name": "1.0",
"branchName": "master",
"slug": "latest",
"current": true,
"aliases": [
"current",
"stable"
]
}
]
}

15
vendor/doctrine/event-manager/psalm.xml vendored Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@@ -16,7 +16,7 @@ class EventArgs
/**
* Single instance of EventArgs.
*
* @var EventArgs
* @var EventArgs|null
*/
private static $_emptyEventArgsInstance;

View File

@@ -2,6 +2,8 @@
namespace Doctrine\Common;
use Doctrine\Deprecations\Deprecation;
use function spl_object_hash;
/**
@@ -15,9 +17,9 @@ class EventManager
* Map of registered listeners.
* <event> => <listeners>
*
* @var object[][]
* @var array<string, object[]>
*/
private $_listeners = [];
private $listeners = [];
/**
* Dispatches an event to all registered listeners.
@@ -31,27 +33,49 @@ class EventManager
*/
public function dispatchEvent($eventName, ?EventArgs $eventArgs = null)
{
if (! isset($this->_listeners[$eventName])) {
if (! isset($this->listeners[$eventName])) {
return;
}
$eventArgs = $eventArgs ?? EventArgs::getEmptyInstance();
foreach ($this->_listeners[$eventName] as $listener) {
foreach ($this->listeners[$eventName] as $listener) {
$listener->$eventName($eventArgs);
}
}
/**
* Gets the listeners of a specific event or all listeners.
* Gets the listeners of a specific event.
*
* @param string|null $event The name of the event.
*
* @return object[]|object[][] The event listeners for the specified event, or all event listeners.
* @return object[]|array<string, object[]> The event listeners for the specified event, or all event listeners.
* @psalm-return ($event is null ? array<string, object[]> : object[])
*/
public function getListeners($event = null)
{
return $event ? $this->_listeners[$event] : $this->_listeners;
if ($event === null) {
Deprecation::trigger(
'doctrine/event-manager',
'https://github.com/doctrine/event-manager/pull/50',
'Calling %s without an event name is deprecated. Call getAllListeners() instead.',
__METHOD__
);
return $this->getAllListeners();
}
return $this->listeners[$event] ?? [];
}
/**
* Gets all listeners keyed by event name.
*
* @return array<string, object[]> The event listeners for the specified event, or all event listeners.
*/
public function getAllListeners(): array
{
return $this->listeners;
}
/**
@@ -63,7 +87,7 @@ class EventManager
*/
public function hasListeners($event)
{
return ! empty($this->_listeners[$event]);
return ! empty($this->listeners[$event]);
}
/**
@@ -82,7 +106,7 @@ class EventManager
foreach ((array) $events as $event) {
// Overrides listener if a previous one was associated already
// Prevents duplicate listeners on same event (same instance only)
$this->_listeners[$event][$hash] = $listener;
$this->listeners[$event][$hash] = $listener;
}
}
@@ -100,7 +124,7 @@ class EventManager
$hash = spl_object_hash($listener);
foreach ((array) $events as $event) {
unset($this->_listeners[$event][$hash]);
unset($this->listeners[$event][$hash]);
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Doctrine\Common;
/**
* An EventSubscriber knows himself what events he is interested in.
* An EventSubscriber knows what events it is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.

View File

@@ -81,16 +81,8 @@ class EachPromise implements PromisorInterface
$this->iterable->rewind();
$this->refillPending();
} catch (\Throwable $e) {
/**
* @psalm-suppress NullReference
* @phpstan-ignore-next-line
*/
$this->aggregate->reject($e);
} catch (\Exception $e) {
/**
* @psalm-suppress NullReference
* @phpstan-ignore-next-line
*/
$this->aggregate->reject($e);
}

View File

@@ -38,9 +38,11 @@ class JsonFormatter extends NormalizerFormatter
/**
* @param int $batchMode
* @param bool $appendNewline
* @param int $maxDepth
*/
public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true)
public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true, $maxDepth = 9)
{
parent::__construct(null, $maxDepth);
$this->batchMode = $batchMode;
$this->appendNewline = $appendNewline;
}
@@ -141,8 +143,8 @@ class JsonFormatter extends NormalizerFormatter
*/
protected function normalize($data, $depth = 0)
{
if ($depth > 9) {
return 'Over 9 levels deep, aborting normalization';
if ($depth > $this->maxDepth) {
return 'Over '.$this->maxDepth.' levels deep, aborting normalization';
}
if (is_array($data)) {

View File

@@ -24,13 +24,16 @@ class NormalizerFormatter implements FormatterInterface
const SIMPLE_DATE = "Y-m-d H:i:s";
protected $dateFormat;
protected $maxDepth;
/**
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
* @param int $maxDepth
*/
public function __construct($dateFormat = null)
public function __construct($dateFormat = null, $maxDepth = 9)
{
$this->dateFormat = $dateFormat ?: static::SIMPLE_DATE;
$this->maxDepth = $maxDepth;
if (!function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter');
}
@@ -56,10 +59,26 @@ class NormalizerFormatter implements FormatterInterface
return $records;
}
/**
* @return int
*/
public function getMaxDepth()
{
return $this->maxDepth;
}
/**
* @param int $maxDepth
*/
public function setMaxDepth($maxDepth)
{
$this->maxDepth = $maxDepth;
}
protected function normalize($data, $depth = 0)
{
if ($depth > 9) {
return 'Over 9 levels deep, aborting normalization';
if ($depth > $this->maxDepth) {
return 'Over '.$this->maxDepth.' levels deep, aborting normalization';
}
if (null === $data || is_scalar($data)) {
@@ -177,4 +196,4 @@ class NormalizerFormatter implements FormatterInterface
{
return Utils::jsonEncode($data, null, $ignoreErrors);
}
}
}

View File

@@ -50,7 +50,11 @@ class MandrillHandler extends MailHandler
{
$message = clone $this->message;
$message->setBody($content);
$message->setDate(time());
if (version_compare(\Swift::VERSION, '6.0.0', '>=')) {
$message->setDate(new \DateTimeImmutable());
} else {
$message->setDate(time());
}
$ch = curl_init();

View File

@@ -23,6 +23,10 @@ use Monolog\Utils;
*/
class StreamHandler extends AbstractProcessingHandler
{
/** @private 512KB */
const CHUNK_SIZE = 524288;
/** @var resource|null */
protected $stream;
protected $url;
private $errorMessage;
@@ -45,6 +49,7 @@ class StreamHandler extends AbstractProcessingHandler
parent::__construct($level, $bubble);
if (is_resource($stream)) {
$this->stream = $stream;
$this->streamSetChunkSize();
} elseif (is_string($stream)) {
$this->url = Utils::canonicalizePath($stream);
} else {
@@ -109,6 +114,7 @@ class StreamHandler extends AbstractProcessingHandler
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $this->url));
}
$this->streamSetChunkSize();
}
if ($this->useLocking) {
@@ -133,6 +139,15 @@ class StreamHandler extends AbstractProcessingHandler
fwrite($stream, (string) $record['formatted']);
}
protected function streamSetChunkSize()
{
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
return stream_set_chunk_size($this->stream, self::CHUNK_SIZE);
}
return false;
}
private function customErrorHandler($code, $msg)
{
$this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg);

View File

@@ -113,7 +113,7 @@ class CssToInlineStyles
{
$document = new \DOMDocument('1.0', 'UTF-8');
$internalErrors = libxml_use_internal_errors(true);
$document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
$document->loadHTML(mb_encode_numericentity($html, [0x80, 0xFFFF, 0, 0xFFFF], 'UTF-8'));
libxml_use_internal_errors($internalErrors);
$document->formatOutput = true;

View File

@@ -52,7 +52,7 @@ class Address {
* @return string
*/
public function __toString() {
return $this->full ? $this->full : "";
return $this->full ?: "";
}
/**
@@ -75,7 +75,7 @@ class Address {
*
* @return array
*/
public function toArray(){
public function toArray(): array {
return $this->__serialize();
}
@@ -84,7 +84,7 @@ class Address {
*
* @return string
*/
public function toString(){
public function toString(): string {
return $this->__toString();
}
}

View File

@@ -119,7 +119,7 @@ class Attachment {
* @return mixed
* @throws MethodNotFoundException
*/
public function __call($method, $arguments) {
public function __call(string $method, array $arguments) {
if(strtolower(substr($method, 0, 3)) === 'get') {
$name = Str::snake(substr($method, 3));
@@ -242,8 +242,8 @@ class Attachment {
*
* @return boolean
*/
public function save($path, $filename = null) {
$filename = $filename ? $filename : $this->getName();
public function save(string $path, $filename = null): bool {
$filename = $filename ?: $this->getName();
return file_put_contents($path.$filename, $this->getContent()) !== false;
}
@@ -278,13 +278,20 @@ class Attachment {
* @return string|null
*/
public function getExtension(){
$guesser = "\Symfony\Component\Mime\MimeTypes";
if (class_exists($guesser) !== false) {
/** @var Symfony\Component\Mime\MimeTypes $guesser */
$extensions = $guesser::getDefault()->getExtensions($this->getMimeType());
return $extensions[0] ?? null;
}
$deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
if (class_exists($deprecated_guesser) !== false){
/** @var \Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser $deprecated_guesser */
return $deprecated_guesser::getInstance()->guess($this->getMimeType());
}
$guesser = "\Symfony\Component\Mime\MimeTypes";
$extensions = $guesser::getDefault()->getExtensions($this->getMimeType());
return isset($extensions[0]) ? $extensions[0] : null;
return null;
}
/**
@@ -292,14 +299,14 @@ class Attachment {
*
* @return array
*/
public function getAttributes(){
public function getAttributes(): array {
return $this->attributes;
}
/**
* @return Message
*/
public function getMessage(){
public function getMessage(): Message {
return $this->oMessage;
}
@@ -309,7 +316,7 @@ class Attachment {
*
* @return $this
*/
public function setMask($mask){
public function setMask($mask): Attachment {
if(class_exists($mask)){
$this->mask = $mask;
}
@@ -322,7 +329,7 @@ class Attachment {
*
* @return string
*/
public function getMask(){
public function getMask(): string {
return $this->mask;
}

View File

@@ -14,6 +14,7 @@ namespace Webklex\PHPIMAP;
use ArrayAccess;
use Carbon\Carbon;
use ReturnTypeWillChange;
/**
* Class Attribute
@@ -34,10 +35,10 @@ class Attribute implements ArrayAccess {
/**
* Attribute constructor.
* @param string $name
* @param string $name
* @param array|mixed $value
*/
public function __construct($name, $value = null) {
public function __construct(string $name, $value = null) {
$this->setName($name);
$this->add($value);
}
@@ -57,7 +58,7 @@ class Attribute implements ArrayAccess {
*
* @return string
*/
public function toString(){
public function toString(): string {
return $this->__toString();
}
@@ -66,16 +67,16 @@ class Attribute implements ArrayAccess {
*
* @return array
*/
public function toArray(){
public function toArray(): array {
return $this->values;
}
/**
* Convert first value to a date object
*
* @return Carbon|null
* @return Carbon
*/
public function toDate(){
public function toDate(): Carbon {
$date = $this->first();
if ($date instanceof Carbon) return $date;
@@ -85,47 +86,49 @@ class Attribute implements ArrayAccess {
/**
* Determine if a value exists at an offset.
*
* @param mixed $key
* @param mixed $offset
* @return bool
*/
public function offsetExists($key): bool {
return array_key_exists($key, $this->values);
public function offsetExists($offset): bool {
return array_key_exists($offset, $this->values);
}
/**
* Get a value at a given offset.
*
* @param mixed $key
* @param mixed $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key) {
return $this->values[$key];
#[ReturnTypeWillChange]
public function offsetGet($offset) {
return $this->values[$offset];
}
/**
* Set the value at a given offset.
*
* @param mixed $key
* @param mixed $offset
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value): void {
if (is_null($key)) {
#[ReturnTypeWillChange]
public function offsetSet($offset, $value) {
if (is_null($offset)) {
$this->values[] = $value;
} else {
$this->values[$key] = $value;
$this->values[$offset] = $value;
}
}
/**
* Unset the value at a given offset.
*
* @param string $key
* @param string $offset
* @return void
*/
public function offsetUnset($key): void {
unset($this->values[$key]);
#[ReturnTypeWillChange]
public function offsetUnset($offset) {
unset($this->values[$offset]);
}
/**
@@ -135,7 +138,7 @@ class Attribute implements ArrayAccess {
*
* @return Attribute
*/
public function add($value, $strict = false) {
public function add($value, bool $strict = false): Attribute {
if (is_array($value)) {
return $this->merge($value, $strict);
}elseif ($value !== null) {
@@ -152,11 +155,9 @@ class Attribute implements ArrayAccess {
*
* @return Attribute
*/
public function merge($values, $strict = false) {
if (is_array($values)) {
foreach ($values as $value) {
$this->attach($value, $strict);
}
public function merge(array $values, bool $strict = false): Attribute {
foreach ($values as $value) {
$this->attach($value, $strict);
}
return $this;
@@ -168,13 +169,8 @@ class Attribute implements ArrayAccess {
*
* @return bool
*/
public function contains($value) {
foreach ($this->values as $v) {
if ($v === $value) {
return true;
}
}
return false;
public function contains($value): bool {
return in_array($value, $this->values, true);
}
/**
@@ -182,7 +178,7 @@ class Attribute implements ArrayAccess {
* @param $value
* @param bool $strict
*/
public function attach($value, $strict = false) {
public function attach($value, bool $strict = false) {
if ($strict === true) {
if ($this->contains($value) === false) {
$this->values[] = $value;
@@ -198,7 +194,7 @@ class Attribute implements ArrayAccess {
*
* @return Attribute
*/
public function setName($name){
public function setName($name): Attribute {
$this->name = $name;
return $this;
@@ -209,7 +205,7 @@ class Attribute implements ArrayAccess {
*
* @return string
*/
public function getName(){
public function getName(): string {
return $this->name;
}
@@ -218,7 +214,7 @@ class Attribute implements ArrayAccess {
*
* @return array
*/
public function get(){
public function get(): array {
return $this->values;
}
@@ -227,7 +223,7 @@ class Attribute implements ArrayAccess {
*
* @return array
*/
public function all(){
public function all(): array {
return $this->get();
}
@@ -260,7 +256,7 @@ class Attribute implements ArrayAccess {
*
* @return int
*/
public function count(){
public function count(): int {
return count($this->values);
}
}

View File

@@ -174,7 +174,7 @@ class Client {
*
* @throws MaskNotFoundException
*/
public function __construct($config = []) {
public function __construct(array $config = []) {
$this->setConfig($config);
$this->setMaskFromConfig($config);
$this->setEventsFromConfig($config);
@@ -193,7 +193,7 @@ class Client {
*
* @return self
*/
public function setConfig(array $config) {
public function setConfig(array $config): Client {
$default_account = ClientManager::get('default');
$default_config = ClientManager::get("accounts.$default_account");
@@ -210,7 +210,7 @@ class Client {
* @param array $config
* @param array $default_config
*/
private function setAccountConfig($key, $config, $default_config){
private function setAccountConfig(string $key, array $config, array $default_config){
$value = $this->default_account_config[$key];
if(isset($config[$key])) {
$value = $config[$key];
@@ -301,8 +301,8 @@ class Client {
*
* @return bool
*/
public function isConnected() {
return $this->connection ? $this->connection->connected() : false;
public function isConnected(): bool {
return $this->connection && $this->connection->connected();
}
/**
@@ -317,7 +317,7 @@ class Client {
}
/**
* Force a reconnect
* Force the connection to reconnect
*
* @throws ConnectionFailedException
*/
@@ -334,7 +334,7 @@ class Client {
* @return $this
* @throws ConnectionFailedException
*/
public function connect() {
public function connect(): Client {
$this->disconnect();
$protocol = strtolower($this->protocol);
@@ -397,7 +397,7 @@ class Client {
*
* @return $this
*/
public function disconnect() {
public function disconnect(): Client {
if ($this->isConnected() && $this->connection !== false) {
$this->connection->logout();
}
@@ -411,12 +411,12 @@ class Client {
* @param string $folder_name
* @param string|bool|null $delimiter
*
* @return mixed
* @return Folder|null
* @throws ConnectionFailedException
* @throws FolderFetchingException
* @throws Exceptions\RuntimeException
*/
public function getFolder($folder_name, $delimiter = null) {
public function getFolder(string $folder_name, $delimiter = null) {
if ($delimiter !== false && $delimiter !== null) {
return $this->getFolderByPath($folder_name);
}
@@ -434,7 +434,7 @@ class Client {
* Get a folder instance by a folder name
* @param $folder_name
*
* @return mixed
* @return Folder|null
* @throws ConnectionFailedException
* @throws FolderFetchingException
* @throws Exceptions\RuntimeException
@@ -447,7 +447,7 @@ class Client {
* Get a folder instance by a folder path
* @param $folder_path
*
* @return mixed
* @return Folder|null
* @throws ConnectionFailedException
* @throws FolderFetchingException
* @throws Exceptions\RuntimeException
@@ -468,7 +468,7 @@ class Client {
* @throws FolderFetchingException
* @throws Exceptions\RuntimeException
*/
public function getFolders($hierarchical = true, $parent_folder = null) {
public function getFolders(bool $hierarchical = true, string $parent_folder = null): FolderCollection {
$this->checkConnection();
$folders = FolderCollection::make([]);
@@ -495,16 +495,56 @@ class Client {
}
}
/**
* Get folders list.
* If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array.
*
* @param boolean $hierarchical
* @param string|null $parent_folder
*
* @return FolderCollection
* @throws ConnectionFailedException
* @throws FolderFetchingException
* @throws Exceptions\RuntimeException
*/
public function getFoldersWithStatus(bool $hierarchical = true, string $parent_folder = null): FolderCollection {
$this->checkConnection();
$folders = FolderCollection::make([]);
$pattern = $parent_folder.($hierarchical ? '%' : '*');
$items = $this->connection->folders('', $pattern);
if(is_array($items)){
foreach ($items as $folder_name => $item) {
$folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
if ($hierarchical && $folder->hasChildren()) {
$pattern = $folder->full_name.$folder->delimiter.'%';
$children = $this->getFoldersWithStatus(true, $pattern);
$folder->setChildren($children);
}
$folder->loadStatus();
$folders->push($folder);
}
return $folders;
}else{
throw new FolderFetchingException("failed to fetch any folders");
}
}
/**
* Open a given folder.
* @param string $folder_path
* @param boolean $force_select
*
* @return mixed
* @return array|bool
* @throws ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function openFolder($folder_path, $force_select = false) {
public function openFolder(string $folder_path, bool $force_select = false) {
if ($this->active_folder == $folder_path && $this->isConnected() && $force_select === false) {
return true;
}
@@ -524,13 +564,13 @@ class Client {
* @throws Exceptions\EventNotFoundException
* @throws Exceptions\RuntimeException
*/
public function createFolder($folder, $expunge = true) {
public function createFolder(string $folder, bool $expunge = true): Folder {
$this->checkConnection();
$status = $this->connection->createFolder($folder);
if($expunge) $this->expunge();
$folder = $this->getFolder($folder);
$folder = $this->getFolderByPath($folder);
if($status && $folder) {
$event = $this->getEvent("folder", "new");
$event::dispatch($folder);
@@ -543,7 +583,7 @@ class Client {
* Check a given folder
* @param $folder
*
* @return false|object
* @return array|bool
* @throws ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
@@ -565,13 +605,13 @@ class Client {
* Exchange identification information
* Ref.: https://datatracker.ietf.org/doc/html/rfc2971
*
* @param null|array $ids
* @param array|null $ids
* @return array|bool|void|null
*
* @throws ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function Id($ids = null) {
public function Id(array $ids = null) {
$this->checkConnection();
return $this->connection->ID($ids);
}
@@ -583,7 +623,7 @@ class Client {
* @throws ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function getQuota() {
public function getQuota(): array {
$this->checkConnection();
return $this->connection->getQuota($this->username);
}
@@ -595,7 +635,7 @@ class Client {
* @return array
* @throws ConnectionFailedException
*/
public function getQuotaRoot($quota_root = 'INBOX') {
public function getQuotaRoot(string $quota_root = 'INBOX'): array {
$this->checkConnection();
return $this->connection->getQuotaRoot($quota_root);
}
@@ -607,7 +647,7 @@ class Client {
* @throws ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function expunge() {
public function expunge(): bool {
$this->checkConnection();
return $this->connection->expunge();
}
@@ -619,9 +659,13 @@ class Client {
* @return Protocol
* @throws ConnectionFailedException
*/
public function setTimeout($timeout) {
$this->checkConnection();
return $this->connection->setConnectionTimeout($timeout);
public function setTimeout(int $timeout): Protocol {
$this->timeout = $timeout;
if ($this->isConnected()) {
$this->connection->setConnectionTimeout($timeout);
$this->reconnect();
}
return $this->connection;
}
/**
@@ -630,7 +674,7 @@ class Client {
* @return int
* @throws ConnectionFailedException
*/
public function getTimeout(){
public function getTimeout(): int {
$this->checkConnection();
return $this->connection->getConnectionTimeout();
}
@@ -640,7 +684,7 @@ class Client {
*
* @return string
*/
public function getDefaultMessageMask(){
public function getDefaultMessageMask(): string {
return $this->default_message_mask;
}
@@ -650,18 +694,21 @@ class Client {
*
* @return array
*/
public function getDefaultEvents($section){
return $this->events[$section];
public function getDefaultEvents($section): array {
if (isset($this->events[$section])) {
return is_array($this->events[$section]) ? $this->events[$section] : [];
}
return [];
}
/**
* Set the default message mask
* @param $mask
* @param string $mask
*
* @return $this
* @throws MaskNotFoundException
*/
public function setDefaultMessageMask($mask) {
public function setDefaultMessageMask(string $mask): Client {
if(class_exists($mask)) {
$this->default_message_mask = $mask;
@@ -676,18 +723,18 @@ class Client {
*
* @return string
*/
public function getDefaultAttachmentMask(){
public function getDefaultAttachmentMask(): string {
return $this->default_attachment_mask;
}
/**
* Set the default attachment mask
* @param $mask
* @param string $mask
*
* @return $this
* @throws MaskNotFoundException
*/
public function setDefaultAttachmentMask($mask) {
public function setDefaultAttachmentMask(string $mask): Client {
if(class_exists($mask)) {
$this->default_attachment_mask = $mask;

View File

@@ -43,13 +43,13 @@ class ClientManager {
/**
* Dynamically pass calls to the default account.
* @param string $method
* @param array $parameters
* @param string $method
* @param array $parameters
*
* @return mixed
* @throws Exceptions\MaskNotFoundException
*/
public function __call($method, $parameters) {
public function __call(string $method, array $parameters) {
$callable = [$this->account(), $method];
return call_user_func_array($callable, $parameters);
@@ -62,7 +62,7 @@ class ClientManager {
* @return Client
* @throws Exceptions\MaskNotFoundException
*/
public function make($config) {
public function make(array $config): Client {
return new Client($config);
}
@@ -73,7 +73,7 @@ class ClientManager {
*
* @return mixed|null
*/
public static function get($key, $default = null) {
public static function get(string $key, $default = null) {
$parts = explode('.', $key);
$value = null;
foreach($parts as $part) {
@@ -97,16 +97,16 @@ class ClientManager {
/**
* Resolve a account instance.
* @param string $name
* @param string|null $name
*
* @return Client
* @throws Exceptions\MaskNotFoundException
*/
public function account($name = null) {
public function account(string $name = null): Client {
$name = $name ?: $this->getDefaultAccount();
// If the connection has not been resolved yet we will resolve it now as all
// of the connections are resolved when they are actually needed so we do
// If the connection has not been resolved we will resolve it now as all
// the connections are resolved when they are actually needed, so we do
// not make any unnecessary connection to the various queue end-points.
if (!isset($this->accounts[$name])) {
$this->accounts[$name] = $this->resolve($name);
@@ -116,14 +116,13 @@ class ClientManager {
}
/**
* Resolve a account.
*
* @param string $name
* Resolve an account.
* @param string $name
*
* @return Client
* @throws Exceptions\MaskNotFoundException
*/
protected function resolve($name) {
protected function resolve(string $name): Client {
$config = $this->getClientConfig($name);
return new Client($config);
@@ -131,16 +130,16 @@ class ClientManager {
/**
* Get the account configuration.
* @param string $name
* @param string|null $name
*
* @return array
*/
protected function getClientConfig($name) {
protected function getClientConfig($name): array {
if ($name === null || $name === 'null') {
return ['driver' => 'null'];
}
return self::$config["accounts"][$name];
return is_array(self::$config["accounts"][$name]) ? self::$config["accounts"][$name] : [];
}
/**
@@ -148,17 +147,17 @@ class ClientManager {
*
* @return string
*/
public function getDefaultAccount() {
public function getDefaultAccount(): string {
return self::$config['default'];
}
/**
* Set the name of the default account.
* @param string $name
* @param string $name
*
* @return void
*/
public function setDefaultAccount($name) {
public function setDefaultAccount(string $name) {
self::$config['default'] = $name;
}
@@ -174,7 +173,7 @@ class ClientManager {
*
* @return $this
*/
public function setConfig($config) {
public function setConfig($config): ClientManager {
if(is_array($config) === false) {
$config = require $config;
@@ -188,7 +187,7 @@ class ClientManager {
if(is_array($config)){
if(isset($config['default'])){
if(isset($config['accounts']) && $config['default'] != false){
if(isset($config['accounts']) && $config['default']){
$default_config = $vendor_config['accounts']['default'];
if(isset($config['accounts'][$config['default']])){
@@ -219,9 +218,6 @@ class ClientManager {
* Numeric entries are appended, not replaced, but only if they are
* unique
*
* @param array $array1 Initial array to merge.
* @param array ... Variable list of arrays to recursively merge.
*
* @return array|mixed
*
* @link http://www.php.net/manual/en/function.array-merge-recursive.php#96201
@@ -247,7 +243,7 @@ class ClientManager {
foreach($append as $key => $value) {
if(!array_key_exists($key, $base) and !is_numeric($key)) {
$base[$key] = $append[$key];
$base[$key] = $value;
continue;
}
@@ -264,7 +260,7 @@ class ClientManager {
// If the arrays are not associates we don't want to array_merge_recursive_distinct
// else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment']
// results in $resultConfig['dispositions'] = ['attachment', 'inline']
$base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
$base[$key] = $this->array_merge_recursive_distinct($base[$key], $value);
} else if(is_numeric($key)) {
if(!in_array($value, $base)) $base[] = $value;
} else {

View File

@@ -39,7 +39,7 @@ class ImapProtocol extends Protocol {
* @param bool $cert_validation set to false to skip SSL certificate validation
* @param mixed $encryption Connection encryption method
*/
public function __construct($cert_validation = true, $encryption = false) {
public function __construct(bool $cert_validation = true, $encryption = false) {
$this->setCertValidation($cert_validation);
$this->encryption = $encryption;
}
@@ -58,7 +58,7 @@ class ImapProtocol extends Protocol {
*
* @throws ConnectionFailedException
*/
public function connect($host, $port = null) {
public function connect(string $host, $port = null) {
$transport = 'tcp';
$encryption = '';
@@ -103,14 +103,16 @@ class ImapProtocol extends Protocol {
* @return string next line
* @throws RuntimeException
*/
public function nextLine() {
$line = fgets($this->stream);
if ($line === false) {
throw new RuntimeException('failed to read - connection closed?');
public function nextLine(): string {
$line = "";
while (($next_char = fread($this->stream, 1)) !== false && $next_char !== "\n") {
$line .= $next_char;
}
return $line;
if ($line === "" && $next_char === false) {
throw new RuntimeException('empty response');
}
if ($this->debug) echo "<< ".$line."\n";
return $line . "\n";
}
/**
@@ -120,25 +122,37 @@ class ImapProtocol extends Protocol {
* @return bool
* @throws RuntimeException
*/
protected function assumedNextLine($start) {
$line = $this->nextLine();
return strpos($line, $start) === 0;
protected function assumedNextLine(string $start): bool {
return strpos($this->nextLine(), $start) === 0;
}
/**
* Get the next line and split the tag
* @param string $tag reference tag
* @param string|null $tag reference tag
*
* @return string next line
* @throws RuntimeException
*/
protected function nextTaggedLine(&$tag) {
protected function nextTaggedLine(&$tag): string {
$line = $this->nextLine();
list($tag, $line) = explode(' ', $line, 2);
return $line;
}
/**
* Get the next line and check if it contains a given string and split the tag
* @param string $start
* @param $tag
*
* @return bool
* @throws RuntimeException
*/
protected function assumedNextTaggedLine(string $start, &$tag): bool {
$line = $this->nextTaggedLine($tag);
return strpos($line, $start) !== false;
}
/**
* Split a given line in values. A value is literal of any form or a list
* @param string $line
@@ -146,7 +160,7 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
protected function decodeLine($line) {
protected function decodeLine(string $line): array {
$tokens = [];
$stack = [];
@@ -155,10 +169,11 @@ class ImapProtocol extends Protocol {
while (($pos = strpos($line, ' ')) !== false) {
$token = substr($line, 0, $pos);
if (!strlen($token)) {
$line = substr($line, $pos + 1);
continue;
}
while ($token[0] == '(') {
array_push($stack, $tokens);
$stack[] = $tokens;
$tokens = [];
$token = substr($token, 1);
}
@@ -231,14 +246,13 @@ class ImapProtocol extends Protocol {
* @return bool
* @throws RuntimeException
*/
public function readLine(&$tokens = [], $wantedTag = '*', $dontParse = false) {
public function readLine(&$tokens = [], string $wantedTag = '*', bool $dontParse = false): bool {
$line = $this->nextTaggedLine($tag); // get next tag
if (!$dontParse) {
$tokens = $this->decodeLine($line);
} else {
$tokens = $line;
}
if ($this->debug) echo "<< ".$line."\n";
// if tag is wanted tag we might be at the end of a multiline response
return $tag == $wantedTag;
@@ -249,10 +263,10 @@ class ImapProtocol extends Protocol {
* @param string $tag request tag
* @param bool $dontParse if true every line is returned unparsed instead of the decoded tokens
*
* @return void|null|bool|array tokens if success, false if error, null if bad request
* @return array|bool|null tokens if success, false if error, null if bad request
* @throws RuntimeException
*/
public function readResponse($tag, $dontParse = false) {
public function readResponse(string $tag, bool $dontParse = false) {
$lines = [];
$tokens = null; // define $tokens variable before first use
do {
@@ -272,18 +286,18 @@ class ImapProtocol extends Protocol {
return false;
}
return;
return null;
}
/**
* Send a new request
* @param string $command
* @param array $tokens additional parameters to command, use escapeString() to prepare
* @param string $tag provide a tag otherwise an autogenerated is returned
* @param string|null $tag provide a tag otherwise an autogenerated is returned
*
* @throws RuntimeException
*/
public function sendRequest($command, $tokens = [], &$tag = null) {
public function sendRequest(string $command, array $tokens = [], string &$tag = null) {
if (!$tag) {
$this->noun++;
$tag = 'TAG' . $this->noun;
@@ -293,9 +307,7 @@ class ImapProtocol extends Protocol {
foreach ($tokens as $token) {
if (is_array($token)) {
if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
throw new RuntimeException('failed to write - connection closed?');
}
$this->write($line . ' ' . $token[0]);
if (!$this->assumedNextLine('+ ')) {
throw new RuntimeException('failed to send literal string');
}
@@ -304,9 +316,19 @@ class ImapProtocol extends Protocol {
$line .= ' ' . $token;
}
}
if ($this->debug) echo ">> ".$line."\n";
$this->write($line);
}
if (fwrite($this->stream, $line . "\r\n") === false) {
/**
* Write data to the current stream
* @param string $data
* @return void
* @throws RuntimeException
*/
public function write(string $data) {
if ($this->debug) echo ">> ".$data ."\n";
if (fwrite($this->stream, $data . "\r\n") === false) {
throw new RuntimeException('failed to write - connection closed?');
}
}
@@ -317,10 +339,10 @@ class ImapProtocol extends Protocol {
* @param array $tokens parameters as in sendRequest()
* @param bool $dontParse if true unparsed lines are returned instead of tokens
*
* @return void|null|bool|array response as in readResponse()
* @return array|bool|null response as in readResponse()
* @throws RuntimeException
*/
public function requestAndResponse($command, $tokens = [], $dontParse = false) {
public function requestAndResponse(string $command, array $tokens = [], bool $dontParse = false) {
$this->sendRequest($command, $tokens, $tag);
return $this->readResponse($tag, $dontParse);
@@ -354,7 +376,7 @@ class ImapProtocol extends Protocol {
*
* @return string escaped list for imap
*/
public function escapeList($list) {
public function escapeList(array $list): string {
$result = [];
foreach ($list as $v) {
if (!is_array($v)) {
@@ -374,9 +396,10 @@ class ImapProtocol extends Protocol {
* @return bool|mixed
* @throws AuthFailedException
*/
public function login($user, $password) {
public function login(string $user, string $password): bool {
try {
return $this->requestAndResponse('LOGIN', $this->escapeString($user, $password), true);
$response = $this->requestAndResponse('LOGIN', $this->escapeString($user, $password), true);
return $response !== null && $response !== false;
} catch (RuntimeException $e) {
throw new AuthFailedException("failed to authenticate", 0, $e);
}
@@ -390,7 +413,7 @@ class ImapProtocol extends Protocol {
* @return bool
* @throws AuthFailedException
*/
public function authenticate($user, $token) {
public function authenticate(string $user, string $token): bool {
try {
$authenticateParams = ['XOAUTH2', base64_encode("user=$user\1auth=Bearer $token\1\1")];
$this->sendRequest('AUTHENTICATE', $authenticateParams);
@@ -416,7 +439,6 @@ class ImapProtocol extends Protocol {
} catch (RuntimeException $e) {
throw new AuthFailedException("failed to authenticate", 0, $e);
}
return false;
}
/**
@@ -424,7 +446,7 @@ class ImapProtocol extends Protocol {
*
* @return bool success
*/
public function logout() {
public function logout(): bool {
$result = false;
if ($this->stream) {
try {
@@ -435,7 +457,7 @@ class ImapProtocol extends Protocol {
$this->uid_cache = null;
}
return $result;
return $result !== false;
}
/**
@@ -443,7 +465,7 @@ class ImapProtocol extends Protocol {
*
* @return bool
*/
public function connected(){
public function connected(): bool {
return (boolean) $this->stream;
}
@@ -453,7 +475,7 @@ class ImapProtocol extends Protocol {
* @return array list of capabilities
* @throws RuntimeException
*/
public function getCapabilities() {
public function getCapabilities(): array {
$response = $this->requestAndResponse('CAPABILITY');
if (!$response) return [];
@@ -473,7 +495,7 @@ class ImapProtocol extends Protocol {
* @return bool|array
* @throws RuntimeException
*/
public function examineOrSelect($command = 'EXAMINE', $folder = 'INBOX') {
public function examineOrSelect(string $command = 'EXAMINE', string $folder = 'INBOX') {
$this->sendRequest($command, [$this->escapeString($folder)], $tag);
$result = [];
@@ -487,7 +509,7 @@ class ImapProtocol extends Protocol {
switch ($tokens[1]) {
case 'EXISTS':
case 'RECENT':
$result[strtolower($tokens[1])] = $tokens[0];
$result[strtolower($tokens[1])] = (int)$tokens[0];
break;
case '[UIDVALIDITY':
$result['uidvalidity'] = (int)$tokens[2];
@@ -495,6 +517,11 @@ class ImapProtocol extends Protocol {
case '[UIDNEXT':
$result['uidnext'] = (int)$tokens[2];
break;
case '[UNSEEN':
$result['unseen'] = (int)$tokens[2];
break;
case '[NONEXISTENT]':
throw new RuntimeException("folder doesn't exist");
default:
// ignore
break;
@@ -514,7 +541,7 @@ class ImapProtocol extends Protocol {
* @return bool|array see examineOrselect()
* @throws RuntimeException
*/
public function selectFolder($folder = 'INBOX') {
public function selectFolder(string $folder = 'INBOX') {
$this->uid_cache = null;
return $this->examineOrSelect('SELECT', $folder);
@@ -527,7 +554,7 @@ class ImapProtocol extends Protocol {
* @return bool|array see examineOrselect()
* @throws RuntimeException
*/
public function examineFolder($folder = 'INBOX') {
public function examineFolder(string $folder = 'INBOX') {
return $this->examineOrSelect('EXAMINE', $folder);
}
@@ -542,7 +569,7 @@ class ImapProtocol extends Protocol {
*
* @return string|array if only one item of one message is fetched it's returned as string
* if items of one message are fetched it's returned as (name => value)
* if one items of messages are fetched it's returned as (msgno => value)
* if one item of messages are fetched it's returned as (msgno => value)
* if items of messages are fetched it's returned as (msgno => (name => value))
* @throws RuntimeException
*/
@@ -577,7 +604,12 @@ class ImapProtocol extends Protocol {
} else if ($tokens[2][0] == 'UID') {
$uidKey = 1;
} else {
$uidKey = array_search('UID', $tokens[2]) + 1;
$found = array_search('UID', $tokens[2]);
if ($found === false || $found === -1) {
continue;
}
$uidKey = $found + 1;
}
}
@@ -593,6 +625,7 @@ class ImapProtocol extends Protocol {
} elseif ($uid && $tokens[2][2] == $items[0]) {
$data = $tokens[2][3];
} else {
$expectedResponse = 0;
// maybe the server send an other field we didn't wanted
$count = count($tokens[2]);
// we start with 2, because 0 was already checked
@@ -601,8 +634,12 @@ class ImapProtocol extends Protocol {
continue;
}
$data = $tokens[2][$i + 1];
$expectedResponse = 1;
break;
}
if (!$expectedResponse) {
continue;
}
}
} else {
$data = [];
@@ -643,8 +680,9 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
public function content($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) {
return $this->fetch(["$rfc.TEXT"], $uids, null, $uid);
public function content($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array {
$result = $this->fetch(["$rfc.TEXT"], $uids, null, $uid);
return is_array($result) ? $result : [];
}
/**
@@ -657,8 +695,9 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){
return $this->fetch(["$rfc.HEADER"], $uids, null, $uid);
public function headers($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array{
$result = $this->fetch(["$rfc.HEADER"], $uids, null, $uid);
return $result === "" ? [] : $result;
}
/**
@@ -670,8 +709,9 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
public function flags($uids, $uid = IMAP::ST_UID){
return $this->fetch(["FLAGS"], $uids, null, $uid);
public function flags($uids, $uid = IMAP::ST_UID): array {
$result = $this->fetch(["FLAGS"], $uids, null, $uid);
return is_array($result) ? $result : [];
}
/**
@@ -682,15 +722,12 @@ class ImapProtocol extends Protocol {
* @throws MessageNotFoundException
*/
public function getUid($id = null) {
if ($this->enable_uid_cache && $this->uid_cache) {
$uids = $this->uid_cache;
} else {
if (!$this->enable_uid_cache || $this->uid_cache === null || ($this->uid_cache && count($this->uid_cache) <= 0)) {
try {
$uids = $this->fetch('UID', 1, INF);
$this->setUidCache($uids); // set cache for this folder
$this->setUidCache($this->fetch('UID', 1, INF)); // set cache for this folder
} catch (RuntimeException $e) {}
}
$uids = $this->uid_cache;
if ($id == null) {
return $uids;
@@ -718,11 +755,11 @@ class ImapProtocol extends Protocol {
* @return int message number
* @throws MessageNotFoundException
*/
public function getMessageNumber($id) {
public function getMessageNumber(string $id): int {
$ids = $this->getUid();
foreach ($ids as $k => $v) {
if ($v == $id) {
return $k;
return (int)$k;
}
}
@@ -737,7 +774,7 @@ class ImapProtocol extends Protocol {
* @return array folders that matched $folder as array(name => array('delimiter' => .., 'flags' => ..))
* @throws RuntimeException
*/
public function folders($reference = '', $folder = '*') {
public function folders(string $reference = '', string $folder = '*'): array {
$result = [];
$list = $this->requestAndResponse('LIST', $this->escapeString($reference, $folder));
if (!$list || $list === true) {
@@ -769,7 +806,7 @@ class ImapProtocol extends Protocol {
* @return bool|array new flags if $silent is false, else true or false depending on success
* @throws RuntimeException
*/
public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID, $item = null) {
public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) {
$flags = $this->escapeList($flags);
$set = $this->buildSet($from, $to);
@@ -797,13 +834,13 @@ class ImapProtocol extends Protocol {
* Append a new message to given folder
* @param string $folder name of target folder
* @param string $message full message content
* @param array $flags flags for new message
* @param array|null $flags flags for new message
* @param string $date date for new message
*
* @return bool success
* @throws RuntimeException
*/
public function appendMessage($folder, $message, $flags = null, $date = null) {
public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool {
$tokens = [];
$tokens[] = $this->escapeString($folder);
if ($flags !== null) {
@@ -814,7 +851,7 @@ class ImapProtocol extends Protocol {
}
$tokens[] = $this->escapeString($message);
return $this->requestAndResponse('APPEND', $tokens, true);
return (bool) $this->requestAndResponse('APPEND', $tokens, true);
}
/**
@@ -829,16 +866,16 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function copyMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) {
public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool {
$set = $this->buildSet($from, $to);
$command = $this->buildUIDCommand("COPY", $uid);
return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
}
/**
* Copy multiple messages to the target folder
*
* @param array<string> $messages List of message identifiers
* @param array $messages List of message identifiers
* @param string $folder Destination folder
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
* message numbers instead.
@@ -846,7 +883,7 @@ class ImapProtocol extends Protocol {
*
* @throws RuntimeException
*/
public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
$command = $this->buildUIDCommand("COPY", $uid);
$set = implode(',', $messages);
@@ -867,16 +904,16 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function moveMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) {
public function moveMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool {
$set = $this->buildSet($from, $to);
$command = $this->buildUIDCommand("MOVE", $uid);
return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
}
/**
* Move multiple messages to the target folder
* @param array<string> $messages List of message identifiers
* @param array $messages List of message identifiers
* @param string $folder Destination folder
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
* message numbers instead.
@@ -884,7 +921,7 @@ class ImapProtocol extends Protocol {
* @return array|bool Tokens if operation successful, false if an error occurred
* @throws RuntimeException
*/
public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
$command = $this->buildUIDCommand("MOVE", $uid);
$set = implode(',', $messages);
@@ -922,8 +959,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function createFolder($folder) {
return $this->requestAndResponse('CREATE', [$this->escapeString($folder)], true);
public function createFolder(string $folder): bool {
return (bool)$this->requestAndResponse('CREATE', [$this->escapeString($folder)], true);
}
/**
@@ -934,8 +971,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function renameFolder($old, $new) {
return $this->requestAndResponse('RENAME', $this->escapeString($old, $new), true);
public function renameFolder(string $old, string $new): bool {
return (bool)$this->requestAndResponse('RENAME', $this->escapeString($old, $new), true);
}
/**
@@ -945,8 +982,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function deleteFolder($folder) {
return $this->requestAndResponse('DELETE', [$this->escapeString($folder)], true);
public function deleteFolder(string $folder): bool {
return (bool)$this->requestAndResponse('DELETE', [$this->escapeString($folder)], true);
}
/**
@@ -956,8 +993,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function subscribeFolder($folder) {
return $this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true);
public function subscribeFolder(string $folder): bool {
return (bool)$this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true);
}
/**
@@ -967,8 +1004,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function unsubscribeFolder($folder) {
return $this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true);
public function unsubscribeFolder(string $folder): bool {
return (bool)$this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true);
}
/**
@@ -977,8 +1014,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function expunge() {
return $this->requestAndResponse('EXPUNGE');
public function expunge(): bool {
return (bool)$this->requestAndResponse('EXPUNGE');
}
/**
@@ -987,8 +1024,8 @@ class ImapProtocol extends Protocol {
* @return bool success
* @throws RuntimeException
*/
public function noop() {
return $this->requestAndResponse('NOOP');
public function noop(): bool {
return (bool)$this->requestAndResponse('NOOP');
}
/**
@@ -998,8 +1035,9 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
public function getQuota($username) {
return $this->requestAndResponse("GETQUOTA", ['"#user/'.$username.'"']);
public function getQuota($username): array {
$result = $this->requestAndResponse("GETQUOTA", ['"#user/'.$username.'"']);
return is_array($result) ? $result : [];
}
/**
@@ -1009,8 +1047,9 @@ class ImapProtocol extends Protocol {
* @return array
* @throws RuntimeException
*/
public function getQuotaRoot($quota_root = 'INBOX') {
return $this->requestAndResponse("QUOTA", [$quota_root]);
public function getQuotaRoot(string $quota_root = 'INBOX'): array {
$result = $this->requestAndResponse("QUOTA", [$quota_root]);
return is_array($result) ? $result : [];
}
/**
@@ -1029,9 +1068,10 @@ class ImapProtocol extends Protocol {
* Send done command
* @throws RuntimeException
*/
public function done() {
if (fwrite($this->stream, "DONE\r\n") === false) {
throw new RuntimeException('failed to write - connection closed?');
public function done(): bool {
$this->write("DONE");
if (!$this->assumedNextTaggedLine('OK', $tags)) {
throw new RuntimeException('done failed');
}
return true;
}
@@ -1045,12 +1085,10 @@ class ImapProtocol extends Protocol {
* @return array message ids
* @throws RuntimeException
*/
public function search(array $params, $uid = IMAP::ST_UID) {
public function search(array $params, $uid = IMAP::ST_UID): array {
$command = $this->buildUIDCommand("SEARCH", $uid);
$response = $this->requestAndResponse($command, $params);
if (!$response) {
return $response;
}
if (!$response) return [];
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
@@ -1072,7 +1110,7 @@ class ImapProtocol extends Protocol {
* @throws MessageNotFoundException
* @throws InvalidMessageDateException
*/
public function overview($sequence, $uid = IMAP::ST_UID) {
public function overview(string $sequence, $uid = IMAP::ST_UID): array {
$result = [];
list($from, $to) = explode(":", $sequence);

View File

@@ -35,7 +35,7 @@ class LegacyProtocol extends Protocol {
* @param bool $cert_validation set to false to skip SSL certificate validation
* @param mixed $encryption Connection encryption method
*/
public function __construct($cert_validation = true, $encryption = false) {
public function __construct(bool $cert_validation = true, $encryption = false) {
$this->setCertValidation($cert_validation);
$this->encryption = $encryption;
}
@@ -52,7 +52,7 @@ class LegacyProtocol extends Protocol {
* @param string $host
* @param null $port
*/
public function connect($host, $port = null) {
public function connect(string $host, $port = null) {
if ($this->encryption) {
$encryption = strtolower($this->encryption);
if ($encryption == "ssl") {
@@ -73,7 +73,7 @@ class LegacyProtocol extends Protocol {
* @throws AuthFailedException
* @throws RuntimeException
*/
public function login($user, $password) {
public function login(string $user, string $password): bool {
try {
$this->stream = \imap_open(
$this->getAddress(),
@@ -104,7 +104,7 @@ class LegacyProtocol extends Protocol {
}
}
return $this->stream;
return $this->stream !== false;
}
/**
@@ -115,7 +115,7 @@ class LegacyProtocol extends Protocol {
* @return bool|resource
* @throws AuthFailedException|RuntimeException
*/
public function authenticate($user, $token) {
public function authenticate(string $user, string $token): bool {
return $this->login($user, $token);
}
@@ -124,7 +124,7 @@ class LegacyProtocol extends Protocol {
*
* @return string
*/
protected function getAddress() {
protected function getAddress(): string {
$address = "{".$this->host.":".$this->port."/".$this->protocol;
if (!$this->cert_validation) {
$address .= '/novalidate-cert';
@@ -145,7 +145,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function logout() {
public function logout(): bool {
if ($this->stream) {
$result = \imap_close($this->stream, IMAP::CL_EXPUNGE);
$this->stream = false;
@@ -160,7 +160,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool
*/
public function connected(){
public function connected(): bool {
return boolval($this->stream);
}
@@ -169,7 +169,7 @@ class LegacyProtocol extends Protocol {
*
* @throws MethodNotSupportedException
*/
public function getCapabilities() {
public function getCapabilities(): array {
throw new MethodNotSupportedException();
}
@@ -180,8 +180,16 @@ class LegacyProtocol extends Protocol {
* @return bool|array see examineOrselect()
* @throws RuntimeException
*/
public function selectFolder($folder = 'INBOX') {
\imap_reopen($this->stream, $folder, IMAP::OP_READONLY, 3);
public function selectFolder(string $folder = 'INBOX') {
$flags = IMAP::OP_READONLY;
if (in_array($this->protocol, ["pop3", "nntp"])) {
$flags = IMAP::NIL;
}
if ($this->stream === false) {
throw new RuntimeException("failed to reopen stream.");
}
\imap_reopen($this->stream, $this->getAddress().$folder, $flags, 3);
$this->uid_cache = null;
return $this->examineFolder($folder);
}
@@ -193,7 +201,7 @@ class LegacyProtocol extends Protocol {
* @return bool|array
* @throws RuntimeException
*/
public function examineFolder($folder = 'INBOX') {
public function examineFolder(string $folder = 'INBOX') {
if (strpos($folder, ".") === 0) {
throw new RuntimeException("Segmentation fault prevented. Folders starts with an illegal char '.'.");
}
@@ -216,7 +224,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function content($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) {
public function content($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array {
$result = [];
$uids = is_array($uids) ? $uids : [$uids];
foreach ($uids as $id) {
@@ -233,7 +241,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){
public function headers($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array {
$result = [];
$uids = is_array($uids) ? $uids : [$uids];
foreach ($uids as $id) {
@@ -249,7 +257,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function flags($uids, $uid = IMAP::ST_UID){
public function flags($uids, $uid = IMAP::ST_UID): array {
$result = [];
$uids = is_array($uids) ? $uids : [$uids];
foreach ($uids as $id) {
@@ -300,7 +308,7 @@ class LegacyProtocol extends Protocol {
*
* @return int message number
*/
public function getMessageNumber($id) {
public function getMessageNumber(string $id): int {
return \imap_msgno($this->stream, $id);
}
@@ -311,7 +319,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function overview($sequence, $uid = IMAP::ST_UID) {
public function overview(string $sequence, $uid = IMAP::ST_UID): array {
return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL);
}
@@ -323,7 +331,7 @@ class LegacyProtocol extends Protocol {
* @return array folders that matched $folder as array(name => array('delimiter' => .., 'flags' => ..))
* @throws RuntimeException
*/
public function folders($reference = '', $folder = '*') {
public function folders(string $reference = '', string $folder = '*'): array {
$result = [];
$items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
@@ -348,10 +356,11 @@ class LegacyProtocol extends Protocol {
* @param string|null $mode '+' to add flags, '-' to remove flags, everything else sets the flags as given
* @param bool $silent if false the return values are the new flags for the wanted messages
* @param int $uid set to IMAP::ST_UID if you pass message unique identifiers instead of numbers.
* @param null $item unused attribute
*
* @return bool|array new flags if $silent is false, else true or false depending on success
*/
public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID) {
public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) {
$flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
if ($mode == "+"){
@@ -371,12 +380,12 @@ class LegacyProtocol extends Protocol {
* Append a new message to given folder
* @param string $folder name of target folder
* @param string $message full message content
* @param array $flags flags for new message
* @param array|null $flags flags for new message
* @param string $date date for new message
*
* @return bool success
*/
public function appendMessage($folder, $message, $flags = null, $date = null) {
public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool {
if ($date != null) {
if ($date instanceof \Carbon\Carbon){
$date = $date->format('d-M-Y H:i:s O');
@@ -397,21 +406,21 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function copyMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) {
public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool {
return \imap_mail_copy($this->stream, $from, $folder, $uid ? IMAP::ST_UID : IMAP::NIL);
}
/**
* Copy multiple messages to the target folder
* @param array<string> $messages List of message identifiers
* @param array $messages List of message identifiers
* @param string $folder Destination folder
* @param int $uid set to IMAP::ST_UID if you pass message unique identifiers instead of numbers.
*
* @return array|bool Tokens if operation successful, false if an error occurred
*/
public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
foreach($messages as $msg) {
if ($this->copyMessage($folder, $msg, null, $uid) == false) {
if (!$this->copyMessage($folder, $msg, null, $uid)) {
return false;
}
}
@@ -420,7 +429,7 @@ class LegacyProtocol extends Protocol {
}
/**
* Move a message set from current folder to an other folder
* Move a message set from current folder to another folder
* @param string $folder destination folder
* @param $from
* @param int|null $to if null only one message ($from) is fetched, else it's the
@@ -429,21 +438,21 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function moveMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) {
public function moveMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool {
return \imap_mail_move($this->stream, $from, $folder, $uid ? IMAP::ST_UID : IMAP::NIL);
}
/**
* Move multiple messages to the target folder
* @param array<string> $messages List of message identifiers
* @param array $messages List of message identifiers
* @param string $folder Destination folder
* @param int $uid set to IMAP::ST_UID if you pass message unique identifiers instead of numbers.
*
* @return array|bool Tokens if operation successful, false if an error occurred
*/
public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
foreach($messages as $msg) {
if ($this->moveMessage($folder, $msg, null, $uid) == false) {
if (!$this->moveMessage($folder, $msg, null, $uid)) {
return false;
}
}
@@ -470,7 +479,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function createFolder($folder) {
public function createFolder(string $folder): bool {
return \imap_createmailbox($this->stream, $folder);
}
@@ -481,7 +490,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function renameFolder($old, $new) {
public function renameFolder(string $old, string $new): bool {
return \imap_renamemailbox($this->stream, $old, $new);
}
@@ -491,7 +500,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function deleteFolder($folder) {
public function deleteFolder(string $folder): bool {
return \imap_deletemailbox($this->stream, $folder);
}
@@ -501,7 +510,7 @@ class LegacyProtocol extends Protocol {
*
* @throws MethodNotSupportedException
*/
public function subscribeFolder($folder) {
public function subscribeFolder(string $folder): bool {
throw new MethodNotSupportedException();
}
@@ -511,7 +520,7 @@ class LegacyProtocol extends Protocol {
*
* @throws MethodNotSupportedException
*/
public function unsubscribeFolder($folder) {
public function unsubscribeFolder(string $folder): bool {
throw new MethodNotSupportedException();
}
@@ -520,7 +529,7 @@ class LegacyProtocol extends Protocol {
*
* @return bool success
*/
public function expunge() {
public function expunge(): bool {
return \imap_expunge($this->stream);
}
@@ -529,7 +538,7 @@ class LegacyProtocol extends Protocol {
*
* @throws MethodNotSupportedException
*/
public function noop() {
public function noop(): bool {
throw new MethodNotSupportedException();
}
@@ -558,7 +567,7 @@ class LegacyProtocol extends Protocol {
*
* @return array message ids
*/
public function search(array $params, $uid = IMAP::ST_UID) {
public function search(array $params, $uid = IMAP::ST_UID): array {
$result = \imap_search($this->stream, $params[0], $uid ? IMAP::ST_UID : IMAP::NIL);
if ($result === false) {
return [];
@@ -586,7 +595,7 @@ class LegacyProtocol extends Protocol {
*
* @param $name
*
* @return mixed|string
* @return array|false|string|string[]|null
*/
protected function decodeFolderName($name) {
preg_match('#\{(.*)\}(.*)#', $name, $preg);
@@ -596,7 +605,7 @@ class LegacyProtocol extends Protocol {
/**
* @return string
*/
public function getProtocol() {
public function getProtocol(): string {
return $this->protocol;
}
@@ -606,7 +615,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function getQuota($username) {
public function getQuota($username): array {
return \imap_get_quota($this->stream, 'user.'.$username);
}
@@ -616,7 +625,7 @@ class LegacyProtocol extends Protocol {
*
* @return array
*/
public function getQuotaRoot($quota_root = 'INBOX') {
public function getQuotaRoot(string $quota_root = 'INBOX'): array {
return \imap_get_quotaroot($this->stream, $quota_root);
}
@@ -624,7 +633,7 @@ class LegacyProtocol extends Protocol {
* @param string $protocol
* @return LegacyProtocol
*/
public function setProtocol($protocol) {
public function setProtocol(string $protocol): LegacyProtocol {
if (($pos = strpos($protocol, "legacy")) > 0) {
$protocol = substr($protocol, 0, ($pos + 2) * -1);
}

View File

@@ -38,7 +38,7 @@ abstract class Protocol implements ProtocolInterface {
protected $enable_uid_cache = true;
/**
* @var false|resource
* @var false|\IMAP\Connection|resource
*/
public $stream = false;

View File

@@ -28,12 +28,6 @@ use Webklex\PHPIMAP\IMAP;
*/
interface ProtocolInterface {
/**
* Protocol constructor.
* @param bool $cert_validation set to false to skip SSL certificate validation
*/
public function __construct($cert_validation = true);
/**
* Public destructor
*/
@@ -48,7 +42,7 @@ interface ProtocolInterface {
* @throws ConnectionFailedException
* @throws RuntimeException
*/
public function connect($host, $port = null);
public function connect(string $host, $port = null);
/**
* Login to a new session.
@@ -58,7 +52,7 @@ interface ProtocolInterface {
* @return bool success
* @throws AuthFailedException
*/
public function login($user, $password);
public function login(string $user, string $password): bool;
/**
* Authenticate your current session.
@@ -68,21 +62,21 @@ interface ProtocolInterface {
* @return bool|mixed
* @throws AuthFailedException
*/
public function authenticate($user, $token);
public function authenticate(string $user, string $token);
/**
* Logout of the current server session
*
* @return bool success
*/
public function logout();
public function logout(): bool;
/**
* Check if the current session is connected
*
* @return bool
*/
public function connected();
public function connected(): bool;
/**
* Get an array of available capabilities
@@ -90,16 +84,16 @@ interface ProtocolInterface {
* @return array list of capabilities
* @throws RuntimeException
*/
public function getCapabilities();
public function getCapabilities(): array;
/**
* Change the current folder
*
* @param string $folder change to this folder
* @return bool|array see examineOrselect()
* @return bool|array see examineOrSelect()
* @throws RuntimeException
*/
public function selectFolder($folder = 'INBOX');
public function selectFolder(string $folder = 'INBOX');
/**
* Examine a given folder
@@ -108,7 +102,7 @@ interface ProtocolInterface {
* @return bool|array
* @throws RuntimeException
*/
public function examineFolder($folder = 'INBOX');
public function examineFolder(string $folder = 'INBOX');
/**
* Fetch message headers
@@ -120,7 +114,7 @@ interface ProtocolInterface {
* @return array
* @throws RuntimeException
*/
public function content($uids, $rfc = "RFC822", $uid = IMAP::ST_UID);
public function content($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array;
/**
* Fetch message headers
@@ -132,7 +126,7 @@ interface ProtocolInterface {
* @return array
* @throws RuntimeException
*/
public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID);
public function headers($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array;
/**
* Fetch message flags
@@ -143,7 +137,7 @@ interface ProtocolInterface {
* @return array
* @throws RuntimeException
*/
public function flags($uids, $uid = IMAP::ST_UID);
public function flags($uids, $uid = IMAP::ST_UID): array;
/**
* Get uid for a given id
@@ -161,7 +155,7 @@ interface ProtocolInterface {
* @return int message number
* @throws MessageNotFoundException
*/
public function getMessageNumber($id);
public function getMessageNumber(string $id): int;
/**
* Get a list of available folders
@@ -171,7 +165,7 @@ interface ProtocolInterface {
* @return array mailboxes that matched $folder as array(globalName => array('delim' => .., 'flags' => ..))
* @throws RuntimeException
*/
public function folders($reference = '', $folder = '*');
public function folders(string $reference = '', string $folder = '*'): array;
/**
* Set message flags
@@ -183,23 +177,24 @@ interface ProtocolInterface {
* @param bool $silent if false the return values are the new flags for the wanted messages
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
* message numbers instead.
* @param null|string $item command used to store a flag
*
* @return bool|array new flags if $silent is false, else true or false depending on success
* @throws RuntimeException
*/
public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID);
public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null);
/**
* Append a new message to given folder
* @param string $folder name of target folder
* @param string $message full message content
* @param array $flags flags for new message
* @param string $date date for new message
* @param array|null $flags flags for new message
* @param string|null $date date for new message
*
* @return bool success
* @throws RuntimeException
*/
public function appendMessage($folder, $message, $flags = null, $date = null);
public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool;
/**
* Copy message set from current folder to other folder
@@ -214,7 +209,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function copyMessage($folder, $from, $to = null, $uid = IMAP::ST_UID);
public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool;
/**
* Copy multiple messages to the target folder
@@ -226,10 +221,10 @@ interface ProtocolInterface {
* @return array|bool Tokens if operation successful, false if an error occurred
* @throws RuntimeException
*/
public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID);
public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID);
/**
* Move a message set from current folder to an other folder
* Move a message set from current folder to another folder
* @param string $folder destination folder
* @param $from
* @param int|null $to if null only one message ($from) is fetched, else it's the
@@ -239,7 +234,7 @@ interface ProtocolInterface {
*
* @return bool success
*/
public function moveMessage($folder, $from, $to = null, $uid = IMAP::ST_UID);
public function moveMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool;
/**
* Move multiple messages to the target folder
@@ -252,7 +247,7 @@ interface ProtocolInterface {
* @return array|bool Tokens if operation successful, false if an error occurred
* @throws RuntimeException
*/
public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID);
public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID);
/**
* Exchange identification information
@@ -272,7 +267,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function createFolder($folder);
public function createFolder(string $folder): bool;
/**
* Rename an existing folder
@@ -282,7 +277,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function renameFolder($old, $new);
public function renameFolder(string $old, string $new): bool;
/**
* Delete a folder
@@ -291,7 +286,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function deleteFolder($folder);
public function deleteFolder(string $folder): bool;
/**
* Subscribe to a folder
@@ -300,7 +295,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function subscribeFolder($folder);
public function subscribeFolder(string $folder): bool;
/**
* Unsubscribe from a folder
@@ -309,7 +304,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function unsubscribeFolder($folder);
public function unsubscribeFolder(string $folder): bool;
/**
* Send idle command
@@ -330,7 +325,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function expunge();
public function expunge(): bool;
/**
* Retrieve the quota level settings, and usage statics per mailbox
@@ -339,7 +334,7 @@ interface ProtocolInterface {
* @return array
* @throws RuntimeException
*/
public function getQuota($username);
public function getQuota($username): array;
/**
* Retrieve the quota settings per user
@@ -349,7 +344,7 @@ interface ProtocolInterface {
* @return array
* @throws ConnectionFailedException
*/
public function getQuotaRoot($quota_root = 'INBOX');
public function getQuotaRoot(string $quota_root = 'INBOX'): array;
/**
* Send noop command
@@ -357,7 +352,7 @@ interface ProtocolInterface {
* @return bool success
* @throws RuntimeException
*/
public function noop();
public function noop(): bool;
/**
* Do a search request
@@ -369,7 +364,7 @@ interface ProtocolInterface {
* @return array message ids
* @throws RuntimeException
*/
public function search(array $params, $uid = IMAP::ST_UID);
public function search(array $params, $uid = IMAP::ST_UID): array;
/**
* Get a message overview
@@ -382,7 +377,7 @@ interface ProtocolInterface {
* @throws MessageNotFoundException
* @throws InvalidMessageDateException
*/
public function overview($sequence, $uid = IMAP::ST_UID);
public function overview(string $sequence, $uid = IMAP::ST_UID): array;
/**
* Enable the debug mode

View File

@@ -467,12 +467,12 @@ class EncodingAliases {
/**
* Returns proper encoding mapping, if exsists. If it doesn't, return unchanged $encoding
* @param string $encoding
* @param string|null $encoding
* @param string|null $fallback
*
* @return string
*/
public static function get($encoding, $fallback = null) {
public static function get($encoding, string $fallback = null): string {
if (isset(self::$aliases[strtolower($encoding ?? '')])) {
return self::$aliases[strtolower($encoding ?? '')];
}

View File

@@ -22,7 +22,7 @@ abstract class Event {
/**
* Dispatch the event with the given arguments.
*/
public static function dispatch() {
public static function dispatch(): Event {
return new static(func_get_args());
}
}

View File

@@ -15,6 +15,7 @@ namespace Webklex\PHPIMAP;
use Carbon\Carbon;
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use Webklex\PHPIMAP\Exceptions\NotSupportedCapabilityException;
use Webklex\PHPIMAP\Exceptions\RuntimeException;
use Webklex\PHPIMAP\Query\WhereQuery;
use Webklex\PHPIMAP\Support\FolderCollection;
use Webklex\PHPIMAP\Traits\HasEvents;
@@ -108,6 +109,9 @@ class Folder {
*/
public $referral;
/** @var array */
public $status;
/**
* Folder constructor.
* @param Client $client
@@ -115,7 +119,7 @@ class Folder {
* @param string $delimiter
* @param string[] $attributes
*/
public function __construct(Client $client, $folder_name, $delimiter, $attributes) {
public function __construct(Client $client, string $folder_name, string $delimiter, array $attributes) {
$this->client = $client;
$this->events["message"] = $client->getDefaultEvents("message");
@@ -137,7 +141,7 @@ class Folder {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function query($extensions = []){
public function query(array $extensions = []): WhereQuery {
$this->getClient()->checkConnection();
$this->getClient()->openFolder($this->path);
$extensions = count($extensions) > 0 ? $extensions : $this->getClient()->extensions;
@@ -146,20 +150,26 @@ class Folder {
}
/**
* @inheritdoc self::query($extensions = [])
* Get a new search query instance
* @param string[] $extensions
*
* @return WhereQuery
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function search($extensions = 'UTF-8'){
public function search(array $extensions = []): WhereQuery {
return $this->query($extensions);
}
/**
* @inheritdoc self::query($extensions = [])
* Get a new search query instance
* @param string[] $extensions
*
* @return WhereQuery
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function messages($extensions = []){
public function messages(array $extensions = []): WhereQuery {
return $this->query($extensions);
}
@@ -168,7 +178,7 @@ class Folder {
*
* @return bool
*/
public function hasChildren() {
public function hasChildren(): bool {
return $this->has_children;
}
@@ -178,7 +188,7 @@ class Folder {
*
* @return self
*/
public function setChildren($children = []) {
public function setChildren($children = []): Folder {
$this->children = $children;
return $this;
@@ -189,7 +199,7 @@ class Folder {
* It converts UTF7-IMAP encoding to UTF-8.
* @param $name
*
* @return mixed|string
* @return array|false|string|string[]|null
*/
protected function decodeName($name) {
return mb_convert_encoding($name, "UTF-8", "UTF7-IMAP");
@@ -213,11 +223,11 @@ class Folder {
* @param $attributes
*/
protected function parseAttributes($attributes) {
$this->no_inferiors = in_array('\NoInferiors', $attributes) ? true : false;
$this->no_select = in_array('\NoSelect', $attributes) ? true : false;
$this->marked = in_array('\Marked', $attributes) ? true : false;
$this->referral = in_array('\Referral', $attributes) ? true : false;
$this->has_children = in_array('\HasChildren', $attributes) ? true : false;
$this->no_inferiors = in_array('\NoInferiors', $attributes);
$this->no_select = in_array('\NoSelect', $attributes);
$this->marked = in_array('\Marked', $attributes);
$this->referral = in_array('\Referral', $attributes);
$this->has_children = in_array('\HasChildren', $attributes);
}
/**
@@ -231,7 +241,7 @@ class Folder {
* @throws Exceptions\FolderFetchingException
* @throws Exceptions\RuntimeException
*/
public function move($new_name, $expunge = true) {
public function move(string $new_name, bool $expunge = true): bool {
$this->client->checkConnection();
$status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
if($expunge) $this->client->expunge();
@@ -253,7 +263,7 @@ class Folder {
* @throws Exceptions\MessageNotFoundException
* @throws Exceptions\RuntimeException
*/
public function overview($sequence = null){
public function overview(string $sequence = null): array {
$this->client->openFolder($this->path);
$sequence = $sequence === null ? "1:*" : $sequence;
$uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID;
@@ -263,27 +273,25 @@ class Folder {
/**
* Append a string message to the current mailbox
* @param string $message
* @param string $options
* @param string $internal_date
* @param array|null $options
* @param string|null|Carbon $internal_date
*
* @return bool
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function appendMessage($message, $options = null, $internal_date = null) {
public function appendMessage(string $message, array $options = null, $internal_date = null): bool {
/**
* Check if $internal_date is parsed. If it is null it should not be set. Otherwise the message can't be stored.
* Check if $internal_date is parsed. If it is null it should not be set. Otherwise, the message can't be stored.
* If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a
* date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object.
*/
if ($internal_date != null) {
if ($internal_date instanceof Carbon){
$internal_date = $internal_date->format('d-M-Y H:i:s O');
}
if ($internal_date instanceof Carbon){
$internal_date = $internal_date->format('d-M-Y H:i:s O');
}
return $this->client->getConnection()->appendMessage($this->full_name, $message, $options, $internal_date);
return $this->client->getConnection()->appendMessage($this->path, $message, $options, $internal_date);
}
/**
@@ -297,7 +305,7 @@ class Folder {
* @throws Exceptions\FolderFetchingException
* @throws Exceptions\RuntimeException
*/
public function rename($new_name, $expunge = true) {
public function rename(string $new_name, bool $expunge = true): bool {
return $this->move($new_name, $expunge);
}
@@ -310,7 +318,7 @@ class Folder {
* @throws Exceptions\RuntimeException
* @throws Exceptions\EventNotFoundException
*/
public function delete($expunge = true) {
public function delete(bool $expunge = true): bool {
$status = $this->client->getConnection()->deleteFolder($this->path);
if($expunge) $this->client->expunge();
@@ -327,7 +335,7 @@ class Folder {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function subscribe() {
public function subscribe(): bool {
$this->client->openFolder($this->path);
return $this->client->getConnection()->subscribeFolder($this->path);
}
@@ -339,7 +347,7 @@ class Folder {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function unsubscribe() {
public function unsubscribe(): bool {
$this->client->openFolder($this->path);
return $this->client->getConnection()->unsubscribeFolder($this->path);
}
@@ -347,8 +355,8 @@ class Folder {
/**
* Idle the current connection
* @param callable $callback
* @param integer $timeout max 1740 seconds - recommended by rfc2177 §3
* @param boolean $auto_reconnect try to reconnect on connection close
* @param integer $timeout max 1740 seconds - recommended by rfc2177 §3. Should not be lower than the servers "* OK Still here" message interval
* @param boolean $auto_reconnect try to reconnect on connection close (@deprecated is no longer required)
*
* @throws ConnectionFailedException
* @throws Exceptions\InvalidMessageDateException
@@ -360,25 +368,25 @@ class Folder {
* @throws Exceptions\MessageNotFoundException
* @throws Exceptions\NotSupportedCapabilityException
*/
public function idle(callable $callback, $timeout = 1200, $auto_reconnect = false) {
$this->client->getConnection()->setConnectionTimeout($timeout);
$this->client->reconnect();
public function idle(callable $callback, int $timeout = 300, bool $auto_reconnect = false) {
$this->client->setTimeout($timeout);
if (!in_array("IDLE", $this->client->getConnection()->getCapabilities())) {
throw new NotSupportedCapabilityException("IMAP server does not support IDLE");
}
$this->client->openFolder($this->path, true);
$connection = $this->client->getConnection();
$connection->idle();
$sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
$connection->idle();
while (true) {
try {
// This polymorphic call is fine - Protocol::idle() will throw an exception beforehand
$line = $connection->nextLine();
if (($pos = strpos($line, "EXISTS")) !== false) {
$msgn = (int) substr($line, 2, $pos -2);
$connection->done();
$msgn = (int) substr($line, 2, $pos -2);
$this->client->openFolder($this->path, true);
$message = $this->query()->getMessageByMsgn($msgn);
@@ -387,20 +395,26 @@ class Folder {
$event = $this->getEvent("message", "new");
$event::dispatch($message);
$connection->idle();
} elseif (strpos($line, "OK") === false) {
$connection->done();
$connection->idle();
}
}catch (Exceptions\RuntimeException $e) {
if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) {
$connection->done();
$connection->idle();
continue;
}
if(strpos($e->getMessage(), "connection closed") === false) {
throw $e;
}
if ($auto_reconnect === true) {
$this->client->reconnect();
$this->client->openFolder($this->path, true);
$connection = $this->client->getConnection();
$connection->idle();
}
$this->client->reconnect();
$this->client->openFolder($this->path, true);
$connection = $this->client->getConnection();
$connection->idle();
}
}
}
@@ -408,14 +422,24 @@ class Folder {
/**
* Get folder status information
*
* @return array|bool
* @return array
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function getStatus() {
public function getStatus(): array {
return $this->examine();
}
/**
* @throws RuntimeException
* @throws ConnectionFailedException
*/
public function loadStatus(): Folder
{
$this->status = $this->getStatus();
return $this;
}
/**
* Examine the current folder
*
@@ -423,8 +447,9 @@ class Folder {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
public function examine() {
return $this->client->getConnection()->examineFolder($this->path);
public function examine(): array {
$result = $this->client->getConnection()->examineFolder($this->path);
return is_array($result) ? $result : [];
}
/**
@@ -432,7 +457,7 @@ class Folder {
*
* @return Client
*/
public function getClient() {
public function getClient(): Client {
return $this->client;
}

View File

@@ -66,7 +66,7 @@ class Header {
*
* @throws InvalidMessageDateException
*/
public function __construct($raw_header, $attributize = true) {
public function __construct(string $raw_header, bool $attributize = true) {
$this->raw = $raw_header;
$this->config = ClientManager::get('options');
$this->attributize = $attributize;
@@ -81,7 +81,7 @@ class Header {
* @return Attribute|mixed
* @throws MethodNotFoundException
*/
public function __call($method, $arguments) {
public function __call(string $method, array $arguments) {
if (strtolower(substr($method, 0, 3)) === 'get') {
$name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
@@ -126,13 +126,13 @@ class Header {
*
* @return Attribute
*/
public function set($name, $value, $strict = false) {
public function set(string $name, $value, bool $strict = false) {
if (isset($this->attributes[$name]) && $strict === false) {
if ($this->attributize) {
$this->attributes[$name]->add($value, true);
} else {
if (isset($this->attributes[$name])) {
if (is_array($this->attributes[$name]) == false) {
if (!is_array($this->attributes[$name])) {
$this->attributes[$name] = [$this->attributes[$name], $value];
} else {
$this->attributes[$name][] = $value;
@@ -141,7 +141,7 @@ class Header {
$this->attributes[$name] = $value;
}
}
} elseif ($this->attributize == false) {
} elseif (!$this->attributize) {
$this->attributes[$name] = $value;
} else {
$this->attributes[$name] = new Attribute($name, $value);
@@ -173,7 +173,7 @@ class Header {
* @return string|null
*/
public function getBoundary() {
$regex = isset($this->config["boundary"]) ? $this->config["boundary"] : "/boundary=(.*?(?=;)|(.*))/i";
$regex = $this->config["boundary"] ?? "/boundary=(.*?(?=;)|(.*))/i";
$boundary = $this->find($regex);
if ($boundary === null) {
@@ -189,7 +189,7 @@ class Header {
*
* @return string
*/
private function clearBoundaryString($str) {
private function clearBoundaryString(string $str): string {
return str_replace(['"', '\r', '\n', "\n", "\r", ";", "\s"], "", $str);
}
@@ -242,7 +242,7 @@ class Header {
$imap_headers[$key] = $values;
}
}
$lines = explode("\r\n", str_replace("\r\n\t", ' ', $raw_headers));
$lines = explode("\r\n", preg_replace("/\r\n\s/", ' ', $raw_headers));
$prev_header = null;
foreach ($lines as $line) {
if (substr($line, 0, 1) === "\n") {
@@ -334,9 +334,10 @@ class Header {
* @return array The decoded elements are returned in an array of objects, where each
* object has two properties, charset and text.
*/
public function mime_header_decode($text) {
public function mime_header_decode(string $text): array {
if (extension_loaded('imap')) {
return \imap_mime_header_decode($text);
$result = \imap_mime_header_decode($text);
return is_array($result) ? $result : [];
}
$charset = $this->getEncoding($text);
return [(object)[
@@ -346,13 +347,13 @@ class Header {
}
/**
* Check if a given pair of strings has ben decoded
* Check if a given pair of strings has been decoded
* @param $encoded
* @param $decoded
*
* @return bool
*/
private function notDecoded($encoded, $decoded) {
private function notDecoded($encoded, $decoded): bool {
return 0 === strpos($decoded, '=?')
&& strlen($decoded) - 2 === strpos($decoded, '?=')
&& false !== strpos($encoded, $decoded);
@@ -415,7 +416,7 @@ class Header {
*
* @return string
*/
public function getEncoding($structure) {
public function getEncoding($structure): string {
if (property_exists($structure, 'parameters')) {
foreach ($structure->parameters as $parameter) {
if (strtolower($parameter->attribute) == "charset") {
@@ -425,7 +426,8 @@ class Header {
} elseif (property_exists($structure, 'charset')) {
return EncodingAliases::get($structure->charset, $this->fallback_encoding);
} elseif (is_string($structure) === true) {
return mb_detect_encoding($structure);
$result = mb_detect_encoding($structure);
return $result === false ? $this->fallback_encoding : $result;
}
return $this->fallback_encoding;
@@ -437,7 +439,7 @@ class Header {
*
* @return bool
*/
private function is_uft8($value) {
private function is_uft8($value): bool {
return strpos(strtolower($value), '=?utf-8?') === 0;
}
@@ -495,7 +497,7 @@ class Header {
*
* @return array
*/
private function decodeArray($values) {
private function decodeArray(array $values): array {
foreach ($values as $key => $value) {
$values[$key] = $this->decode($value);
}
@@ -537,7 +539,7 @@ class Header {
*
* @return array
*/
private function decodeAddresses($values) {
private function decodeAddresses($values): array {
$addresses = [];
if (extension_loaded('mailparse') && $this->config["rfc822"]) {
@@ -547,7 +549,7 @@ class Header {
$mail_address = explode('@', $parsed_address['address']);
if (count($mail_address) == 2) {
$addresses[] = (object)[
"personal" => isset($parsed_address['display']) ? $parsed_address['display'] : '',
"personal" => $parsed_address['display'] ?? '',
"mailbox" => $mail_address[0],
"host" => $mail_address[1],
];
@@ -604,7 +606,7 @@ class Header {
*
* @return array
*/
private function parseAddresses($list) {
private function parseAddresses($list): array {
$addresses = [];
if (is_array($list) === false) {
@@ -657,7 +659,7 @@ class Header {
$value = (string)$value;
}
// Only parse strings and don't parse any attributes like the user-agent
if (in_array($key, ["user_agent"]) === false) {
if (($key == "user_agent") === false) {
if (($pos = strpos($value, ";")) !== false) {
$original = substr($value, 0, $pos);
$this->set($key, trim(rtrim($original)), true);
@@ -705,7 +707,6 @@ class Header {
private function parseDate($header) {
if (property_exists($header, 'date')) {
$parsed_date = null;
$date = $header->date;
if (preg_match('/\+0580/', $date)) {
@@ -714,9 +715,15 @@ class Header {
$date = trim(rtrim($date));
try {
if(strpos($date, '&nbsp;') !== false){
$date = str_replace('&nbsp;', ' ', $date);
}
$parsed_date = Carbon::parse($date);
} catch (\Exception $e) {
switch (true) {
case preg_match('/([0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}\-[0-9]{1,2}\.[0-9]{1,2}.[0-9]{1,2})+$/i', $date) > 0:
$date = Carbon::createFromFormat("Y.m.d-H.i.s", $date);
break;
case preg_match('/([0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
$date .= 'C';
@@ -751,7 +758,7 @@ class Header {
*
* @return array
*/
public function getAttributes() {
public function getAttributes(): array {
return $this->attributes;
}

View File

@@ -93,7 +93,7 @@ class Message {
/**
* Attribute holder
*
* @var Attribute[]|mixed[] $attributes
* @var Attribute[]|array $attributes
*/
protected $attributes = [];
@@ -177,7 +177,7 @@ class Message {
* @param integer|null $fetch_options
* @param boolean $fetch_body
* @param boolean $fetch_flags
* @param integer $sequence
* @param integer|null $sequence
*
* @throws Exceptions\ConnectionFailedException
* @throws InvalidMessageDateException
@@ -188,7 +188,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\MessageNotFoundException
*/
public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) {
public function __construct(int $uid, $msglist, Client $client, int $fetch_options = null, bool $fetch_body = false, bool $fetch_flags = false, int $sequence = null) {
$this->boot();
$default_mask = $client->getDefaultMessageMask();
@@ -246,7 +246,7 @@ class Message {
* @throws Exceptions\RuntimeException
* @throws Exceptions\MessageNotFoundException
*/
public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
public static function make(int $uid, $msglist, Client $client, string $raw_header, string $raw_body, array $raw_flags, $fetch_options = null, $sequence = null): Message {
$reflection = new ReflectionClass(self::class);
/** @var self $instance */
$instance = $reflection->newInstanceWithoutConstructor();
@@ -296,7 +296,7 @@ class Message {
* @return mixed
* @throws MethodNotFoundException
*/
public function __call($method, $arguments) {
public function __call(string $method, array $arguments) {
if(strtolower(substr($method, 0, 3)) === 'get') {
$name = Str::snake(substr($method, 3));
return $this->get($name);
@@ -354,7 +354,7 @@ class Message {
*
* @return bool
*/
public function hasTextBody() {
public function hasTextBody(): bool {
return isset($this->bodies['text']);
}
@@ -376,7 +376,7 @@ class Message {
*
* @return bool
*/
public function hasHTMLBody() {
public function hasHTMLBody(): bool {
return isset($this->bodies['html']);
}
@@ -416,7 +416,7 @@ class Message {
*
* @throws InvalidMessageDateException
*/
public function parseRawHeader($raw_header){
public function parseRawHeader(string $raw_header){
$this->header = new Header($raw_header);
}
@@ -424,7 +424,7 @@ class Message {
* Parse additional raw flags
* @param array $raw_flags
*/
public function parseRawFlags($raw_flags) {
public function parseRawFlags(array $raw_flags) {
$this->flags = FlagCollection::make([]);
foreach($raw_flags as $flag) {
@@ -473,7 +473,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\RuntimeException
*/
public function parseBody() {
public function parseBody(): Message {
$this->client->openFolder($this->folder_path);
$sequence_id = $this->getSequenceId();
@@ -521,7 +521,7 @@ class Message {
* @throws MessageContentFetchingException
* @throws Exceptions\RuntimeException
*/
public function parseRawBody($raw_body) {
public function parseRawBody(string $raw_body): Message {
$this->structure = new Structure($raw_body, $this->header);
$this->fetchStructure($this->structure);
@@ -535,7 +535,7 @@ class Message {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\RuntimeException
*/
private function fetchStructure($structure) {
private function fetchStructure(Structure $structure) {
$this->client->openFolder($this->folder_path);
foreach ($structure->parts as $part) {
@@ -585,7 +585,7 @@ class Message {
* Fetch the Message attachment
* @param Part $part
*/
protected function fetchAttachment($part) {
protected function fetchAttachment(Part $part) {
$oAttachment = new Attachment($this, $part);
if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
@@ -603,7 +603,7 @@ class Message {
*
* @return $this
*/
public function setFetchOption($option) {
public function setFetchOption($option): Message {
if (is_long($option) === true) {
$this->fetch_options = $option;
} elseif (is_null($option) === true) {
@@ -616,11 +616,11 @@ class Message {
/**
* Set the sequence type
* @param int $sequence
* @param int|null $sequence
*
* @return $this
*/
public function setSequence($sequence) {
public function setSequence($sequence): Message {
if (is_long($sequence)) {
$this->sequence = $sequence;
} elseif (is_null($sequence)) {
@@ -637,7 +637,7 @@ class Message {
*
* @return $this
*/
public function setFetchBodyOption($option) {
public function setFetchBodyOption($option): Message {
if (is_bool($option)) {
$this->fetch_body = $option;
} elseif (is_null($option)) {
@@ -654,7 +654,7 @@ class Message {
*
* @return $this
*/
public function setFetchFlagsOption($option) {
public function setFetchFlagsOption($option): Message {
if (is_bool($option)) {
$this->fetch_flags = $option;
} elseif (is_null($option)) {
@@ -672,7 +672,7 @@ class Message {
*
* @return string
*/
public function decodeString($string, $encoding) {
public function decodeString($string, $encoding): string {
switch ($encoding) {
case IMAP::MESSAGE_ENC_BINARY:
if (extension_loaded('imap')) {
@@ -699,7 +699,7 @@ class Message {
*
* @return mixed|string
*/
public function convertEncoding($str, $from = "ISO-8859-2", $to = "UTF-8") {
public function convertEncoding($str, string $from = "ISO-8859-2", string $to = "UTF-8") {
$from = EncodingAliases::get($from);
$to = EncodingAliases::get($to);
@@ -735,19 +735,19 @@ class Message {
/**
* Get the encoding of a given abject
* @param object|string $structure
* @param string|object $structure
*
* @return string
* @return string|null
*/
public function getEncoding($structure) {
public function getEncoding($structure): string {
if (property_exists($structure, 'parameters')) {
foreach ($structure->parameters as $parameter) {
if (strtolower($parameter->attribute) == "charset") {
return EncodingAliases::get($parameter->value);
return EncodingAliases::get($parameter->value, "ISO-8859-2");
}
}
}elseif (property_exists($structure, 'charset')){
return EncodingAliases::get($structure->charset);
return EncodingAliases::get($structure->charset, "ISO-8859-2");
}elseif (is_string($structure) === true){
return mb_detect_encoding($structure);
}
@@ -779,10 +779,10 @@ class Message {
* @throws Exceptions\GetMessagesFailedException
* @throws Exceptions\RuntimeException
*/
public function thread($sent_folder = null, &$thread = null, $folder = null){
$thread = $thread ? $thread : MessageCollection::make([]);
$folder = $folder ? $folder : $this->getFolder();
$sent_folder = $sent_folder ? $sent_folder : $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection {
$thread = $thread ?: MessageCollection::make([]);
$folder = $folder ?: $this->getFolder();
$sent_folder = $sent_folder ?: $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
/** @var Message $message */
foreach($thread as $message) {
@@ -816,8 +816,9 @@ class Message {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\GetMessagesFailedException
* @throws Exceptions\RuntimeException
* @throws Exceptions\FolderFetchingException
*/
protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){
$primary_folder->query()->inReplyTo($in_reply_to)
->setFetchBody($this->getFetchBodyOption())
->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -837,8 +838,9 @@ class Message {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\GetMessagesFailedException
* @throws Exceptions\RuntimeException
* @throws Exceptions\FolderFetchingException
*/
protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){
$primary_folder->query()->messageId($message_id)
->setFetchBody($this->getFetchBodyOption())
->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -863,7 +865,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\MessageNotFoundException
*/
public function copy($folder_path, $expunge = false) {
public function copy(string $folder_path, bool $expunge = false) {
$this->client->openFolder($folder_path);
$status = $this->client->getConnection()->examineFolder($folder_path);
@@ -898,7 +900,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\MessageNotFoundException
*/
public function move($folder_path, $expunge = false) {
public function move(string $folder_path, bool $expunge = false) {
$this->client->openFolder($folder_path);
$status = $this->client->getConnection()->examineFolder($folder_path);
@@ -924,7 +926,7 @@ class Message {
* @param string $event
* @param boolean $expunge
*
* @return mixed
* @return Message
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\EventNotFoundException
* @throws Exceptions\MessageNotFoundException
@@ -934,7 +936,7 @@ class Message {
* @throws MessageFlagException
* @throws MessageHeaderFetchingException
*/
protected function fetchNewMail($folder, $next_uid, $event, $expunge){
protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message {
if($expunge) $this->client->expunge();
$this->client->openFolder($folder->path);
@@ -961,10 +963,15 @@ class Message {
* @return bool
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\EventNotFoundException
* @throws MessageFlagException
* @throws Exceptions\FolderFetchingException
* @throws Exceptions\MessageNotFoundException
* @throws Exceptions\RuntimeException
* @throws InvalidMessageDateException
* @throws MessageContentFetchingException
* @throws MessageFlagException
* @throws MessageHeaderFetchingException
*/
public function delete($expunge = true, $trash_path = null, $force_move = false) {
public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false) {
$status = $this->setFlag("Deleted");
if($force_move) {
$trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path;
@@ -988,7 +995,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\RuntimeException
*/
public function restore($expunge = true) {
public function restore(bool $expunge = true): bool {
$status = $this->unsetFlag("Deleted");
if($expunge) $this->client->expunge();
@@ -1008,7 +1015,7 @@ class Message {
* @throws Exceptions\EventNotFoundException
* @throws Exceptions\RuntimeException
*/
public function setFlag($flag) {
public function setFlag($flag): bool {
$this->client->openFolder($this->folder_path);
$flag = "\\".trim(is_array($flag) ? implode(" \\", $flag) : $flag);
$sequence_id = $this->getSequenceId();
@@ -1022,7 +1029,7 @@ class Message {
$event = $this->getEvent("flag", "new");
$event::dispatch($this, $flag);
return $status;
return (bool)$status;
}
/**
@@ -1035,7 +1042,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\RuntimeException
*/
public function unsetFlag($flag) {
public function unsetFlag($flag): bool {
$this->client->openFolder($this->folder_path);
$flag = "\\".trim(is_array($flag) ? implode(" \\", $flag) : $flag);
@@ -1050,7 +1057,7 @@ class Message {
$event = $this->getEvent("flag", "deleted");
$event::dispatch($this, $flag);
return $status;
return (bool)$status;
}
/**
@@ -1063,7 +1070,7 @@ class Message {
* @throws Exceptions\EventNotFoundException
* @throws Exceptions\RuntimeException
*/
public function addFlag($flag) {
public function addFlag($flag): bool {
return $this->setFlag($flag);
}
@@ -1077,7 +1084,7 @@ class Message {
* @throws MessageFlagException
* @throws Exceptions\RuntimeException
*/
public function removeFlag($flag) {
public function removeFlag($flag): bool {
return $this->unsetFlag($flag);
}
@@ -1086,7 +1093,7 @@ class Message {
*
* @return AttachmentCollection
*/
public function getAttachments() {
public function getAttachments(): AttachmentCollection {
return $this->attachments;
}
@@ -1095,7 +1102,7 @@ class Message {
*
* @return AttachmentCollection
*/
public function attachments(){
public function attachments(): AttachmentCollection {
return $this->getAttachments();
}
@@ -1104,7 +1111,7 @@ class Message {
*
* @return boolean
*/
public function hasAttachments() {
public function hasAttachments(): bool {
return $this->attachments->isEmpty() === false;
}
@@ -1139,7 +1146,7 @@ class Message {
*
* @return Client
*/
public function getClient() {
public function getClient(): Client {
return $this->client;
}
@@ -1175,7 +1182,7 @@ class Message {
*
* @return array
*/
public function getBodies() {
public function getBodies(): array {
return $this->bodies;
}
@@ -1184,7 +1191,7 @@ class Message {
*
* @return FlagCollection
*/
public function getFlags() {
public function getFlags(): FlagCollection {
return $this->flags;
}
@@ -1193,7 +1200,7 @@ class Message {
*
* @return FlagCollection
*/
public function flags(){
public function flags(): FlagCollection {
return $this->getFlags();
}
@@ -1212,7 +1219,7 @@ class Message {
* @param null|Message $message
* @return boolean
*/
public function is(Message $message = null) {
public function is(Message $message = null): bool {
if (is_null($message)) {
return false;
}
@@ -1228,7 +1235,7 @@ class Message {
*
* @return array
*/
public function getAttributes(){
public function getAttributes(): array {
return array_merge($this->attributes, $this->header->getAttributes());
}
@@ -1238,7 +1245,7 @@ class Message {
*
* @return $this
*/
public function setMask($mask){
public function setMask($mask): Message {
if(class_exists($mask)){
$this->mask = $mask;
}
@@ -1251,13 +1258,13 @@ class Message {
*
* @return string
*/
public function getMask(){
public function getMask(): string {
return $this->mask;
}
/**
* Get a masked instance by providing a mask name
* @param string|null $mask
* @param string|mixed $mask
*
* @return mixed
* @throws MaskNotFoundException
@@ -1276,7 +1283,7 @@ class Message {
*
* @return string
*/
public function getFolderPath(){
public function getFolderPath(): string {
return $this->folder_path;
}
@@ -1286,7 +1293,7 @@ class Message {
*
* @return $this
*/
public function setFolderPath($folder_path){
public function setFolderPath($folder_path): Message {
$this->folder_path = $folder_path;
return $this;
@@ -1298,7 +1305,7 @@ class Message {
*
* @return $this
*/
public function setConfig($config){
public function setConfig($config): Message {
$this->config = $config;
return $this;
@@ -1310,7 +1317,7 @@ class Message {
*
* @return $this
*/
public function setAvailableFlags($available_flags){
public function setAvailableFlags($available_flags): Message {
$this->available_flags = $available_flags;
return $this;
@@ -1322,7 +1329,7 @@ class Message {
*
* @return $this
*/
public function setAttachments($attachments){
public function setAttachments($attachments): Message {
$this->attachments = $attachments;
return $this;
@@ -1334,7 +1341,7 @@ class Message {
*
* @return $this
*/
public function setFlags($flags){
public function setFlags($flags): Message {
$this->flags = $flags;
return $this;
@@ -1348,7 +1355,7 @@ class Message {
* @throws Exceptions\RuntimeException
* @throws Exceptions\ConnectionFailedException
*/
public function setClient($client){
public function setClient($client): Message {
$this->client = $client;
$this->client->openFolder($this->folder_path);
@@ -1363,7 +1370,7 @@ class Message {
* @throws Exceptions\MessageNotFoundException
* @throws Exceptions\ConnectionFailedException
*/
public function setUid($uid){
public function setUid(int $uid): Message {
$this->uid = $uid;
$this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
$this->msglist = null;
@@ -1373,14 +1380,14 @@ class Message {
/**
* Set the message number
* @param $msgn
* @param int $msgn
* @param int|null $msglist
*
* @return $this
* @throws Exceptions\MessageNotFoundException
* @throws Exceptions\ConnectionFailedException
*/
public function setMsgn($msgn, $msglist = null){
public function setMsgn(int $msgn, int $msglist = null): Message {
$this->msgn = $msgn;
$this->msglist = $msglist;
$this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1393,7 +1400,7 @@ class Message {
*
* @return int
*/
public function getSequence(){
public function getSequence(): int {
return $this->sequence;
}
@@ -1402,7 +1409,7 @@ class Message {
*
* @return int
*/
public function getSequenceId(){
public function getSequenceId(): int {
return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
}
@@ -1414,7 +1421,7 @@ class Message {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\MessageNotFoundException
*/
public function setSequenceId($uid, $msglist = null){
public function setSequenceId($uid, int $msglist = null){
if ($this->getSequence() === IMAP::ST_UID) {
$this->setUid($uid);
$this->setMsglist($msglist);

View File

@@ -142,12 +142,12 @@ class Part {
/**
* Part constructor.
* @param $raw_part
* @param Header $header
* @param Header|null $header
* @param integer $part_number
*
* @throws InvalidMessageDateException
*/
public function __construct($raw_part, $header = null, $part_number = 0) {
public function __construct($raw_part, Header $header = null, int $part_number = 0) {
$this->raw = $raw_part;
$this->header = $header;
$this->part_number = $part_number;
@@ -202,12 +202,12 @@ class Part {
}
/**
* Find all available headers and return the left over body segment
* Find all available headers and return the leftover body segment
*
* @return string
* @throws InvalidMessageDateException
*/
private function findHeaders(){
private function findHeaders(): string {
$body = $this->raw;
while (($pos = strpos($body, "\r\n")) > 0) {
$body = substr($body, $pos + 2);
@@ -217,7 +217,7 @@ class Part {
$this->header = new Header($headers);
return (string) $body;
return $body;
}
/**
@@ -298,7 +298,7 @@ class Part {
*
* @return bool
*/
public function isAttachment(){
public function isAttachment(): bool {
$valid_disposition = in_array(strtolower($this->disposition ?? ''), ClientManager::get('options.dispositions'));
if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || empty($this->disposition) || !$valid_disposition)) {

View File

@@ -87,7 +87,7 @@ class Query {
* @param Client $client
* @param string[] $extensions
*/
public function __construct(Client $client, $extensions = []) {
public function __construct(Client $client, array $extensions = []) {
$this->setClient($client);
$this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
@@ -119,11 +119,9 @@ class Query {
*
* @return string
*/
protected function parse_value($value) {
switch (true) {
case $value instanceof Carbon:
$value = $value->format($this->date_format);
break;
protected function parse_value($value): string {
if ($value instanceof Carbon) {
$value = $value->format($this->date_format);
}
return (string)$value;
@@ -136,7 +134,7 @@ class Query {
* @return Carbon
* @throws MessageSearchValidationException
*/
protected function parse_date($date) {
protected function parse_date($date): Carbon {
if ($date instanceof Carbon) return $date;
try {
@@ -153,7 +151,7 @@ class Query {
*
* @return string
*/
public function generate_query() {
public function generate_query(): string {
$query = '';
$this->query->each(function($statement) use (&$query) {
if (count($statement) == 1) {
@@ -184,12 +182,12 @@ class Query {
* @return Collection
* @throws GetMessagesFailedException
*/
protected function search() {
protected function search(): Collection {
$this->generate_query();
try {
$available_messages = $this->client->getConnection()->search([$this->getRawQuery()], $this->sequence);
return $available_messages !== false ? new Collection($available_messages) : new Collection();
return new Collection($available_messages);
} catch (RuntimeException $e) {
throw new GetMessagesFailedException("failed to fetch messages", 0, $e);
} catch (ConnectionFailedException $e) {
@@ -203,7 +201,7 @@ class Query {
* @return int
* @throws GetMessagesFailedException
*/
public function count() {
public function count(): int {
return $this->search()->count();
}
@@ -215,15 +213,15 @@ class Query {
* @throws ConnectionFailedException
* @throws RuntimeException
*/
protected function fetch($available_messages) {
protected function fetch(Collection $available_messages): array {
if ($this->fetch_order === 'desc') {
$available_messages = $available_messages->reverse();
}
$uids = $available_messages->forPage($this->page, $this->limit)->toArray();
$extensions = [];
if (empty($this->getExtensions()) === false) {
$extensions = $this->client->getConnection()->fetch($this->getExtensions(), $uids, null, $this->sequence);
$extensions = $this->getExtensions();
if (empty($extensions) === false && method_exists($this->client->getConnection(), "fetch")) {
$extensions = $this->client->getConnection()->fetch($extensions, $uids, null, $this->sequence);
}
$flags = $this->client->getConnection()->flags($uids, $this->sequence);
$headers = $this->client->getConnection()->headers($uids, "RFC822", $this->sequence);
@@ -256,7 +254,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws ReflectionException
*/
protected function make($uid, $msglist, $header, $content, $flags) {
protected function make(int $uid, int $msglist, string $header, string $content, array $flags) {
try {
return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence);
} catch (MessageNotFoundException $e) {
@@ -284,7 +282,7 @@ class Query {
*
* @return string
*/
protected function getMessageKey($message_key, $msglist, $message) {
protected function getMessageKey(string $message_key, int $msglist, Message $message): string {
switch ($message_key) {
case 'number':
$key = $message->getMessageNo();
@@ -303,13 +301,13 @@ class Query {
}
/**
* Currates a given collection aof messages
* Curates a given collection aof messages
* @param Collection $available_messages
*
* @return MessageCollection
* @throws GetMessagesFailedException
*/
public function curate_messages($available_messages) {
public function curate_messages(Collection $available_messages): MessageCollection {
try {
if ($available_messages->count() > 0) {
return $this->populate($available_messages);
@@ -331,7 +329,7 @@ class Query {
* @throws ReflectionException
* @throws RuntimeException
*/
protected function populate($available_messages) {
protected function populate(Collection $available_messages): MessageCollection {
$messages = MessageCollection::make([]);
$messages->total($available_messages->count());
@@ -342,9 +340,9 @@ class Query {
$msglist = 0;
foreach ($raw_messages["headers"] as $uid => $header) {
$content = isset($raw_messages["contents"][$uid]) ? $raw_messages["contents"][$uid] : "";
$flag = isset($raw_messages["flags"][$uid]) ? $raw_messages["flags"][$uid] : [];
$extensions = isset($raw_messages["extensions"][$uid]) ? $raw_messages["extensions"][$uid] : [];
$content = $raw_messages["contents"][$uid] ?? "";
$flag = $raw_messages["flags"][$uid] ?? [];
$extensions = $raw_messages["extensions"][$uid] ?? [];
$message = $this->make($uid, $msglist, $header, $content, $flag);
foreach($extensions as $key => $extension) {
@@ -366,7 +364,7 @@ class Query {
* @return MessageCollection
* @throws GetMessagesFailedException
*/
public function get() {
public function get(): MessageCollection {
return $this->curate_messages($this->search());
}
@@ -382,7 +380,7 @@ class Query {
* @throws ReflectionException
* @throws RuntimeException
*/
public function chunked($callback, $chunk_size = 10, $start_chunk = 1) {
public function chunked(callable $callback, int $chunk_size = 10, int $start_chunk = 1) {
$available_messages = $this->search();
if (($available_messages_count = $available_messages->count()) > 0) {
$old_limit = $this->limit;
@@ -411,7 +409,7 @@ class Query {
* @return LengthAwarePaginator
* @throws GetMessagesFailedException
*/
public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
public function paginate(int $per_page = 5, $page = null, string $page_name = 'imap_page'): LengthAwarePaginator {
if (
$page === null
&& isset($_GET[$page_name])
@@ -443,7 +441,7 @@ class Query {
* @throws MessageFlagException
* @throws MessageNotFoundException
*/
public function getMessage($uid, $msglist = null, $sequence = null) {
public function getMessage(int $uid, $msglist = null, $sequence = null): Message {
return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence);
}
@@ -462,7 +460,7 @@ class Query {
* @throws MessageFlagException
* @throws MessageNotFoundException
*/
public function getMessageByMsgn($msgn, $msglist = null) {
public function getMessageByMsgn($msgn, $msglist = null): Message {
return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN);
}
@@ -480,7 +478,7 @@ class Query {
* @throws MessageFlagException
* @throws MessageNotFoundException
*/
public function getMessageByUid($uid) {
public function getMessageByUid($uid): Message {
return $this->getMessage($uid, null, IMAP::ST_UID);
}
@@ -493,7 +491,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function filter($closure) {
public function filter(callable $closure): MessageCollection {
$connection = $this->getClient()->getConnection();
$uids = $connection->getUid();
@@ -518,7 +516,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function getByUidGreaterOrEqual($uid) {
public function getByUidGreaterOrEqual(int $uid): MessageCollection {
return $this->filter(function($id) use($uid){
return $id >= $uid;
});
@@ -533,7 +531,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function getByUidGreater($uid) {
public function getByUidGreater(int $uid): MessageCollection {
return $this->filter(function($id) use($uid){
return $id > $uid;
});
@@ -548,7 +546,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function getByUidLower($uid) {
public function getByUidLower(int $uid): MessageCollection {
return $this->filter(function($id) use($uid){
return $id < $uid;
});
@@ -563,7 +561,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function getByUidLowerOrEqual($uid) {
public function getByUidLowerOrEqual(int $uid): MessageCollection {
return $this->filter(function($id) use($uid){
return $id <= $uid;
});
@@ -578,7 +576,7 @@ class Query {
* @throws GetMessagesFailedException
* @throws MessageNotFoundException
*/
public function getByUidLowerThan($uid) {
public function getByUidLowerThan(int $uid): MessageCollection {
return $this->filter(function($id) use($uid){
return $id < $uid;
});
@@ -589,7 +587,7 @@ class Query {
*
* @return $this
*/
public function leaveUnread() {
public function leaveUnread(): Query {
$this->setFetchOptions(IMAP::FT_PEEK);
return $this;
@@ -600,7 +598,7 @@ class Query {
*
* @return $this
*/
public function markAsRead() {
public function markAsRead(): Query {
$this->setFetchOptions(IMAP::FT_UID);
return $this;
@@ -612,7 +610,7 @@ class Query {
*
* @return $this
*/
public function setSequence($sequence) {
public function setSequence(int $sequence): Query {
$this->sequence = $sequence;
return $this;
@@ -631,7 +629,7 @@ class Query {
* @return Client
* @throws ConnectionFailedException
*/
public function getClient() {
public function getClient(): Client {
$this->client->checkConnection();
return $this->client;
}
@@ -643,7 +641,7 @@ class Query {
*
* @return $this
*/
public function limit($limit, $page = 1) {
public function limit(int $limit, int $page = 1): Query {
if ($page >= 1) $this->page = $page;
$this->limit = $limit;
@@ -653,7 +651,7 @@ class Query {
/**
* @return Collection
*/
public function getQuery() {
public function getQuery(): Collection {
return $this->query;
}
@@ -661,7 +659,7 @@ class Query {
* @param array $query
* @return Query
*/
public function setQuery($query) {
public function setQuery(array $query): Query {
$this->query = new Collection($query);
return $this;
}
@@ -669,7 +667,7 @@ class Query {
/**
* @return string
*/
public function getRawQuery() {
public function getRawQuery(): string {
return $this->raw_query;
}
@@ -677,7 +675,7 @@ class Query {
* @param string $raw_query
* @return Query
*/
public function setRawQuery($raw_query) {
public function setRawQuery(string $raw_query): Query {
$this->raw_query = $raw_query;
return $this;
}
@@ -685,7 +683,7 @@ class Query {
/**
* @return string[]
*/
public function getExtensions() {
public function getExtensions(): array {
return $this->extensions;
}
@@ -693,7 +691,7 @@ class Query {
* @param string[] $extensions
* @return Query
*/
public function setExtensions($extensions) {
public function setExtensions(array $extensions): Query {
$this->extensions = $extensions;
if (count($this->extensions) > 0) {
if (in_array("UID", $this->extensions) === false) {
@@ -707,12 +705,13 @@ class Query {
* @param Client $client
* @return Query
*/
public function setClient(Client $client) {
public function setClient(Client $client): Query {
$this->client = $client;
return $this;
}
/**
* Get the set fetch limit
* @return int
*/
public function getLimit() {
@@ -723,7 +722,7 @@ class Query {
* @param int $limit
* @return Query
*/
public function setLimit($limit) {
public function setLimit(int $limit): Query {
$this->limit = $limit <= 0 ? null : $limit;
return $this;
}
@@ -731,7 +730,7 @@ class Query {
/**
* @return int
*/
public function getPage() {
public function getPage(): int {
return $this->page;
}
@@ -739,25 +738,25 @@ class Query {
* @param int $page
* @return Query
*/
public function setPage($page) {
public function setPage(int $page): Query {
$this->page = $page;
return $this;
}
/**
* @param boolean $fetch_options
* @param int $fetch_options
* @return Query
*/
public function setFetchOptions($fetch_options) {
public function setFetchOptions(int $fetch_options): Query {
$this->fetch_options = $fetch_options;
return $this;
}
/**
* @param boolean $fetch_options
* @param int $fetch_options
* @return Query
*/
public function fetchOptions($fetch_options) {
public function fetchOptions(int $fetch_options): Query {
return $this->setFetchOptions($fetch_options);
}
@@ -779,7 +778,7 @@ class Query {
* @param boolean $fetch_body
* @return Query
*/
public function setFetchBody($fetch_body) {
public function setFetchBody(bool $fetch_body): Query {
$this->fetch_body = $fetch_body;
return $this;
}
@@ -788,7 +787,7 @@ class Query {
* @param boolean $fetch_body
* @return Query
*/
public function fetchBody($fetch_body) {
public function fetchBody(bool $fetch_body): Query {
return $this->setFetchBody($fetch_body);
}
@@ -803,7 +802,7 @@ class Query {
* @param int $fetch_flags
* @return Query
*/
public function setFetchFlags($fetch_flags) {
public function setFetchFlags(int $fetch_flags): Query {
$this->fetch_flags = $fetch_flags;
return $this;
}
@@ -812,7 +811,7 @@ class Query {
* @param string $fetch_order
* @return Query
*/
public function setFetchOrder($fetch_order) {
public function setFetchOrder(string $fetch_order): Query {
$fetch_order = strtolower($fetch_order);
if (in_array($fetch_order, ['asc', 'desc'])) {
@@ -826,42 +825,42 @@ class Query {
* @param string $fetch_order
* @return Query
*/
public function fetchOrder($fetch_order) {
public function fetchOrder(string $fetch_order): Query {
return $this->setFetchOrder($fetch_order);
}
/**
* @return string
*/
public function getFetchOrder() {
public function getFetchOrder(): string {
return $this->fetch_order;
}
/**
* @return Query
*/
public function setFetchOrderAsc() {
public function setFetchOrderAsc(): Query {
return $this->setFetchOrder('asc');
}
/**
* @return Query
*/
public function fetchOrderAsc() {
public function fetchOrderAsc(): Query {
return $this->setFetchOrderAsc();
}
/**
* @return Query
*/
public function setFetchOrderDesc() {
public function setFetchOrderDesc(): Query {
return $this->setFetchOrder('desc');
}
/**
* @return Query
*/
public function fetchOrderDesc() {
public function fetchOrderDesc(): Query {
return $this->setFetchOrderDesc();
}
@@ -870,7 +869,7 @@ class Query {
* @var boolean $state
*
*/
public function softFail($state = true) {
public function softFail(bool $state = true): Query {
return $this->setSoftFail($state);
}
@@ -879,7 +878,7 @@ class Query {
* @var boolean $state
*
*/
public function setSoftFail($state = true) {
public function setSoftFail(bool $state = true): Query {
$this->soft_fail = $state;
return $this;
@@ -888,7 +887,7 @@ class Query {
/**
* @return boolean
*/
public function getSoftFail() {
public function getSoftFail(): bool {
return $this->soft_fail;
}
@@ -898,7 +897,7 @@ class Query {
*
* @throws GetMessagesFailedException
*/
protected function handleException($uid) {
protected function handleException(int $uid) {
if ($this->soft_fail === false && $this->hasError($uid)) {
$error = $this->getError($uid);
throw new GetMessagesFailedException($error->getMessage(), 0, $error);
@@ -910,7 +909,7 @@ class Query {
* @param integer $uid
* @param Exception $error
*/
protected function setError($uid, $error) {
protected function setError(int $uid, Exception $error) {
$this->errors[$uid] = $error;
}
@@ -920,7 +919,7 @@ class Query {
* @var integer|null $uid
*
*/
public function hasErrors($uid = null) {
public function hasErrors($uid = null): bool {
if ($uid !== null) {
return $this->hasError($uid);
}
@@ -933,7 +932,7 @@ class Query {
* @var integer $uid
*
*/
public function hasError($uid) {
public function hasError(int $uid): bool {
return isset($this->errors[$uid]);
}
@@ -942,7 +941,7 @@ class Query {
*
* @return array
*/
public function errors() {
public function errors(): array {
return $this->getErrors();
}
@@ -951,7 +950,7 @@ class Query {
*
* @return array
*/
public function getErrors() {
public function getErrors(): array {
return $this->errors;
}
@@ -961,7 +960,7 @@ class Query {
* @var integer $uid
*
*/
public function error($uid) {
public function error(int $uid) {
return $this->getError($uid);
}
@@ -971,7 +970,7 @@ class Query {
* @var integer $uid
*
*/
public function getError($uid) {
public function getError(int $uid) {
if ($this->hasError($uid)) {
return $this->errors[$uid];
}

View File

@@ -74,7 +74,7 @@ class WhereQuery extends Query {
* @throws InvalidWhereQueryCriteriaException
* @throws MethodNotFoundException
*/
public function __call($name, $arguments) {
public function __call(string $name, $arguments) {
$that = $this;
$name = Str::camel($name);
@@ -104,7 +104,7 @@ class WhereQuery extends Query {
* @return string
* @throws InvalidWhereQueryCriteriaException
*/
protected function validate_criteria($criteria) {
protected function validate_criteria($criteria): string {
$command = strtoupper($criteria);
if (substr($command, 0, 7) === "CUSTOM ") {
return substr($criteria, 7);
@@ -132,7 +132,7 @@ class WhereQuery extends Query {
* $query->where(["FROM" => "someone@email.tld", "SEEN"]);
* $query->where("FROM", "someone@email.tld")->where("SEEN");
*/
public function where($criteria, $value = null) {
public function where($criteria, $value = null): WhereQuery {
if (is_array($criteria)) {
foreach ($criteria as $key => $value) {
if (is_numeric($key)) {
@@ -155,7 +155,7 @@ class WhereQuery extends Query {
*
* @throws InvalidWhereQueryCriteriaException
*/
protected function push_search_criteria($criteria, $value){
protected function push_search_criteria(string $criteria, $value){
$criteria = $this->validate_criteria($criteria);
$value = $this->parse_value($value);
@@ -171,7 +171,7 @@ class WhereQuery extends Query {
*
* @return $this
*/
public function orWhere(Closure $closure = null) {
public function orWhere(Closure $closure = null): WhereQuery {
$this->query->push(['OR']);
if ($closure !== null) $closure($this);
@@ -183,7 +183,7 @@ class WhereQuery extends Query {
*
* @return $this
*/
public function andWhere(Closure $closure = null) {
public function andWhere(Closure $closure = null): WhereQuery {
$this->query->push(['AND']);
if ($closure !== null) $closure($this);
@@ -194,7 +194,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereAll() {
public function whereAll(): WhereQuery {
return $this->where('ALL');
}
@@ -202,7 +202,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereAnswered() {
public function whereAnswered(): WhereQuery {
return $this->where('ANSWERED');
}
@@ -212,7 +212,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereBcc($value) {
public function whereBcc(string $value): WhereQuery {
return $this->where('BCC', $value);
}
@@ -222,7 +222,7 @@ class WhereQuery extends Query {
* @throws InvalidWhereQueryCriteriaException
* @throws MessageSearchValidationException
*/
public function whereBefore($value) {
public function whereBefore($value): WhereQuery {
$date = $this->parse_date($value);
return $this->where('BEFORE', $date);
}
@@ -233,7 +233,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereBody($value) {
public function whereBody(string $value): WhereQuery {
return $this->where('BODY', $value);
}
@@ -243,7 +243,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereCc($value) {
public function whereCc(string $value): WhereQuery {
return $this->where('CC', $value);
}
@@ -251,7 +251,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereDeleted() {
public function whereDeleted(): WhereQuery {
return $this->where('DELETED');
}
@@ -261,7 +261,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereFlagged($value) {
public function whereFlagged(string $value): WhereQuery {
return $this->where('FLAGGED', $value);
}
@@ -271,7 +271,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereFrom($value) {
public function whereFrom(string $value): WhereQuery {
return $this->where('FROM', $value);
}
@@ -281,7 +281,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereKeyword($value) {
public function whereKeyword(string $value): WhereQuery {
return $this->where('KEYWORD', $value);
}
@@ -289,7 +289,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereNew() {
public function whereNew(): WhereQuery {
return $this->where('NEW');
}
@@ -297,7 +297,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereNot() {
public function whereNot(): WhereQuery {
return $this->where('NOT');
}
@@ -305,7 +305,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereOld() {
public function whereOld(): WhereQuery {
return $this->where('OLD');
}
@@ -316,7 +316,7 @@ class WhereQuery extends Query {
* @throws MessageSearchValidationException
* @throws InvalidWhereQueryCriteriaException
*/
public function whereOn($value) {
public function whereOn($value): WhereQuery {
$date = $this->parse_date($value);
return $this->where('ON', $date);
}
@@ -325,7 +325,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereRecent() {
public function whereRecent(): WhereQuery {
return $this->where('RECENT');
}
@@ -333,7 +333,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereSeen() {
public function whereSeen(): WhereQuery {
return $this->where('SEEN');
}
@@ -344,7 +344,7 @@ class WhereQuery extends Query {
* @throws MessageSearchValidationException
* @throws InvalidWhereQueryCriteriaException
*/
public function whereSince($value) {
public function whereSince($value): WhereQuery {
$date = $this->parse_date($value);
return $this->where('SINCE', $date);
}
@@ -355,7 +355,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereSubject($value) {
public function whereSubject(string $value): WhereQuery {
return $this->where('SUBJECT', $value);
}
@@ -365,7 +365,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereText($value) {
public function whereText(string $value): WhereQuery {
return $this->where('TEXT', $value);
}
@@ -375,7 +375,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereTo($value) {
public function whereTo(string $value): WhereQuery {
return $this->where('TO', $value);
}
@@ -385,7 +385,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUnkeyword($value) {
public function whereUnkeyword(string $value): WhereQuery {
return $this->where('UNKEYWORD', $value);
}
@@ -393,7 +393,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUnanswered() {
public function whereUnanswered(): WhereQuery {
return $this->where('UNANSWERED');
}
@@ -401,7 +401,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUndeleted() {
public function whereUndeleted(): WhereQuery {
return $this->where('UNDELETED');
}
@@ -409,7 +409,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUnflagged() {
public function whereUnflagged(): WhereQuery {
return $this->where('UNFLAGGED');
}
@@ -417,7 +417,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUnseen() {
public function whereUnseen(): WhereQuery {
return $this->where('UNSEEN');
}
@@ -425,7 +425,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereNoXSpam() {
public function whereNoXSpam(): WhereQuery {
return $this->where("CUSTOM X-Spam-Flag NO");
}
@@ -433,7 +433,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereIsXSpam() {
public function whereIsXSpam(): WhereQuery {
return $this->where("CUSTOM X-Spam-Flag YES");
}
@@ -445,7 +445,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereHeader($header, $value) {
public function whereHeader($header, $value): WhereQuery {
return $this->where("CUSTOM HEADER $header $value");
}
@@ -456,7 +456,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereMessageId($messageId) {
public function whereMessageId($messageId): WhereQuery {
return $this->whereHeader("Message-ID", $messageId);
}
@@ -467,7 +467,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereInReplyTo($messageId) {
public function whereInReplyTo($messageId): WhereQuery {
return $this->whereHeader("In-Reply-To", $messageId);
}
@@ -477,7 +477,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereLanguage($country_code) {
public function whereLanguage($country_code): WhereQuery {
return $this->where("Content-Language $country_code");
}
@@ -489,7 +489,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUid($uid) {
public function whereUid($uid): WhereQuery {
return $this->where('UID', $uid);
}
@@ -501,7 +501,7 @@ class WhereQuery extends Query {
* @return WhereQuery
* @throws InvalidWhereQueryCriteriaException
*/
public function whereUidIn($uids) {
public function whereUidIn(array $uids): WhereQuery {
$uids = implode(',', $uids);
return $this->where('UID', $uids);
}
@@ -515,7 +515,7 @@ class WhereQuery extends Query {
* @param callable|null $default
* @return $this|mixed
*/
public function when($value, $callback, $default = null) {
public function when($value, callable $callback, $default = null) {
if ($value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {
@@ -534,7 +534,7 @@ class WhereQuery extends Query {
* @param callable|null $default
* @return $this|mixed
*/
public function unless($value, $callback, $default = null) {
public function unless($value, callable $callback, $default = null) {
if (!$value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {

View File

@@ -88,7 +88,7 @@ class Structure {
public function findContentType(){
$content_type = $this->header->get("content_type");
$content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
if(stripos($content_type, 'multipart') === 0) {
if($content_type && stripos($content_type, 'multipart') === 0) {
$this->type = IMAP::MESSAGE_TYPE_MULTIPART;
}else{
$this->type = IMAP::MESSAGE_TYPE_TEXT;
@@ -103,7 +103,7 @@ class Structure {
* @return Part[]
* @throws InvalidMessageDateException
*/
private function parsePart($context, $part_number = 0){
private function parsePart(string $context, int $part_number = 0): array {
$body = $context;
while (($pos = strpos($body, "\r\n")) > 0) {
$body = substr($body, $pos + 2);
@@ -126,7 +126,7 @@ class Structure {
* @return array
* @throws InvalidMessageDateException
*/
private function detectParts($boundary, $context, $part_number = 0){
private function detectParts(string $boundary, string $context, int $part_number = 0): array {
$base_parts = explode( $boundary, $context);
$final_parts = [];
foreach($base_parts as $ctx) {
@@ -150,7 +150,7 @@ class Structure {
* @throws MessageContentFetchingException
* @throws InvalidMessageDateException
*/
public function find_parts(){
public function find_parts(): array {
if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
if (($boundary = $this->header->getBoundary()) === null) {
throw new MessageContentFetchingException("no content found", 0);

View File

@@ -34,7 +34,7 @@ class AttachmentMask extends Mask {
}
/**
* Get an base64 image src string
* Get a base64 image src string
*
* @return string|null
*/

View File

@@ -63,7 +63,7 @@ class Mask {
* @return mixed
* @throws MethodNotFoundException
*/
public function __call($method, $arguments) {
public function __call(string $method, array $arguments) {
if(strtolower(substr($method, 0, 3)) === 'get') {
$name = Str::snake(substr($method, 3));
@@ -119,7 +119,7 @@ class Mask {
/**
* Get the parent instance
*
* @return mixed
* @return object
*/
public function getParent(){
return $this->parent;
@@ -130,7 +130,7 @@ class Mask {
*
* @return array
*/
public function getAttributes(){
public function getAttributes(): array {
return $this->attributes;
}

View File

@@ -32,19 +32,19 @@ class PaginatedCollection extends Collection {
/**
* Paginate the current collection.
* @param int $per_page
* @param int $per_page
* @param int|null $page
* @param string $page_name
* @param boolean $prepaginated
* @param string $page_name
* @param boolean $prepaginated
*
* @return LengthAwarePaginator
*/
public function paginate($per_page = 15, $page = null, $page_name = 'page', $prepaginated = false) {
public function paginate(int $per_page = 15, $page = null, string $page_name = 'page', bool $prepaginated = false): LengthAwarePaginator {
$page = $page ?: Paginator::resolveCurrentPage($page_name);
$total = $this->total ? $this->total : $this->count();
$total = $this->total ?: $this->count();
$results = !$prepaginated && $total ? $this->forPage($page, $per_page) : $this->all();
$results = !$prepaginated && $total ? $this->forPage($page, $per_page)->toArray() : $this->all();
return $this->paginator($results, $total, $per_page, $page, [
'path' => Paginator::resolveCurrentPath(),
@@ -54,15 +54,15 @@ class PaginatedCollection extends Collection {
/**
* Create a new length-aware paginator instance.
* @param array $items
* @param int $total
* @param int $per_page
* @param array $items
* @param int $total
* @param int $per_page
* @param int|null $current_page
* @param array $options
*
* @return LengthAwarePaginator
*/
protected function paginator($items, $total, $per_page, $current_page, array $options) {
protected function paginator(array $items, int $total, int $per_page, $current_page, array $options): LengthAwarePaginator {
return new LengthAwarePaginator($items, $total, $per_page, $current_page, $options);
}

View File

@@ -55,7 +55,7 @@ trait HasEvents {
* @param $section
* @param $event
*
* @return Event
* @return Event|string
* @throws EventNotFoundException
*/
public function getEvent($section, $event) {
@@ -70,7 +70,7 @@ trait HasEvents {
*
* @return array
*/
public function getEvents(){
public function getEvents(): array {
return $this->events;
}