Skip to content

Commit

Permalink
Upgrading code to php 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldreams committed Apr 14, 2024
1 parent e481d06 commit 1e74e6d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
{
"name": "Tuhin Bepari",
"email": "[email protected]",
"homepage": "http://rpms.ieltsmaster.net",
"homepage": "http://github.com/digitaldreams",
"role": "Developer"
}
],
"require": {
"php": ">=5.4.0",
"php": "^8.2",
"phpoffice/phpspreadsheet": "^1.6"
},
"require-dev":{

},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/data-converter/FileExcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function read()
{

try {
$retData = array($range = '');
$retData = [$range = ''];
if (!empty($range)) {
$this->range = $range;
}
Expand Down
17 changes: 6 additions & 11 deletions src/data-converter/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
class FileManager {

const FILE_TYPE_EXCEL = 'excel';
const FILE_TYPE_TEXT = 'text';
const FILE_TYPE_JSON = 'json';
const FILE_TYPE_XML = 'xml';
public const FILE_TYPE_EXCEL = 'excel';
public const FILE_TYPE_TEXT = 'text';
public const FILE_TYPE_JSON = 'json';
public const FILE_TYPE_XML = 'xml';

/**
* Full path of the file.
Expand Down Expand Up @@ -180,7 +180,6 @@ public function __call($name, $arguments) {

/**
* Set settings as associative array. Where key will be the name of the property and value would be its value
* @param array $config
* @return \App\Libs\Report\FileManager Description
*/
public function config(array $config) {
Expand Down Expand Up @@ -214,7 +213,7 @@ public function filter($filter = []) {
$retArr = [];
foreach ($this->data as $index => $value) {
$row = (array) $value;
$filteredArray = array();
$filteredArray = [];
$filteredArray = array_intersect_key($row, array_flip($this->filter));
$retArr[] = $filteredArray;
}
Expand Down Expand Up @@ -345,7 +344,6 @@ public function loadFile($file_path = '', $mode = '', $force_create = false) {

/**
* Set error message from an exception
* @param \Exception $ex
* @return type
*/
public function setException(\Exception $ex) {
Expand All @@ -355,13 +353,10 @@ public function setException(\Exception $ex) {

/**
* Throw a new exception
* @param \Exception $ex
* @return \App\Libs\Report\FileManager
* @throws \Exception
*/
public function throwException(\Exception $ex) {
public function throwException(\Exception $ex): never {
throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
return $this;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/data-converter/FileXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class FileXml extends FileManager implements FileManagerInterface {
* @param file $file_path qualified file path
* @param character $mode file open mode
*/
public function __construct($file_path = '', $mode = '') {
public function __construct()
{
parent::__construct();
}

Expand Down
4 changes: 2 additions & 2 deletions src/data-converter/Laravel/Exim.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function validate(callable $callback)

public function dataFile($pathToFile)
{
$ext = pathinfo($pathToFile, PATHINFO_EXTENSION);
$ext = pathinfo((string) $pathToFile, PATHINFO_EXTENSION);
$this->extension = str_replace(".", "", $ext);

$this->fileManager = FileManager::initByExt($this->extension);
Expand Down Expand Up @@ -126,7 +126,7 @@ public function upload(\Illuminate\Http\Request $request, $name)
public function write($filePath = '', $filter = [])
{
if (!empty($filePath)) {
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
$ext = pathinfo((string) $filePath, PATHINFO_EXTENSION);
$this->extension = str_replace(".", "", $ext);
$this->fileManager = FileManager::initByExt($this->extension);
} else {
Expand Down

0 comments on commit 1e74e6d

Please sign in to comment.