10BC0 Fix php8 deprecations by laurynas-convertapi · Pull Request #51 · ConvertAPI/convertapi-library-php · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ConvertAPI helps in converting various file formats. Creating PDF and Images fro

## Requirements

PHP 5.4.0 and later.
PHP 8.1.0 and later.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions examples/conversions_chaining.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
$cost = $jpgResult->getConversionCost();
$count = count($jpgResult->getFiles());

echo "Conversions done. Cost: ${cost}. Total files created: ${count}\n";
echo "Conversions done. Cost: {$cost}. Total files created: {$count}\n";

$zipResult = ConvertApi::convert('zip', ['Files' => $jpgResult->getFiles()], 'any');

$cost = $zipResult->getConversionCost();
$count = count($zipResult->getFiles());

echo "Conversions done. Cost: ${cost}. Total files created: ${count}\n";
echo "Conversions done. Cost: {$cost}. Total files created: {$count}\n";

$savedFiles = $zipResult->saveFiles($dir);

Expand Down
6 changes: 3 additions & 3 deletions lib/ConvertApi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function upload($file_or_resource, $fileName)

if (!$fp)
{
throw new Error\File("Unable to open file ${file_or_resource}");
throw new Error\File("Unable to open file {$file_or_resource}");
}

curl_setopt($ch, CURLOPT_POST, true);
Expand Down Expand Up @@ -72,7 +72,7 @@ public function download($url, $path)

if (!$fp)
{
throw new Error\File("Unable to open file ${path}");
throw new Error\File("Unable to open file {$path}");
}

curl_setopt($ch, CURLOPT_FILE, $fp);
Expand Down Expand Up @@ -193,7 +193,7 @@ private function buildFormData($params)
if (is_array($val))
{
foreach ($val as $k => $v)
$data["${key}[${k}]"] = $v;
$data["{$key}[{$k}]"] = $v;
}
elseif (is_bool($val))
$data[$key] = $val ? 'true' : 'false';
Expand Down
4 changes: 4 additions & 0 deletions lib/ConvertApi/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

class FileUpload
{
public $filePath;
private string $_fileName;
private array $_result;

function __construct($filePath, $fileName = null)
{
$this->filePath = $filePath;
Expand Down
2 changes: 2 additions & 0 deletions lib/ConvertApi/FormatDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class FormatDetector
{
private $resource;

function __construct($resource)
{
$this->resource = $resource;
Expand Down
3 changes: 2 additions & 1 deletion lib/ConvertApi/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

class Result
{
private $files;
private array $files;
public array $response;

function __construct($response)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/ConvertApi/ResultFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class ResultFile
{
public array $fileInfo;

function __construct($fileInfo)
{
$this->fileInfo = $fileInfo;
Expand Down
5 changes: 5 additions & 0 deletions lib/ConvertApi/Task.php
63BB
Original file line number Diff line numberDiff line change
Expand Up @@ -6,6 +6,11 @@ class Task
{
const DEFAULT_URL_FORMAT = 'url';

private ?string $fromFormat;
private ?string $toFormat;
private array $params;
private ?int $conversionTimeout;

function __construct($fromFormat, $toFormat, $params, $conversionTimeout = null)
{
$this->fromFormat = $fromFormat;
Expand Down
0