diff --git a/composer.json b/composer.json
index 016d33e..e987dd9 100644
--- a/composer.json
+++ b/composer.json
@@ -26,27 +26,35 @@
}
],
"require": {
- "php": ">=5.6",
+ "php": ">=8.0",
"ext-curl": "*",
"ext-gd": "*",
"yiisoft/yii2": "~2.0",
- "yiisoft/yii2-bootstrap": "~2.0",
- "yiisoft/yii2-jui": "~2.0",
+ "yiisoft/yii2-jui": "^2.0.0",
"studio-42/elfinder": "~2.1",
"rmrevin/yii2-fontawesome": "~3.0",
"simialbi/yii2-simialbi-base": ">=0.10.2 <1.0 | ^1.0.0"
},
"require-dev": {
"yiisoft/yii2-coding-standards": "~2.0",
- "phpunit/phpunit": "^7.5.20"
+ "phpunit/phpunit": "^10.5.0",
+ "yiisoft/yii2-bootstrap": "^2.0.0",
+ "google/apiclient": "^2.17.0"
},
"suggest": {
"ext-fileinfo": "To use mime content type detection in behaviors",
"ext-exif": "To use image rotate behavior",
- "simialbi/yii2-widget-crop": "Add an image cropper widget to ElFinderInput"
+ "google/apiclient": "To use with VolumeDriver GoogleDrive",
+ "simialbi/yii2-widget-crop": "Add an image cropper widget to ElFinderInput",
+ "yiisoft/yii2-bootstrap": "To use with bootstrap 3",
+ "yiisoft/yii2-bootstrap4": "To use with bootstrap 4",
+ "yiisoft/yii2-bootstrap5": "To use with bootstrap 5"
},
"config": {
- "process-timeout": 1800
+ "process-timeout": 1800,
+ "allow-plugins": {
+ "yiisoft/yii2-composer": true
+ }
},
"autoload": {
"psr-4": {
diff --git a/src/ElFinder.php b/src/ElFinder.php
index cee8567..7c17b96 100644
--- a/src/ElFinder.php
+++ b/src/ElFinder.php
@@ -372,25 +372,25 @@ class ElFinder extends Component
const FTP_MODE_PASSIVE = 'passive';
/**
- * @var ElFinderOptions the main options of elfinder
+ * @var array|ElFinderOptions the main options of elfinder
*/
- public $options = [];
+ public array|ElFinderOptions $options = [];
/**
* @var ElFinderConfiguration[] Array of arrays with per root settings. This is the only required option.
*/
- public $roots = [];
+ public array $roots = [];
/**
* @var \elFinder api instance
*/
- protected $_elfinder;
+ protected \elFinder $_elfinder;
/**
* @inheritdoc
* @throws InvalidConfigException
*/
- public function init()
+ public function init(): void
{
if (empty($this->roots)) {
throw new InvalidConfigException('roots parameter must be set');
@@ -404,7 +404,7 @@ public function init()
*
* @return \elFinder
*/
- public function getApi()
+ public function getApi(): \elFinder
{
if (empty($this->_elfinder) || !$this->_elfinder instanceof \elFinder) {
$this->setApi();
@@ -416,7 +416,7 @@ public function getApi()
/**
* Sets the elFinder API instance
*/
- public function setApi()
+ public function setApi(): void
{
foreach ($this->roots as &$root) {
$root->path = Yii::getAlias($root->path);
@@ -481,7 +481,7 @@ public function setApi()
* @return boolean
* @throws InvalidConfigException
*/
- public function handleApiBeforeEvent($cmd, &$args, $instance, $dstVolume)
+ public function handleApiBeforeEvent(string $cmd, array &$args, \elFinder $instance, \elFinderVolumeDriver $dstVolume): bool
{
$event = Yii::createObject([
'class' => 'simialbi\yii2\elfinder\base\ElFinderEvent',
@@ -509,7 +509,7 @@ public function handleApiBeforeEvent($cmd, &$args, $instance, $dstVolume)
* @return boolean
* @throws InvalidConfigException
*/
- public function handleApiAfterEvent($cmd, &$result, $args, $instance, $dstVolume)
+ public function handleApiAfterEvent(string $cmd, array &$result, array $args, \elFinder $instance, \elFinderVolumeDriver $dstVolume): bool
{
$event = Yii::createObject([
'class' => 'simialbi\yii2\elfinder\base\ElFinderEvent',
@@ -531,14 +531,14 @@ public function handleApiAfterEvent($cmd, &$result, $args, $instance, $dstVolume
*
* @param string $path relative path from the upload target
* @param string $name file name
- * @param string $tmpname file tmp name
+ * @param string $tmpName file tmp name
* @param \elFinder $instance elFinder instance
* @param \elFinderVolumeDriver $dstVolume Volume Driver instance
*
* @return boolean
* @throws InvalidConfigException
*/
- public function handleApiUploadBeforeSave(&$path, &$name, $tmpname, $instance, $dstVolume)
+ public function handleApiUploadBeforeSave(string &$path, string &$name, string $tmpName, \elFinder $instance, \elFinderVolumeDriver $dstVolume): bool
{
$event = Yii::createObject([
'class' => 'simialbi\yii2\elfinder\base\ElFinderEvent',
@@ -546,7 +546,7 @@ public function handleApiUploadBeforeSave(&$path, &$name, $tmpname, $instance, $
'sender' => $instance,
'path' => $path,
'fileName' => $name,
- 'fileTmpName' => $tmpname,
+ 'fileTmpName' => $tmpName,
'volume' => $dstVolume
]);
/* @var $event \simialbi\yii2\elfinder\base\ElFinderEvent */
diff --git a/src/ElFinderConfiguration.php b/src/ElFinderConfiguration.php
index 94893ab..83255f6 100644
--- a/src/ElFinderConfiguration.php
+++ b/src/ElFinderConfiguration.php
@@ -19,27 +19,27 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
/**
* @var string Volume driver. Set storage engine for current root, can be one of LocalFileSystem, MySQL, FTP
*/
- public $driver = ElFinder::DRIVER_LOCAL_FILE_SYSTEM;
+ public string $driver = ElFinder::DRIVER_LOCAL_FILE_SYSTEM;
/**
* @var boolean It must set true If volume driver supports autoload function.
*/
- public $autoload = true;
+ public bool $autoload = true;
/**
* @var string Folder hash value on elFinder to be the parent of this volume
*/
- public $phash = '';
+ public string $phash = '';
/**
* @var string Folder hash value on elFinder to trash bin of this volume, it require 'copyJoin' to true
*/
- public $trashHash = '';
+ public string $trashHash = '';
/**
* @var string Root directory path
*/
- public $path = '/';
+ public string $path = '/';
/**
* @var string Open this path on initial request instead of root path
@@ -47,7 +47,7 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
* Notice: In order to validate this option by a multi-route, you have to set a value only to the volume which
* applies this option.
*/
- public $startPath = '';
+ public string $startPath = '';
/**
* @var string URL that points to path directory (also called 'root URL'). If not set client will not see full path
@@ -55,46 +55,46 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
*
* Disable real file path from being shown
*/
- public $URL = '';
+ public string $URL = '';
/**
* @var string This volume's local encoding. (server's file system encoding) It's necessary to be valid value to
* iconv.
*/
- public $encoding = '';
+ public string $encoding = '';
/**
* @var string This volume's local locale. It's important for encoding setting. It's necessary to be valid value in
* your server. (It can be checked by showlocale.php or typing locale -a on your server shell.)
*/
- public $locale = '';
+ public string $locale = '';
/**
* @var string Root path alias for volume root. If not set will use directory name of path.
* Warning: when this option is set it will also rewrite return path for getFileCallback
*/
- public $alias = '';
+ public string $alias = '';
/**
* @var boolean Enable i18n folder name that convert name to elFinderInstance.messages['folder_'+name]
*/
- public $i18nFolderName = false;
+ public bool $i18nFolderName = false;
/**
* @var string Method to detect files mimetypes. Can be auto, internal, finfo, mime_content_type
*/
- public $mimeDetect = ElFinder::MIME_DETECT_AUTO;
+ public string $mimeDetect = ElFinder::MIME_DETECT_AUTO;
/**
* @var string Path to alternative mime types file. Only used when mimeDetect set to internal. If not set will use
* default mime.types
*/
- public $mimefile = '';
+ public string $mimefile = '';
/**
* @var array Additional Mime type normalization map
*/
- public $additionalMimeMap = [];
+ public array $additionalMimeMap = [];
/**
* @var string MIME regex of send HTTP header "Content-Disposition: inline" on file open command.
@@ -103,12 +103,12 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
* '$^' is not allow inline of all of MIME types
* '^(?:image|text/plain$)' is recommended for safety on public elFinder
*/
- public $dispInlineRegex = '^(?:(?:image|text)|application/x-shockwave-flash$)';
+ public string $dispInlineRegex = '^(?:(?:image|text)|application/x-shockwave-flash$)';
/**
* @var string Image manipulations library. Can be auto, imagick, gd or convert
*/
- public $imgLib = ElFinder::IMG_LIB_AUTO;
+ public string $imgLib = ElFinder::IMG_LIB_AUTO;
/**
* @var string Directory for thumbnails. If this is a simple filename, it will be prefixed with the root directory
@@ -116,12 +116,12 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
* path using ellipses will get mangled and may not work (create thumbnails because tmbPath is NOT writable)
* on some server OS's.
*/
- public $tmbPath = '.tmb';
+ public string $tmbPath = '.tmb';
/**
* @var integer Umask for thumbnails dir creation. Will be removed in future
*/
- public $tmbPathMode = 0777;
+ public int $tmbPathMode = 0777;
/**
* @var string URL for thumbnails directory set in tmbPath. Set it only if you want to store thumbnails outside root
@@ -129,104 +129,104 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
*
* If you want chose original image as thumbnail it is able to set 'self'.
*/
- public $tmbURL = '';
+ public string $tmbURL = '';
/**
* @var integer Thumbnails size in pixels. Thumbnails are square
*/
- public $tmbSize = 48;
+ public int $tmbSize = 48;
/**
* @var boolean Crop thumbnails to fit tmbSize. true - resize and crop, false - scale image to fit thumbnail size
*/
- public $tmbCrop = true;
+ public bool $tmbCrop = true;
/**
* @var string Thumbnails background color (hex #rrggbb or transparent)
*/
- public $tmbBgColor = 'transparent';
+ public string $tmbBgColor = 'transparent';
/**
* @var string Image rotate fallback background color (hex #rrggbb). Uses this color if it can not specify to
* transparent.
*/
- public $bgColorFb = '#ffffff';
+ public string $bgColorFb = '#ffffff';
/**
* @var boolean Fallback self image to thumbnail (nothing imgLib).
*/
- public $tmbFbSelf = true;
+ public bool $tmbFbSelf = true;
/**
* @var boolean Replace files on paste or give new names to pasted files. true - old file will be replaced with new
* one, false - new file get name - original_name-number.ext
*/
- public $copyOverwrite = true;
+ public bool $copyOverwrite = true;
/**
* @var boolean Merge new and old content on paste. true - join new and old directories content, false - replace old
* directories with new ones
*/
- public $copyJoin = true;
+ public bool $copyJoin = true;
/**
* @var boolean Allow to copy from this volume to other ones
*/
- public $copyFrom = true;
+ public bool $copyFrom = true;
/**
* @var boolean Allow to copy from other volumes to this one
*/
- public $copyTo = true;
+ public bool $copyTo = true;
/**
* @var string Temporary directory used for extracts etc. The default tmpPath is to use 'tmbPath'. If you choose to
* use another location, set 'tmpPath' to a full pathname.
*/
- public $tmpPath = '';
+ public string $tmpPath = '';
/**
* @var boolean Replace files with the same name on upload or give them new names. true - replace old files, false
* give new names like original_name-number.ext
*/
- public $uploadOverwrite = true;
+ public bool $uploadOverwrite = true;
/**
* @var array Mimetypes allowed to upload
*/
- public $uploadAllow = [];
+ public array $uploadAllow = [];
/**
* @var array Mimetypes not allowed to upload. Same values accepted as in uploadAllow
*/
- public $uploadDeny = [];
+ public array $uploadDeny = [];
/**
* @var array Order to proccess uploadAllow and uploadDeny options. Logic is the same as Apache web server options
* Allow, Deny, Order
*/
- public $uploadOrder = ['deny', 'allow'];
+ public array $uploadOrder = ['deny', 'allow'];
/**
* @var integer|string Maximum upload file size. This size is per files. Can be set as number or string with unit
* 10M, 500K, 1G. Note: elFinder 2.1+ support chunked file uploading. 0 means unlimited upload.
*/
- public $uploadMaxSize = 0;
+ public string|int $uploadMaxSize = 0;
/**
* @var integer Maximum number of connection of chunked file uploading. -1 to disable chunked file upload.
*/
- public $uploadMaxConn = 3;
+ public int $uploadMaxConn = 3;
/**
* @var array Default file/directory permissions. Setting hidden, locked here - take no effect
*/
- public $defaults = ['read' => true, 'write' => true];
+ public array $defaults = ['read' => true, 'write' => true];
/**
* @var array File permission attributes.
*/
- public $attributes = [];
+ public array $attributes = [];
/**
* @var string|callable Validate new file name regex or function
@@ -242,72 +242,72 @@ class ElFinderConfiguration extends BaseObject implements Arrayable
/**
* @var mixed Data that will be passed to access control method
*/
- public $accessControlData = null;
+ public mixed $accessControlData = null;
/**
* @var array List of commands disabled on this root
*/
- public $disabled = [];
+ public array $disabled = [];
/**
* @var boolean Include file owner, group & mode in stat results on supported volume driver
* (LocalFileSystem(require POSIX in PHP), FTP on UNIX system-like). false to inactivate "chmod" command.
*/
- public $statOwner = false;
+ public bool $statOwner = false;
/**
* @var boolean Allow exec chmod of read-only( on elFinder permission ) files.
*/
- public $allowChmodReadOnly = false;
+ public bool $allowChmodReadOnly = false;
/**
* @var integer How many subdirs levels return per request
*/
- public $treeDeep = 1;
+ public int $treeDeep = 1;
/**
* @var boolean|integer Check children directories for other directories in it. true every folder will be check for
* children folders, -1 every folder will be check asynchronously, false all folders will be marked as having
* subfolders
*/
- public $checkSubfolders = true;
+ public int|bool $checkSubfolders = true;
/**
* @var string Directory separator. Required by client to show correct file paths
*/
- public $separator = DIRECTORY_SEPARATOR;
+ public string $separator = DIRECTORY_SEPARATOR;
/**
* @var string File modification date format. This value is passed to PHP date() function
*/
- public $dateFormat = 'j M Y H:i';
+ public string $dateFormat = 'j M Y H:i';
/**
* @var string File modification time format
*/
- public $timeFormat = 'H:i';
+ public string $timeFormat = 'H:i';
// public $cryptLib = null;
/**
* @var array Allowed archive's mimetypes to create. Leave empty for all available types
*/
- public $archiveMimes = [];
+ public array $archiveMimes = [];
/**
* @var array Manual config for archivers. Leave empty for auto detect
*/
- public $archivers = [];
+ public array $archivers = [];
/**
* @var string Temporary directory for archive file extracting. This option only uses the LocalFileSystem volume driver.
*
* We recommend to set a path outside the document root.
*/
- public $quarantine = '.quarantine';
+ public string $quarantine = '.quarantine';
/**
* @var array Configure plugin options of each volume
*/
- public $plugin = [];
+ public array $plugin = [];
}
diff --git a/src/ElFinderConfigurationFTP.php b/src/ElFinderConfigurationFTP.php
index 240e324..f65a968 100644
--- a/src/ElFinderConfigurationFTP.php
+++ b/src/ElFinderConfigurationFTP.php
@@ -8,56 +8,55 @@
namespace simialbi\yii2\elfinder;
-
class ElFinderConfigurationFTP extends ElFinderConfiguration
{
/**
* @var string Volume driver. Set storage engine for current root, can be one of LocalFileSystem, MySQL, FTP
*/
- public $driver = ElFinder::DRIVER_FTP;
+ public string $driver = ElFinder::DRIVER_FTP;
/**
* @var string MySQL host name
*/
- public $host = 'localhost';
+ public string $host = 'localhost';
/**
* @var integer FTP connection port (TCP)
*/
- public $port = 21;
+ public int $port = 21;
/**
* @var string FTP user name
*/
- public $user = '';
+ public string $user = '';
/**
* @var string FTP password
*/
- public $pass = '';
+ public string $pass = '';
/**
* @var string Connection mode (passive or active)
*/
- public $mode = ElFinder::FTP_MODE_PASSIVE;
+ public string $mode = ElFinder::FTP_MODE_PASSIVE;
/**
* @var integer Connection timeout
*/
- public $timeout = 20;
+ public int $timeout = 20;
/**
* @var boolean Returnvalue if file/directory owner is not equal connections user name
*/
- public $owner = true;
+ public bool $owner = true;
/**
* @var integer New dirs mode
*/
- public $dirMode = 0755;
+ public int $dirMode = 0755;
/**
* @var integer New files mode
*/
- public $fileMode = 0644;
+ public int $fileMode = 0644;
}
diff --git a/src/ElFinderConfigurationGoogleDrive.php b/src/ElFinderConfigurationGoogleDrive.php
new file mode 100644
index 0000000..7120cd4
--- /dev/null
+++ b/src/ElFinderConfigurationGoogleDrive.php
@@ -0,0 +1,83 @@
+ 'anyone',
+ 'role' => 'reader',
+ 'withLink' => true
+ ];
+
+ /**
+ * @var array|string[] Google docs mime type mapping
+ */
+ public array $appsExportMap = [
+ 'application/vnd.google-apps.document' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'application/vnd.google-apps.spreadsheet' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'application/vnd.google-apps.drawing' => 'application/pdf',
+ 'application/vnd.google-apps.presentation' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'application/vnd.google-apps.script' => 'application/vnd.google-apps.script+json',
+ 'default' => 'application/pdf'
+ ];
+}
diff --git a/src/ElFinderConfigurationLocalFileSystem.php b/src/ElFinderConfigurationLocalFileSystem.php
index 7fb5a58..69326f4 100644
--- a/src/ElFinderConfigurationLocalFileSystem.php
+++ b/src/ElFinderConfigurationLocalFileSystem.php
@@ -8,31 +8,30 @@
namespace simialbi\yii2\elfinder;
-
class ElFinderConfigurationLocalFileSystem extends ElFinderConfiguration
{
/**
* @var integer New dirs mode
*/
- public $dirMode = 0755;
+ public int $dirMode = 0755;
/**
* @var integer New files mode
*/
- public $fileMode = 0644;
+ public int $fileMode = 0644;
/**
* @var boolean Follow symbolic links
*/
- public $followSymLinks = true;
+ public bool $followSymLinks = true;
/**
* @var string File to be detected as a folder icon image e.g. '.favicon.png'
*/
- public $detectDirIcon = '';
+ public string $detectDirIcon = '';
/**
* @var array Keep timestamp at inner filesystem. Allowed values are 'copy', 'move' and 'upload'
*/
- public $keepTimestamp = [];
+ public array $keepTimestamp = [];
}
diff --git a/src/ElFinderConfigurationMySQL.php b/src/ElFinderConfigurationMySQL.php
index d46c95c..266a608 100644
--- a/src/ElFinderConfigurationMySQL.php
+++ b/src/ElFinderConfigurationMySQL.php
@@ -8,46 +8,45 @@
namespace simialbi\yii2\elfinder;
-
class ElFinderConfigurationMySQL extends ElFinderConfiguration
{
/**
* @var string Volume driver. Set storage engine for current root, can be one of LocalFileSystem, MySQL, FTP
*/
- public $driver = ElFinder::DRIVER_MYSQL;
+ public string $driver = ElFinder::DRIVER_MYSQL;
/**
* @var string MySQL host name
*/
- public $host = 'localhost';
+ public string $host = 'localhost';
/**
* @var string|null Path to MySQL sock file
*/
- public $socket = null;
+ public ?string $socket = null;
/**
* @var integer|null MySQL connection port (TCP)
*/
- public $port = null;
+ public ?int $port = null;
/**
* @var string MySQL user name
*/
- public $user = '';
+ public string $user = '';
/**
* @var string MySQL password
*/
- public $pass = '';
+ public string $pass = '';
/**
* @var string MySQL database name
*/
- public $db = '';
+ public string $db = '';
/**
* @var string MySQL files table name
*/
- public $files_table = 'elfinder_file';
+ public string $files_table = 'elfinder_file';
}
diff --git a/src/ElFinderOptions.php b/src/ElFinderOptions.php
index 9d7f24f..d1b45c1 100644
--- a/src/ElFinderOptions.php
+++ b/src/ElFinderOptions.php
@@ -6,7 +6,6 @@
namespace simialbi\yii2\elfinder;
-
use yii\base\Arrayable;
use yii\base\ArrayableTrait;
use yii\base\BaseObject;
@@ -18,51 +17,51 @@ class ElFinderOptions extends BaseObject implements Arrayable
/**
* @var string Set locale. Currently only UTF-8 locales are supported. Passed to `setLocale` PHP function.
*/
- public $locale = 'en_US.UTF-8';
+ public string $locale = 'en_US.UTF-8';
/**
* @var string elFinderVolumeDriver mime.type file path as defaults. This can be overridden in each of the volume
* by setting the volume root mimefile. The default value '' meaning uses a file 'php/mime.type'.
*/
- public $defaultMimefile = '';
+ public string $defaultMimefile = '';
/**
* @var \elFinderSessionInterface Session handling wrapper class object. It must implement elFinderSessionInterface.
*/
- public $session;
+ public \elFinderSessionInterface $session;
/**
* @var string Set sessionCacheKey. PHP $_SESSION array key of elFinder caches.
*/
- public $sessionCacheKey = 'elFinderCaches';
+ public string $sessionCacheKey = 'elFinderCaches';
/**
* @var boolean elFinder save session data as `UTF-8`. If the session storage
* mechanism of the system does not allow `UTF-8`, and it must be set `true`.
*/
- public $base64encodeSessionData = false;
+ public bool $base64encodeSessionData = false;
/**
* @var string Temp directory path for Upload. Default uses `sys_get_temp_dir()`
*/
- public $uploadTempPath = '';
+ public string $uploadTempPath = '';
/**
* @var string Temp directory path for temporally working files. Default uses `./.tmp` if it writable.
*/
- public $commonTempPath = './.tmp';
+ public string $commonTempPath = './.tmp';
/**
* @var string Connection flag files path that connection check of current request. A file is created every
* time an access is made to this location and it is deleted at the end of the request.
* It is recommended to specify RAM disk such as "/dev/shm".
*/
- public $connectionFlagsPath = '';
+ public string $connectionFlagsPath = '';
/**
* @var integer Max allowed archive files size (0 - no limit)
*/
- public $maxArcFilesSize = 0;
+ public int $maxArcFilesSize = 0;
/**
* @var array Root options of the network mounting volume
@@ -76,27 +75,27 @@ class ElFinderOptions extends BaseObject implements Arrayable
* ]
* ```
*/
- public $optionsNetVolumes = [];
+ public array $optionsNetVolumes = [];
/**
* @var integer Max number of limits of selectable items (0 - no limit)
*/
- public $maxTargets = 1000;
+ public int $maxTargets = 1000;
/**
* @var boolean Throw Error on exec()
* `true` need `try{}` block for `$connector->run();`
*/
- public $throwErrorOnExec = false;
+ public bool $throwErrorOnExec = false;
/**
* @var boolean Send debug to client.
*/
- public $debug = false;
+ public bool $debug = false;
/**
* @var array Configure plugin options of All volumes default value. When this config is omitted, the default
* value which plugin has is applied.
*/
- public $plugin = [];
+ public array $plugin = [];
}
diff --git a/src/ElFinderPluginAsset.php b/src/ElFinderPluginAsset.php
index f59cdaa..1e5ba9a 100644
--- a/src/ElFinderPluginAsset.php
+++ b/src/ElFinderPluginAsset.php
@@ -47,7 +47,7 @@ class ElFinderPluginAsset extends AssetBundle
/**
* @inheritdoc
*/
- public function init()
+ public function init(): void
{
if (YII_DEBUG) {
$this->js = [
diff --git a/src/Module.php b/src/Module.php
index 47c382b..c1f32e8 100644
--- a/src/Module.php
+++ b/src/Module.php
@@ -44,7 +44,7 @@ class Module extends \simialbi\yii2\base\Module
* @var array|string the url to to the elfinder proxy. Will be set automatically if not set
* (works only if root module).
*/
- public $proxyUrl = [];
+ public string|array $proxyUrl = [];
/**
* @var array the main options of elfinder per instance.
@@ -64,7 +64,7 @@ class Module extends \simialbi\yii2\base\Module
* @see https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#main-options
* ```
*/
- public $options = [];
+ public array $options = [];
/**
* @var array the connection sets named by array key and $roots configuration as value.
@@ -90,7 +90,7 @@ class Module extends \simialbi\yii2\base\Module
* ]
* ```
*/
- public $connectionSets = [];
+ public array $connectionSets = [];
/**
* @var array the connection sets named by array key and $behaviors value.
@@ -118,14 +118,14 @@ class Module extends \simialbi\yii2\base\Module
* ]
* ```
*/
- public $volumeBehaviors = [];
+ public array $volumeBehaviors = [];
/**
* {@inheritdoc}
* @throws \yii\base\InvalidConfigException
* @throws \ReflectionException
*/
- public function init()
+ public function init(): void
{
$components = [];
if (empty($this->proxyUrl)) {
diff --git a/src/base/ElFinderEvent.php b/src/base/ElFinderEvent.php
index 4d7717d..3901e4e 100644
--- a/src/base/ElFinderEvent.php
+++ b/src/base/ElFinderEvent.php
@@ -14,27 +14,27 @@
class ElFinderEvent extends Event
{
/**
- * @var array arugments array
+ * @var array arguments array
*/
- public $arguments;
+ public array $arguments;
/**
* @var array result array
*/
- public $result;
+ public array $result;
/**
* @var string relative path from the upload target
*/
- public $path;
+ public string $path;
/**
* @var string file name
*/
- public $fileName;
+ public string $fileName;
/**
* @var string file tmp name
*/
- public $fileTmpName;
+ public string $fileTmpName;
/**
* @var \elFinderVolumeDriver $volume Volume Driver Instance
*/
- public $volume;
+ public \elFinderVolumeDriver $volume;
}
diff --git a/src/behaviors/ImageOptimizeBehavior.php b/src/behaviors/ImageOptimizeBehavior.php
index 31ec96a..dcdd8e5 100644
--- a/src/behaviors/ImageOptimizeBehavior.php
+++ b/src/behaviors/ImageOptimizeBehavior.php
@@ -47,17 +47,17 @@ class ImageOptimizeBehavior extends Behavior
/**
* @var string
*/
- public $jpegOptimizer = 'jpegtran -copy none -optimize -progressive -outfile {to} {from}';
+ public string $jpegOptimizer = 'jpegtran -copy none -optimize -progressive -outfile {to} {from}';
/**
* @var string
*/
- public $pngOptimizer = 'optipng -o2 -strip all -out {to} {from}';
+ public string $pngOptimizer = 'optipng -o2 -strip all -out {to} {from}';
/**
* @inheritdoc
*/
- public function events()
+ public function events(): array
{
return [
ElFinder::EVENT_UPLOAD_BEFORE_SAVE => 'afterUploadBeforeSave'
@@ -67,7 +67,7 @@ public function events()
/**
* @param ElFinderEvent $event
*/
- public function afterUploadBeforeSave($event)
+ public function afterUploadBeforeSave(ElFinderEvent $event): void
{
// $elfinder = $event->sender;
$src = $event->fileTmpName;
@@ -81,7 +81,7 @@ public function afterUploadBeforeSave($event)
if (function_exists('mime_content_type')) {
$mime = mime_content_type($src);
- if (substr($mime, 0, 5) !== 'image') {
+ if (!str_starts_with($mime, 'image')) {
return;
}
}
diff --git a/src/behaviors/ImageResizeBehavior.php b/src/behaviors/ImageResizeBehavior.php
index ff68629..440ba1f 100644
--- a/src/behaviors/ImageResizeBehavior.php
+++ b/src/behaviors/ImageResizeBehavior.php
@@ -53,42 +53,42 @@ class ImageResizeBehavior extends Behavior
/**
* @var integer Maximal width of image
*/
- public $maxWidth = 1024;
+ public int $maxWidth = 1024;
/**
* @var integer Maximal height of image
*/
- public $maxHeight = 1024;
+ public int $maxHeight = 1024;
/**
* @var integer Reduce quality
*/
- public $quality = 95;
+ public int $quality = 95;
/**
* @var boolean Preserve EXIF data (Imagick only)
*/
- public $preserveExif = false;
+ public bool $preserveExif = false;
/**
* @var boolean Force quality changing even if image is inside max bounds
*/
- public $forceEffect = false;
+ public bool $forceEffect = false;
/**
* @var integer Target image formats
*/
- public $targetType = 0;
+ public int $targetType = 0;
/**
* @var integer|null To disable it if it is dropped with pressing the meta key
* Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* In case of using any key, specify it as an array
*/
- public $offDropWith = null;
+ public ?int $offDropWith = null;
/**
* @inheritdoc
*/
- public function init()
+ public function init(): void
{
$this->targetType = IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP;
parent::init();
@@ -97,7 +97,7 @@ public function init()
/**
* @inheritdoc
*/
- public function events()
+ public function events(): array
{
return [
ElFinder::EVENT_UPLOAD_BEFORE_SAVE => 'afterUploadBeforeSave'
@@ -106,8 +106,9 @@ public function events()
/**
* @param ElFinderEvent $event
+ * @throws \ImagickException|\elFinderAbortException
*/
- public function afterUploadBeforeSave($event)
+ public function afterUploadBeforeSave(ElFinderEvent $event): void
{
// $elfinder = $event->sender;
$src = $event->fileTmpName;
@@ -117,7 +118,7 @@ public function afterUploadBeforeSave($event)
if (function_exists('mime_content_type')) {
$mime = mime_content_type($src);
- if (substr($mime, 0, 5) !== 'image') {
+ if (!str_starts_with($mime, 'image')) {
return;
}
}
diff --git a/src/behaviors/ImageRotateBehavior.php b/src/behaviors/ImageRotateBehavior.php
index 599096e..ea56063 100644
--- a/src/behaviors/ImageRotateBehavior.php
+++ b/src/behaviors/ImageRotateBehavior.php
@@ -48,20 +48,20 @@ class ImageRotateBehavior extends Behavior
/**
* @var integer Reduce quality
*/
- public $quality = 95;
+ public int $quality = 95;
/**
* @var integer|null To disable it if it is dropped with pressing the meta key
* Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* In case of using any key, specify it as an array
*/
- public $offDropWidth = null;
+ public ?int $offDropWidth = null;
/**
* @inheritdoc
*/
- public function events()
+ public function events(): array
{
return [
ElFinder::EVENT_UPLOAD_BEFORE_SAVE => 'afterUploadBeforeSave'
@@ -70,8 +70,9 @@ public function events()
/**
* @param ElFinderEvent $event
+ * @throws \ImagickException|\elFinderAbortException
*/
- public function afterUploadBeforeSave($event)
+ public function afterUploadBeforeSave(ElFinderEvent $event): void
{
// $elfinder = $event->sender;
$src = $event->fileTmpName;
@@ -81,7 +82,7 @@ public function afterUploadBeforeSave($event)
if (function_exists('mime_content_type')) {
$mime = mime_content_type($src);
- if (substr($mime, 0, 5) !== 'image') {
+ if (!str_starts_with($mime, 'image')) {
return;
}
}
diff --git a/src/controllers/ConnectionController.php b/src/controllers/ConnectionController.php
index 9c9aadd..da0ab96 100644
--- a/src/controllers/ConnectionController.php
+++ b/src/controllers/ConnectionController.php
@@ -28,11 +28,11 @@ class ConnectionController extends Controller
*
* @throws NotFoundHttpException
*/
- public function actionIndex($instanceName = 'default')
+ public function actionIndex(string $instanceName = 'default'): void
{
$elFinder = ArrayHelper::getValue($this->module->components, $instanceName);
- if (is_null($elFinder) || !$elFinder instanceof ElFinder) {
+ if (!($elFinder instanceof ElFinder)) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
}
diff --git a/src/controllers/ProxyController.php b/src/controllers/ProxyController.php
index 416c6ac..5fa18c8 100644
--- a/src/controllers/ProxyController.php
+++ b/src/controllers/ProxyController.php
@@ -6,6 +6,7 @@
namespace simialbi\yii2\elfinder\controllers;
+use phpDocumentor\Reflection\Types\Resource_;
use Yii;
use yii\helpers\StringHelper;
use yii\web\Controller;
@@ -29,7 +30,7 @@ class ProxyController extends Controller
* @return mixed
* @throws NotFoundHttpException
*/
- public function actionIndex($baseUrl, $path)
+ public function actionIndex(string $baseUrl, string $path): mixed
{
$curl = curl_init();
$url = str_replace(' ', '%20', sprintf(
@@ -74,7 +75,7 @@ public function actionIndex($baseUrl, $path)
* @param string $response
* @return array
*/
- protected function parseCurlResponse($curl, $response)
+ protected function parseCurlResponse($curl, string $response): array
{
$headers = [];
$headerText = substr($response, 0, strpos($response, "\r\n\r\n"));
diff --git a/src/widgets/ElFinder.php b/src/widgets/ElFinder.php
index 2c3e11d..5470333 100644
--- a/src/widgets/ElFinder.php
+++ b/src/widgets/ElFinder.php
@@ -39,55 +39,55 @@ class ElFinder extends Widget
const REQUEST_GET = 'get';
const REQUEST_POST = 'post';
/**
- * @var string/array Connector URL. This is the only required option. Can be absolute or relative
+ * @var string|array Connector URL. This is the only required option. Can be absolute or relative
*/
- public $url = '';
+ public string|array $url = '';
/**
* @var string Base URL of elFinder library starting from Manager HTML
*/
- public $baseUrl = '';
+ public string $baseUrl = '';
/**
* @var string The interface lang to use. Can currently be one of the following: ar, bg, ca, cs, de, en, es, fr, hu,
* jp, nl, pl, pt_BR, ru, zh_CN. You will also need to include corresponding language file from js/i18n directory.
*/
- public $lang;
+ public string $lang;
/**
* @var array Data to append to all requests and to upload files. These can be any extra data that must be passed to
* the connector script. For example, you could use these to pass authentication information.
*/
- public $customData;
+ public array $customData;
/**
* @var string Additional css class for filemanager node. This will be applied to the main filemanager container.
*/
- public $cssClass;
+ public string $cssClass;
/**
* @var boolean|array Auto load required CSS (elfinder.min.css and theme.css).
*
* false to disable this function or CSS URL Array to load additional CSS files
*/
- public $cssAutoLoad = false;
+ public array|bool $cssAutoLoad = false;
/**
* @var boolean Remeber last opened dir to open it after reload or in next session. This is stored in browser cookie.
*/
- public $rememberLastDir;
+ public bool $rememberLastDir;
/**
* @var boolean Clear historys(elFinder) on reload(not browser) function. Historys was cleared on Reload function on
* elFinder 2.0. (value is true)
*/
- public $reloadClearHistory;
+ public bool $reloadClearHistory;
/**
* @var boolean Use browser native history by hash-change with supported browsers. This option give URI hash that
* holder position hash of elFinder.
*/
- public $useBrowserHistory;
+ public bool $useBrowserHistory;
/**
* @var array Display only certain files based on their mime type.
*/
- public $onlyMimes;
+ public array $onlyMimes;
/**
* @var boolean|string|\yii\web\JsExpression Used to validate file names. By default, no empty names or '..' allowed.
*/
- public $validName;
+ public string|bool|\yii\web\JsExpression $validName;
/**
* @var string Hash of default directory path to open.
*
@@ -103,77 +103,77 @@ class ElFinder extends Widget
* var hash = volumeId + btoa(path).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '.').rep
* ```
*/
- public $startPathHash;
+ public string $startPathHash;
/**
* @var string Default view mode. Can be [[ElFinder::VIEW_ICONS]] and [[ElFinder::VIEW_LIST]].
*/
- public $defaultView = self::VIEW_ICONS;
+ public string $defaultView = self::VIEW_ICONS;
/**
* @var string Default sort type. Can be [[ElFinder::SORT_NAME]], [[ElFinder::SORT_KIND]], [[ElFinder::SORT_SIZE]]
* or [[ElFinder::SORT_DATE]]
*/
- public $sortType;
+ public string $sortType;
/**
* @var integer Default sort order. Either [[SORT_ASC]] or [[SORT_DESC]]
*/
- public $sortOrder = SORT_ASC;
+ public int $sortOrder = SORT_ASC;
/**
* @var boolean Display folders first?
*/
- public $sortStickFolders = true;
+ public bool $sortStickFolders = true;
/**
* @var string|integer The width of the elFinder main interface.
*/
- public $width;
+ public string|int $width;
/**
* @var integer The height of the elFinder main interface (in pixels).
*/
- public $height;
+ public int $height;
/**
* @var boolean Format dates using client. If set to false - backend date format will be used.
*/
- public $clientFormatDate;
+ public bool $clientFormatDate;
/**
* @var boolean Show datetime in UTC timezone. Requires clientFormatDate set to true.
*/
- public $UTCDate;
+ public bool $UTCDate;
/**
* @var string File modification datetime format. Value from selected language is used by default.
* Set format here to overwrite it. Format is set in PHP date maner
*/
- public $dateFormat;
+ public string $dateFormat;
/**
* @var string File modification datetime format for last two days (today, yesterday).
* Same syntax as for dateFormat. Use $1 for "Today" and "Yesterday" placeholder.
*/
- public $fancyDateFormat;
+ public string $fancyDateFormat;
/**
* @var string Style of file mode at cwd-list, info dialog [[ElFinder::FILE_MODE_STRING]] (ex. rwxr-xr-x)
* or [[ElFinder::FILE_MODE_OCTAL]] (ex. 755) or [[ElFinder::FILE_MODE_BOTH]] (ex. rwxr-xr-x (755))
*/
- public $fileModeStyle;
+ public string $fileModeStyle;
/**
* @var array Active commands list. You can set any list of enabled commands here if some minimal required commands
* will be missed here, elFinder will add them to list automatically.
*
* '*' means all of the commands that have been load.
*/
- public $commands;
+ public array $commands;
/**
* @var null|\yii\web\JsExpression Commands options used to interact with external callbacks, editors, plugins.
*/
- public $commandsOptions;
+ public ?\yii\web\JsExpression $commandsOptions;
/**
* @var null|\yii\web\JsExpression Callback function for "getfile" command. Required to use elFinder with WYSIWYG
* editors, external callbacks.
* For more info how to use this function refer to wiki WYSIWYG integrations examples.
*/
- public $getFileCallback;
+ public ?\yii\web\JsExpression $getFileCallback;
/**
* @var \yii\web\JsExpression[] Event listeners to bind on elFinder init.
* For more info refer Client event API.
*/
- public $handlers;
+ public array $handlers;
/**
* @var array UI plugins to load. places value not activated by default.
*
@@ -182,91 +182,91 @@ class ElFinder extends Widget
* ['toolbar', 'places', 'tree', 'path', 'stat']
* ```
*/
- public $ui;
+ public array $ui;
/**
* @var null|array Specifies the configuration for the elFinder UI.
*/
- public $uiOptions;
+ public ?array $uiOptions;
/**
* @var array The configuration for the right-click context menu
*/
- public $contextmenu;
+ public array $contextmenu;
/**
* @var boolean Whether or not the elFinder interface will be resizable. This only works if jQuery UI has the
* resizable plugin loaded.
*/
- public $resizable;
+ public bool $resizable;
/**
* @var integer Timeout in ms for open notification dialogs.
*/
- public $notifyDelay;
+ public int $notifyDelay;
/**
* @var array Position and width of notification dialogs.
*/
- public $notifyDialog;
+ public array $notifyDialog;
/**
* @var string|boolean Allow to drag and drop to upload files.
*/
- public $dragUploadAllow;
+ public string|bool $dragUploadAllow;
/**
* @var boolean Allow shortcuts
*/
- public $allowShortcuts;
+ public bool $allowShortcuts;
/**
* @var integer Number of thumbnails to create per one request
*/
- public $loadTmbs;
+ public int $loadTmbs;
/**
* @var integer Lazy load. Amount of files display at once.
*/
- public $showFiles;
+ public int $showFiles;
/**
* @var integer Lazy load. Distance in px to cwd bottom edge to start displaying files.
*/
- public $showThreshold;
+ public int $showThreshold;
/**
* @var string The AJAX request type. Available choices are [[ElFinder::REQUEST_POST]]
* and [[ElFinder::REQUEST_GET]].
*/
- public $requestType;
+ public string $requestType;
/**
* @var string Separate URL to upload file to. If not set - connector URL will be used.
*/
- public $urlUpload;
+ public string $urlUpload;
/**
* @var integer Timeout for upload using iframe.
*/
- public $iframeTimeout;
+ public int $iframeTimeout;
/**
* @var integer Sync content by refreshing cwd every N milliseconds. Value must be bigger than 1000. 0 = no sync
*/
- public $sync;
+ public int $sync;
/**
* @var array Cookie option for browsers that does not support localStorage
*/
- public $cookie;
+ public array $cookie;
/**
* @var array Passing custom headers during Ajax calls
*/
- public $customHeaders;
+ public array $customHeaders;
/**
* @var array Any custom xhrFields to send across every ajax request, useful for CORS
* (Cross-origin resource sharing) support
*/
- public $xhrFields;
+ public array $xhrFields;
/**
* @var array|boolean Debug config
*/
- public $debug;
+ public array|bool $debug;
/**
* @var integer Increase the size of individual chunks.
*/
- public $uploadMaxChunkSize;
+ public int $uploadMaxChunkSize;
/**
* @var boolean play sounds? Defaults to true
* @since 1.1.13
*/
- public $sound;
+ public bool $sound;
/**
* @var array the HTML attributes for the title tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
@@ -275,12 +275,12 @@ class ElFinder extends Widget
/**
* @var string name of the instance used in module configuration (defaults to default)
*/
- public $instanceName = 'default';
+ public string $instanceName = 'default';
/**
* {@inheritDoc}
*/
- public function init()
+ public function init(): void
{
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
@@ -305,7 +305,7 @@ public function init()
/**
* {@inheritDoc}
*/
- public function run()
+ public function run(): void
{
echo Html::tag('div', null, $this->options);
@@ -315,7 +315,7 @@ public function run()
/**
* {@inheritDoc}
*/
- protected function registerPlugin($pluginName = 'elfinder', $selector = null)
+ protected function registerPlugin($pluginName = 'elfinder', $selector = null): void
{
$id = $this->options['id'];
$view = $this->getView();
@@ -339,7 +339,7 @@ protected function registerPlugin($pluginName = 'elfinder', $selector = null)
*
* @return string
*/
- protected function getClientOptions()
+ protected function getClientOptions(): string
{
$options = get_object_vars($this);
if ($options['sortOrder'] === SORT_DESC) {
@@ -360,7 +360,7 @@ protected function getClientOptions()
unset($options['options']);
foreach ($options as $key => $option) {
- if (is_null($option) || substr($key, 0, 1) === '_') {
+ if (is_null($option) || str_starts_with($key, '_')) {
unset($options[$key]);
}
}
diff --git a/src/widgets/ElFinderInput.php b/src/widgets/ElFinderInput.php
index 7fef099..914bed4 100644
--- a/src/widgets/ElFinderInput.php
+++ b/src/widgets/ElFinderInput.php
@@ -58,59 +58,59 @@ class ElFinderInput extends InputWidget
* such as an image tag. If this is is coming from end users, you should [[encode()]]
* it to prevent XSS attacks.
*/
- public $label;
+ public string $label;
/**
* @var string name of the instance used in module configuration (defaults to default)
*/
- public $instanceName = 'default';
+ public string $instanceName = 'default';
/**
* @var array ElFinder widget configuration options
*/
- public $elfinderOptions = [];
+ public array $elfinderOptions = [];
/**
* @var boolean add an image cropper widget (requires demi/cropper)
*/
- public $addImageCrop = false;
+ public bool $addImageCrop = false;
/**
* @var array options for image cropper
*/
- public $cropperOptions = [];
+ public array $cropperOptions = [];
/**
* @var boolean add a preview button
*/
- public $addPreview = false;
+ public bool $addPreview = false;
/**
* @var string Preview button content
*/
- public $previewContent = '';
+ public string $previewContent = '';
/**
* @var array Preview button options
*/
- public $previewButtonOptions = [
+ public array $previewButtonOptions = [
'class' => ['btn', 'btn-default'],
'target' => '_blank'
];
/**
* @var array Open elfinder button options
*/
- public $openButtonOptions = [
+ public array $openButtonOptions = [
'class' => ['btn', 'btn-default'],
];
/**
* @var array modal options
* @see \yii\bootstrap\Modal
*/
- public $modalOptions = [];
+ public array $modalOptions = [];
/**
* @var boolean return only path or full url
*/
- public $onlyPath = false;
+ public bool $onlyPath = false;
/**
* {@inheritdoc}
* @throws \ReflectionException
*/
- public function init()
+ public function init(): void
{
if (!isset($this->options['id'])) {
if ($this->hasModel()) {
@@ -129,7 +129,7 @@ public function init()
* @inheritdoc
* @throws \Exception
*/
- public function run()
+ public function run(): string
{
$options = $this->options;
$cropperCallback = '';
@@ -225,7 +225,7 @@ public function run()
* @param string $icon
* @deprecated
*/
- public function setIcon($icon)
+ public function setIcon(string $icon): void
{
ArrayHelper::setValue($this->openButtonOptions, 'icon', $icon);
}
@@ -236,7 +236,7 @@ public function setIcon($icon)
* @param string $modalIcon
* @deprecated
*/
- public function setModalIcon($modalIcon)
+ public function setModalIcon(string $modalIcon): void
{
ArrayHelper::setValue($this->modalOptions, 'icon', $modalIcon);
}
@@ -247,7 +247,7 @@ public function setModalIcon($modalIcon)
* @param array $previewOptions
* @deprecated
*/
- public function setPreviewOptions(array $previewOptions)
+ public function setPreviewOptions(array $previewOptions): void
{
$this->previewButtonOptions = $previewOptions;
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 864388a..3e2a323 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -21,7 +21,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
/**
* {@inheritDoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->mockWebApplication();
@@ -30,7 +30,7 @@ protected function setUp()
/**
* {@inheritDoc}
*/
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
$this->destroyApplication();
@@ -40,9 +40,9 @@ protected function tearDown()
* @param array $config
* @param string $appClass
*/
- protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
+ protected function mockWebApplication(array $config = [], string $appClass = '\yii\web\Application'): void
{
- new $appClass(ArrayHelper::merge([
+ $app = new $appClass(ArrayHelper::merge([
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
@@ -53,7 +53,7 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
'connectionSets' => [
'default' => [
[
- 'class' => 'simialbi\yii2\elfinder\ElfinderConfigurationLocalFileSystem',
+ 'class' => 'simialbi\yii2\elfinder\ElFinderConfigurationLocalFileSystem',
'path' => '@webroot/default',
'URL' => '@web/default'
]
@@ -79,7 +79,7 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
'request' => [
'cookieValidationKey' => '2VYuNNIognPSVv0zqj1C9sdmgk_O1UBa',
'scriptFile' => __DIR__ . '/index.php',
- 'scriptUrl' => '/index.php',
+ 'scriptUrl' => '/index.php'
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
@@ -87,16 +87,16 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning', 'info'],
- ],
- ],
+ ]
+ ]
],
'urlManager' => [
'showScriptName' => true,
- ],
+ ]
],
'params' => [
'adminEmail' => 'admin@example.com',
- ],
+ ]
], $config));
}
@@ -105,10 +105,10 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
*
* @param string $controllerId
* @param string $actionID
- * @param string $moduleID
+ * @param string|null $moduleID
* @param array $params
*/
- protected function mockAction($controllerId, $actionID, $moduleID = null, $params = [])
+ protected function mockAction(string $controllerId, string $actionID, ?string $moduleID = null, array $params = []): void
{
Yii::$app->controller = $controller = new Controller($controllerId, Yii::$app);
$controller->actionParams = $params;
@@ -122,7 +122,7 @@ protected function mockAction($controllerId, $actionID, $moduleID = null, $param
/**
* Removes controller
*/
- protected function removeMockedAction()
+ protected function removeMockedAction(): void
{
Yii::$app->controller = null;
}
@@ -130,7 +130,7 @@ protected function removeMockedAction()
/**
* Destroys application in Yii::$app by setting it to null.
*/
- protected function destroyApplication()
+ protected function destroyApplication(): void
{
Yii::$app = null;
Yii::$container = new Container();
@@ -142,7 +142,7 @@ protected function destroyApplication()
* @param string $expected
* @param string $actual
*/
- public function assertEqualsWithoutLE($expected, $actual)
+ public function assertEqualsWithoutLE(string $expected, string $actual): void
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);
@@ -156,7 +156,7 @@ public function assertEqualsWithoutLE($expected, $actual)
* @param string $needle
* @param string $haystack
*/
- public function assertContainsWithoutLE($needle, $haystack)
+ public function assertContainsWithoutLE(string $needle, string $haystack): void
{
$needle = str_replace("\r\n", "\n", $needle);
$haystack = str_replace("\r\n", "\n", $haystack);