Update composer dependencies
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 1 Aug 2023 13:43:11 +0000 (15:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 1 Aug 2023 13:44:20 +0000 (15:44 +0200)
18 files changed:
wcfsetup/install/files/lib/system/api/composer.json
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/README.md
wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/Response/JsonResponse.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/.laminas-ci.json [deleted file]
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/composer.json
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/renovate.json [new file with mode: 0644]
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Adapter/AbstractAdapter.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Adapter/Console.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Adapter/JsPull.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Adapter/JsPush.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/ProgressBar.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Upload/AbstractUploadHandler.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Upload/ApcProgress.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Upload/SessionProgress.php
wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/src/Upload/UploadProgress.php

index 4b5cdb7f1f9627672885193d2326c13d98a7dcc4..731183b6cea41c43254ca33d49d7ea294bbcc790 100644 (file)
@@ -16,9 +16,9 @@
         "ezyang/htmlpurifier": "^4.16",
         "guzzlehttp/guzzle": "^7.7.0",
         "guzzlehttp/psr7": "^2.5.0",
-        "laminas/laminas-diactoros": "^3.0.0",
+        "laminas/laminas-diactoros": "^3.1.0",
         "laminas/laminas-httphandlerrunner": "^2.7.0",
-        "laminas/laminas-progressbar": "^2.11",
+        "laminas/laminas-progressbar": "^2.12",
         "paragonie/constant_time_encoding": "^2.6.3",
         "pelago/emogrifier": "^7.0.0",
         "psr/clock": "^1.0",
index bec6162ff0c8baf6135e8feb1fc397113da148eb..7a9f744029f5c6aaed3714cef13d7a0cc617f626 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "d814a85f0d1b746a068aee996edf2215",
+    "content-hash": "f22e1ed8363f1981362682c58a866a8a",
     "packages": [
         {
             "name": "cuyz/valinor",
         },
         {
             "name": "laminas/laminas-diactoros",
-            "version": "3.0.0",
+            "version": "3.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laminas/laminas-diactoros.git",
-                "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea"
+                "reference": "860660e0774719660699e2b851071555c7b7d45c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/2515f4134258b1b418c23cb86606b8a09dd01aea",
-                "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea",
+                "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/860660e0774719660699e2b851071555c7b7d45c",
+                "reference": "860660e0774719660699e2b851071555c7b7d45c",
                 "shasum": ""
             },
             "require": {
                     "type": "community_bridge"
                 }
             ],
-            "time": "2023-05-04T21:18:23+00:00"
+            "time": "2023-08-01T12:40:44+00:00"
         },
         {
             "name": "laminas/laminas-httphandlerrunner",
         },
         {
             "name": "laminas/laminas-progressbar",
-            "version": "2.11.0",
+            "version": "2.12.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laminas/laminas-progressbar.git",
-                "reference": "f4ab187791a64370825e9012b756e49d568230ea"
+                "reference": "a7cb86bd5cc7ce9a96700297776f567119d65834"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laminas/laminas-progressbar/zipball/f4ab187791a64370825e9012b756e49d568230ea",
-                "reference": "f4ab187791a64370825e9012b756e49d568230ea",
+                "url": "https://api.github.com/repos/laminas/laminas-progressbar/zipball/a7cb86bd5cc7ce9a96700297776f567119d65834",
+                "reference": "a7cb86bd5cc7ce9a96700297776f567119d65834",
                 "shasum": ""
             },
             "require": {
                 "zendframework/zend-progressbar": "*"
             },
             "require-dev": {
-                "laminas/laminas-coding-standard": "~1.0.0",
-                "laminas/laminas-session": "^2.13",
+                "laminas/laminas-coding-standard": "~2.5.0",
+                "laminas/laminas-session": "^2.16",
                 "phpunit/phpunit": "^9.5.25"
             },
             "suggest": {
                     "type": "community_bridge"
                 }
             ],
-            "time": "2022-10-25T14:08:59+00:00"
+            "time": "2023-08-01T13:29:34+00:00"
         },
         {
             "name": "laminas/laminas-stdlib",
index 36738b5e6f9102b4fb56d1b0cfce586d1dec9af4..f9c86fcc62470d7a110ecf4025dd6d52c82c0042 100644 (file)
         },
         {
             "name": "laminas/laminas-diactoros",
-            "version": "3.0.0",
-            "version_normalized": "3.0.0.0",
+            "version": "3.1.0",
+            "version_normalized": "3.1.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laminas/laminas-diactoros.git",
-                "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea"
+                "reference": "860660e0774719660699e2b851071555c7b7d45c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/2515f4134258b1b418c23cb86606b8a09dd01aea",
-                "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea",
+                "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/860660e0774719660699e2b851071555c7b7d45c",
+                "reference": "860660e0774719660699e2b851071555c7b7d45c",
                 "shasum": ""
             },
             "require": {
                 "psalm/plugin-phpunit": "^0.18.4",
                 "vimeo/psalm": "^5.9"
             },
-            "time": "2023-05-04T21:18:23+00:00",
+            "time": "2023-08-01T12:40:44+00:00",
             "type": "library",
             "extra": {
                 "laminas": {
         },
         {
             "name": "laminas/laminas-progressbar",
-            "version": "2.11.0",
-            "version_normalized": "2.11.0.0",
+            "version": "2.12.0",
+            "version_normalized": "2.12.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laminas/laminas-progressbar.git",
-                "reference": "f4ab187791a64370825e9012b756e49d568230ea"
+                "reference": "a7cb86bd5cc7ce9a96700297776f567119d65834"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laminas/laminas-progressbar/zipball/f4ab187791a64370825e9012b756e49d568230ea",
-                "reference": "f4ab187791a64370825e9012b756e49d568230ea",
+                "url": "https://api.github.com/repos/laminas/laminas-progressbar/zipball/a7cb86bd5cc7ce9a96700297776f567119d65834",
+                "reference": "a7cb86bd5cc7ce9a96700297776f567119d65834",
                 "shasum": ""
             },
             "require": {
                 "zendframework/zend-progressbar": "*"
             },
             "require-dev": {
-                "laminas/laminas-coding-standard": "~1.0.0",
-                "laminas/laminas-session": "^2.13",
+                "laminas/laminas-coding-standard": "~2.5.0",
+                "laminas/laminas-session": "^2.16",
                 "phpunit/phpunit": "^9.5.25"
             },
             "suggest": {
                 "laminas/laminas-session": "To support progressbar persistent"
             },
-            "time": "2022-10-25T14:08:59+00:00",
+            "time": "2023-08-01T13:29:34+00:00",
             "type": "library",
             "installation-source": "dist",
             "autoload": {
index 166d19436cabaf2b7e21a317d031d6fe4a3d69a8..1a018e70056f46d681d1cfdc15e210fec615b335 100644 (file)
@@ -83,9 +83,9 @@
             'dev_requirement' => false,
         ),
         'laminas/laminas-diactoros' => array(
-            'pretty_version' => '3.0.0',
-            'version' => '3.0.0.0',
-            'reference' => '2515f4134258b1b418c23cb86606b8a09dd01aea',
+            'pretty_version' => '3.1.0',
+            'version' => '3.1.0.0',
+            'reference' => '860660e0774719660699e2b851071555c7b7d45c',
             'type' => 'library',
             'install_path' => __DIR__ . '/../laminas/laminas-diactoros',
             'aliases' => array(),
             'dev_requirement' => false,
         ),
         'laminas/laminas-progressbar' => array(
-            'pretty_version' => '2.11.0',
-            'version' => '2.11.0.0',
-            'reference' => 'f4ab187791a64370825e9012b756e49d568230ea',
+            'pretty_version' => '2.12.0',
+            'version' => '2.12.0.0',
+            'reference' => 'a7cb86bd5cc7ce9a96700297776f567119d65834',
             'type' => 'library',
             'install_path' => __DIR__ . '/../laminas/laminas-progressbar',
             'aliases' => array(),
index 078bd50e064d6aa10e017c15e02a2cd8288be035..13ece3829cfecd5e513bfcd84056b305c7dc20be 100644 (file)
@@ -3,19 +3,19 @@
 [![Build Status](https://github.com/laminas/laminas-diactoros/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-diactoros/actions/workflows/continuous-integration.yml)
 
 > ## 🇷🇺 Русским гражданам
-> 
+>
 > Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.
-> 
+>
 > У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.
-> 
+>
 > Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"
-> 
+>
 > ## 🇺🇸 To Citizens of Russia
-> 
+>
 > We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
-> 
+>
 > One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
-> 
+>
 > You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"
 
 > Diactoros (pronunciation: `/dɪʌktɒrɒs/`): an epithet for Hermes, meaning literally, "the messenger."
index 8dcad1b2c55addd231494c4165d269c1a463ff21..f570a0a004df5736ff53a6e912d3664b306f3151 100644 (file)
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 namespace Laminas\Diactoros\Response;
 
+use JsonException;
 use Laminas\Diactoros\Exception;
 use Laminas\Diactoros\Response;
 use Laminas\Diactoros\Stream;
@@ -11,15 +12,13 @@ use Laminas\Diactoros\Stream;
 use function is_object;
 use function is_resource;
 use function json_encode;
-use function json_last_error;
-use function json_last_error_msg;
 use function sprintf;
 
-use const JSON_ERROR_NONE;
 use const JSON_HEX_AMP;
 use const JSON_HEX_APOS;
 use const JSON_HEX_QUOT;
 use const JSON_HEX_TAG;
+use const JSON_THROW_ON_ERROR;
 use const JSON_UNESCAPED_SLASHES;
 
 /**
@@ -131,17 +130,15 @@ class JsonResponse extends Response
         // Clear json_last_error()
         json_encode(null);
 
-        $json = json_encode($data, $encodingOptions);
-
-        if (JSON_ERROR_NONE !== json_last_error()) {
+        try {
+            return json_encode($data, $encodingOptions | JSON_THROW_ON_ERROR);
+        } catch (JsonException $e) {
             throw new Exception\InvalidArgumentException(sprintf(
                 'Unable to encode data to JSON in %s: %s',
                 self::class,
-                json_last_error_msg()
-            ));
+                $e->getMessage()
+            ), 0, $e);
         }
-
-        return $json;
     }
 
     private function setPayload(mixed $data): void
diff --git a/wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/.laminas-ci.json b/wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/.laminas-ci.json
deleted file mode 100644 (file)
index 6d7c4b7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "ignore_php_platform_requirements": {
-        "8.2": true
-    }
-}
index 9f8512fcabcd300b92595bb5c75baaadd66e264a..aa8407cec56f2813b399fdc1db701f1f3ace0211 100644 (file)
         "forum": "https://discourse.laminas.dev"
     },
     "config": {
-        "sort-packages": true
+        "sort-packages": true,
+        "platform": {
+            "php": "8.0.99"
+        },
+        "allow-plugins": {
+            "dealerdirect/phpcodesniffer-composer-installer": true
+        }
     },
     "require": {
         "php": "~8.0.0 || ~8.1.0 || ~8.2.0",
         "laminas/laminas-stdlib": "^3.2.1"
     },
     "require-dev": {
-        "laminas/laminas-coding-standard": "~1.0.0",
-        "laminas/laminas-session": "^2.13",
+        "laminas/laminas-coding-standard": "~2.5.0",
+        "laminas/laminas-session": "^2.16",
         "phpunit/phpunit": "^9.5.25"
     },
     "suggest": {
diff --git a/wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/renovate.json b/wcfsetup/install/files/lib/system/api/laminas/laminas-progressbar/renovate.json
new file mode 100644 (file)
index 0000000..060b1d1
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
+  "extends": [
+    "local>laminas/.github:renovate-config"
+  ]
+}
index f4159177d8a93cdd3702edf09d42d7793c922694..30f6e642798b6a7eba311d8f6e886f15204c3a6b 100644 (file)
@@ -5,6 +5,12 @@ namespace Laminas\ProgressBar\Adapter;
 use Laminas\Stdlib\ArrayUtils;
 use Traversable;
 
+use function in_array;
+use function is_array;
+use function method_exists;
+use function strtolower;
+use function ucfirst;
+
 /**
  * Abstract class for Laminas\ProgressBar Adapters
  */
@@ -67,7 +73,7 @@ abstract class AbstractAdapter
      * @param  float   $max           Max progress value
      * @param  float   $percent       Current percent value
      * @param  int $timeTaken     Taken time in seconds
-     * @param  int $timeRemaining Remaining time in seconds
+     * @param  int|null $timeRemaining Remaining time in seconds
      * @param  string  $text          Status text
      * @return void
      */
index 90060669197783a8d8b2b88316d88d93ac5a436a..68dca9c8fc75b223b0d98dabec5629ab3e9c9507 100644 (file)
@@ -2,11 +2,40 @@
 
 namespace Laminas\ProgressBar\Adapter;
 
-use Laminas\ProgressBar\Adapter\Exception\RuntimeException;
+use Laminas\ProgressBar\Adapter\Exception\InvalidArgumentException;
 use Laminas\Stdlib\ErrorHandler;
 use Laminas\Stdlib\StringUtils;
+use Traversable;
 use ValueError;
 
+use function array_diff;
+use function ceil;
+use function count;
+use function defined;
+use function fclose;
+use function floor;
+use function fopen;
+use function fwrite;
+use function implode;
+use function in_array;
+use function is_int;
+use function min;
+use function preg_match;
+use function round;
+use function shell_exec;
+use function sprintf;
+use function str_pad;
+use function str_repeat;
+use function strlen;
+use function substr;
+
+use const E_DEPRECATED;
+use const PHP_EOL;
+use const PHP_OS;
+use const STDOUT;
+use const STR_PAD_LEFT;
+use const STR_PAD_RIGHT;
+
 /**
  * Laminas\ProgressBar\Adapter\Console offers a text-based progressbar for console
  * applications
@@ -16,44 +45,44 @@ class Console extends AbstractAdapter
     /**
      * Percentage value of the progress
      */
-    const ELEMENT_PERCENT = 'ELEMENT_PERCENT';
+    public const ELEMENT_PERCENT = 'ELEMENT_PERCENT';
 
     /**
      * Visual value of the progress
      */
-    const ELEMENT_BAR = 'ELEMENT_BAR';
+    public const ELEMENT_BAR = 'ELEMENT_BAR';
 
     /**
      * ETA of the progress
      */
-    const ELEMENT_ETA = 'ELEMENT_ETA';
+    public const ELEMENT_ETA = 'ELEMENT_ETA';
 
     /**
      * Text part of the progress
      */
-    const ELEMENT_TEXT = 'ELEMENT_TEXT';
+    public const ELEMENT_TEXT = 'ELEMENT_TEXT';
 
     /**
      * Finish action: End of Line
      */
-    const FINISH_ACTION_EOL = 'FINISH_ACTION_EOL';
+    public const FINISH_ACTION_EOL = 'FINISH_ACTION_EOL';
 
     /**
      * Finish action: Clear Line
      */
-    const FINISH_ACTION_CLEAR_LINE = 'FINISH_ACTION_CLEAR_LINE';
+    public const FINISH_ACTION_CLEAR_LINE = 'FINISH_ACTION_CLEAR_LINE';
 
     /**
      * Finish action: None
      */
-    const FINISH_ACTION_NONE = 'FINISH_ACTION_NONE';
+    public const FINISH_ACTION_NONE = 'FINISH_ACTION_NONE';
 
     /**
      * Width of the progressbar
      *
      * @var int
      */
-    protected $width = null;
+    protected $width;
 
     /**
      * Elements to display
@@ -106,7 +135,7 @@ class Console extends AbstractAdapter
      *
      * @var resource
      */
-    protected $outputStream = null;
+    protected $outputStream;
 
     /**
      * Width of the text element
@@ -132,7 +161,7 @@ class Console extends AbstractAdapter
     /**
      * Defined by Laminas\ProgressBar adapter
      *
-     * @param  array|\Traversable $options
+     * @param array|Traversable $options
      */
     public function __construct($options = null)
     {
@@ -159,7 +188,7 @@ class Console extends AbstractAdapter
      * Set a different output-stream
      *
      * @param  string $resource
-     * @throws Exception\RuntimeException
+     * @throws RuntimeException
      */
     public function setOutputStream($resource)
     {
@@ -207,7 +236,7 @@ class Console extends AbstractAdapter
      * Set the width of the progressbar
      *
      * @param  int $width
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @return Console
      */
     public function setWidth($width = null)
     {
@@ -244,19 +273,20 @@ class Console extends AbstractAdapter
      * Set the elements to display with the progressbar
      *
      * @param  array $elements
-     * @throws \Laminas\ProgressBar\Adapter\Exception\InvalidArgumentException When an invalid element is found
-     *                                                                      in the array
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @throws InvalidArgumentException When an invalid element is found in the array.
+     * @return Console
      */
     public function setElements(array $elements)
     {
-        $allowedElements = [self::ELEMENT_PERCENT,
-                                 self::ELEMENT_BAR,
-                                 self::ELEMENT_ETA,
-                                 self::ELEMENT_TEXT];
+        $allowedElements = [
+            self::ELEMENT_PERCENT,
+            self::ELEMENT_BAR,
+            self::ELEMENT_ETA,
+            self::ELEMENT_TEXT,
+        ];
 
         if (count(array_diff($elements, $allowedElements)) > 0) {
-            throw new Exception\InvalidArgumentException('Invalid element found in $elements array');
+            throw new InvalidArgumentException('Invalid element found in $elements array');
         }
 
         $this->elements = $elements;
@@ -270,13 +300,13 @@ class Console extends AbstractAdapter
      * Set the left-hand character for the bar
      *
      * @param  string $char
-     * @throws \Laminas\ProgressBar\Adapter\Exception\InvalidArgumentException When character is empty
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @throws InvalidArgumentException When character is empty.
+     * @return Console
      */
     public function setBarLeftChar($char)
     {
         if (empty($char)) {
-            throw new Exception\InvalidArgumentException('Character may not be empty');
+            throw new InvalidArgumentException('Character may not be empty');
         }
 
         $this->barLeftChar = (string) $char;
@@ -288,13 +318,13 @@ class Console extends AbstractAdapter
      * Set the right-hand character for the bar
      *
      * @param  string $char
-     * @throws \Laminas\ProgressBar\Adapter\Exception\InvalidArgumentException When character is empty
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @throws InvalidArgumentException When character is empty.
+     * @return Console
      */
     public function setBarRightChar($char)
     {
         if (empty($char)) {
-            throw new Exception\InvalidArgumentException('Character may not be empty');
+            throw new InvalidArgumentException('Character may not be empty');
         }
 
         $this->barRightChar = (string) $char;
@@ -306,7 +336,7 @@ class Console extends AbstractAdapter
      * Set the indicator character for the bar
      *
      * @param  string $char
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @return Console
      */
     public function setBarIndicatorChar($char)
     {
@@ -319,7 +349,7 @@ class Console extends AbstractAdapter
      * Set the width of the text element
      *
      * @param  int $width
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @return Console
      */
     public function setTextWidth($width)
     {
@@ -344,17 +374,19 @@ class Console extends AbstractAdapter
      * Set the finish action
      *
      * @param  string $action
-     * @throws \Laminas\ProgressBar\Adapter\Exception\InvalidArgumentException When an invalid action is specified
-     * @return \Laminas\ProgressBar\Adapter\Console
+     * @throws InvalidArgumentException When an invalid action is specified.
+     * @return Console
      */
     public function setFinishAction($action)
     {
-        $allowedActions = [self::FINISH_ACTION_CLEAR_LINE,
-                                self::FINISH_ACTION_EOL,
-                                self::FINISH_ACTION_NONE];
+        $allowedActions = [
+            self::FINISH_ACTION_CLEAR_LINE,
+            self::FINISH_ACTION_EOL,
+            self::FINISH_ACTION_NONE,
+        ];
 
         if (! in_array($action, $allowedActions)) {
-            throw new Exception\InvalidArgumentException('Invalid finish action specified');
+            throw new InvalidArgumentException('Invalid finish action specified');
         }
 
         $this->finishAction = $action;
@@ -369,7 +401,7 @@ class Console extends AbstractAdapter
      * @param  float   $max           Max progress value
      * @param  float   $percent       Current percent value
      * @param  int $timeTaken     Taken time in seconds
-     * @param  int $timeRemaining Remaining time in seconds
+     * @param  int|null $timeRemaining Remaining time in seconds
      * @param  string  $text          Status text
      * @return void
      */
@@ -379,7 +411,7 @@ class Console extends AbstractAdapter
         if ($this->outputStarted) {
             $data = str_repeat("\x08", $this->width);
         } else {
-            $data = '';
+            $data                = '';
             $this->outputStarted = true;
         }
 
@@ -437,7 +469,7 @@ class Console extends AbstractAdapter
                     } else {
                         $hours   = floor($timeRemaining / 3600);
                         $minutes = floor(($timeRemaining % 3600) / 60);
-                        $seconds = ($timeRemaining % 3600 % 60);
+                        $seconds = $timeRemaining % 3600 % 60;
 
                         $etaFormatted = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
                     }
@@ -446,7 +478,7 @@ class Console extends AbstractAdapter
                     break;
 
                 case self::ELEMENT_TEXT:
-                    $wrapper = StringUtils::getWrapper($this->charset);
+                    $wrapper            = StringUtils::getWrapper($this->charset);
                     $renderedElements[] = $wrapper->strPad(
                         $wrapper->substr($text, 0, $this->textWidth),
                         $this->textWidth,
index 8b7fffc246801fd00c3f4091c9302da24e3311e4..ff8d462fffda85ea806527f2aff40807599c15a7 100644 (file)
@@ -23,7 +23,7 @@ class JsPull extends AbstractAdapter
      * Set whether to exit after json data send or not
      *
      * @param  bool $exitAfterSend
-     * @return \Laminas\ProgressBar\Adapter\JsPull
+     * @return void
      */
     public function setExitAfterSend($exitAfterSend)
     {
@@ -37,7 +37,7 @@ class JsPull extends AbstractAdapter
      * @param  float   $max           Max progress value
      * @param  float   $percent       Current percent value
      * @param  int $timeTaken     Taken time in seconds
-     * @param  int $timeRemaining Remaining time in seconds
+     * @param  int|null $timeRemaining Remaining time in seconds
      * @param  string  $text          Status text
      * @return void
      */
@@ -46,11 +46,11 @@ class JsPull extends AbstractAdapter
         $arguments = [
             'current'       => $current,
             'max'           => $max,
-            'percent'       => ($percent * 100),
+            'percent'       => $percent * 100,
             'timeTaken'     => $timeTaken,
             'timeRemaining' => $timeRemaining,
             'text'          => $text,
-            'finished'      => false
+            'finished'      => false,
         ];
 
         $data = json_encode($arguments, JSON_THROW_ON_ERROR);
index 2b2aa71399d31fd6e506c4c421b109c606d1acb6..5a52189a75449bb5856461be8d37d1ee38511b77 100644 (file)
@@ -2,9 +2,13 @@
 
 namespace Laminas\ProgressBar\Adapter;
 
+use function flush;
 use function json_encode;
+use function ob_flush;
+use function str_pad;
 
 use const JSON_THROW_ON_ERROR;
+use const STR_PAD_RIGHT;
 
 /**
  * Laminas\ProgressBar\Adapter\JsPush offers a simple method for updating a
@@ -30,7 +34,7 @@ class JsPush extends AbstractAdapter
      * Set the update method name
      *
      * @param  string $methodName
-     * @return \Laminas\ProgressBar\Adapter\JsPush
+     * @return JsPush
      */
     public function setUpdateMethodName($methodName)
     {
@@ -43,7 +47,7 @@ class JsPush extends AbstractAdapter
      * Set the finish method name
      *
      * @param  string $methodName
-     * @return \Laminas\ProgressBar\Adapter\JsPush
+     * @return JsPush
      */
     public function setFinishMethodName($methodName)
     {
@@ -59,7 +63,7 @@ class JsPush extends AbstractAdapter
      * @param  float   $max           Max progress value
      * @param  float   $percent       Current percent value
      * @param  int $timeTaken     Taken time in seconds
-     * @param  int $timeRemaining Remaining time in seconds
+     * @param  int|null $timeRemaining Remaining time in seconds
      * @param  string  $text          Status text
      * @return void
      */
@@ -68,10 +72,10 @@ class JsPush extends AbstractAdapter
         $arguments = [
             'current'       => $current,
             'max'           => $max,
-            'percent'       => ($percent * 100),
+            'percent'       => $percent * 100,
             'timeTaken'     => $timeTaken,
             'timeRemaining' => $timeRemaining,
-            'text'          => $text
+            'text'          => $text,
         ];
 
         $data = '<script type="text/javascript">'
index d98f20d1d522a676eb81d1a1435e402c513b377d..e93f9bea772f05e9c4ed5050f512cdb04bb71ca0 100644 (file)
@@ -2,8 +2,14 @@
 
 namespace Laminas\ProgressBar;
 
+use Laminas\ProgressBar\Adapter\AbstractAdapter;
 use Laminas\Session;
 
+use function max;
+use function min;
+use function round;
+use function time;
+
 /**
  * Laminas\ProgressBar offers an interface for multiple environments.
  */
@@ -47,7 +53,7 @@ class ProgressBar
     /**
      * Adapter for the output
      *
-     * @var \Laminas\ProgressBar\Adapter\AbstractAdapter
+     * @var AbstractAdapter
      */
     protected $adapter;
 
@@ -56,18 +62,17 @@ class ProgressBar
      *
      * @var string
      */
-    protected $persistenceNamespace = null;
+    protected $persistenceNamespace;
 
     /**
      * Create a new progressbar backend.
      *
-     * @param  Adapter\AbstractAdapter $adapter
      * @param  float|int               $min
      * @param  float|int               $max
      * @param  string|null             $persistenceNamespace
-     * @throws Exception\OutOfRangeException When $min is greater than $max
+     * @throws Exception\OutOfRangeException When $min is greater than $max.
      */
-    public function __construct(Adapter\AbstractAdapter $adapter, $min = 0, $max = 100, $persistenceNamespace = null)
+    public function __construct(AbstractAdapter $adapter, $min = 0, $max = 100, $persistenceNamespace = null)
     {
         // Check min/max values and set them
         if ($min > $max) {
@@ -109,7 +114,7 @@ class ProgressBar
     /**
      * Get the current adapter
      *
-     * @return Adapter\AbstractAdapter
+     * @return AbstractAdapter
      */
     public function getAdapter()
     {
@@ -154,7 +159,7 @@ class ProgressBar
         if ($percent === .0 || $percent === false) {
             $timeRemaining = null;
         } else {
-            $timeRemaining = round(((1 / $percent) * $timeTaken) - $timeTaken);
+            $timeRemaining = (int) round(((1 / $percent) * $timeTaken) - $timeTaken);
         }
 
         // Poll the adapter
index c49d6c7c7fd2e6b3e27b3c04713bc196df7f64de..1c5e2de62db4c41fd1f6bd041fef676f8f84557f 100644 (file)
@@ -8,19 +8,18 @@ use Laminas\ProgressBar\ProgressBar;
 use Laminas\Stdlib\ArrayUtils;
 use Traversable;
 
+use function is_array;
+use function round;
+
 /**
  * Abstract class for Upload Progress Handlers
  */
 abstract class AbstractUploadHandler implements UploadHandlerInterface
 {
-    /**
-     * @var string
-     */
-    protected $sessionNamespace = 'Laminas\ProgressBar\Upload\AbstractUploadHandler';
+    /** @var string */
+    protected $sessionNamespace = self::class;
 
-    /**
-     * @var AbstractProgressAdapter|ProgressBar
-     */
+    /** @var AbstractProgressAdapter|ProgressBar */
     protected $progressAdapter;
 
     /**
@@ -105,12 +104,12 @@ abstract class AbstractUploadHandler implements UploadHandlerInterface
      */
     public function getProgress($id)
     {
-        $status  = [
-            'total'    => 0,
-            'current'  => 0,
-            'rate'     => 0,
-            'message'  => 'No upload in progress',
-            'done'     => true
+        $status = [
+            'total'   => 0,
+            'current' => 0,
+            'rate'    => 0,
+            'message' => 'No upload in progress',
+            'done'    => true,
         ];
         if (empty($id)) {
             return $status;
@@ -122,8 +121,8 @@ abstract class AbstractUploadHandler implements UploadHandlerInterface
         }
         $status = $newStatus;
         if ('' === $status['message']) {
-            $status['message'] = $this->toByteString($status['current']) .
-                " - " . $this->toByteString($status['total']);
+            $status['message'] = $this->toByteString($status['current'])
+                " - " . $this->toByteString($status['total']);
         }
         $status['id'] = $id;
 
index c73a7a722782e2d807185a5f3de44721c374e4ae..70acb65f9a74b70f88a30eaf81ecfb195a7e3039 100644 (file)
@@ -4,6 +4,10 @@ namespace Laminas\ProgressBar\Upload;
 
 use Laminas\ProgressBar\Exception;
 
+use function ini_get;
+use function is_array;
+use function is_callable;
+
 /**
  * Progress Bar Upload Handler for the APC extension
  */
@@ -25,16 +29,16 @@ class ApcProgress extends AbstractUploadHandler
             return false;
         }
 
-        $status  = [
-            'total'    => 0,
-            'current'  => 0,
-            'rate'     => 0,
-            'message'  => '',
-            'done'     => false
+        $status = [
+            'total'   => 0,
+            'current' => 0,
+            'rate'    => 0,
+            'message' => '',
+            'done'    => false,
         ];
         $status = $uploadInfo + $status;
         if (! empty($status['cancel_upload'])) {
-            $status['done'] = true;
+            $status['done']    = true;
             $status['message'] = 'The upload has been canceled';
         }
 
index e4de9931b41b83d794df3c2971d101f0e3220bdb..fae6d6bb843a46448ee8a3251b563a9ce718c17c 100644 (file)
@@ -4,6 +4,10 @@ namespace Laminas\ProgressBar\Upload;
 
 use Laminas\ProgressBar\Exception;
 
+use function ini_get;
+use function is_array;
+use function time;
+
 /**
  * Progress Bar Upload Handler for PHP 5.4+ Session Upload Progress handling
  */
@@ -23,27 +27,27 @@ class SessionProgress extends AbstractUploadHandler
         }
 
         $sessionKey = ini_get('session.upload_progress.prefix') . $id;
-        $uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null;
+        $uploadInfo = $_SESSION[$sessionKey] ?? null;
         if (! is_array($uploadInfo)) {
             return false;
         }
 
-        $status  = [
-            'total'    => 0,
-            'current'  => 0,
-            'rate'     => 0,
-            'message'  => '',
-            'done'     => false,
+        $status            = [
+            'total'   => 0,
+            'current' => 0,
+            'rate'    => 0,
+            'message' => '',
+            'done'    => false,
         ];
-        $status = $uploadInfo + $status;
+        $status            = $uploadInfo + $status;
         $status['total']   = $status['content_length'];
         $status['current'] = $status['bytes_processed'];
 
-        $time = time() - $status['start_time'];
-        $status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0;
+        $time           = time() - $status['start_time'];
+        $status['rate'] = $time > 0 ? $status['bytes_processed'] / $time : 0;
 
         if (! empty($status['cancel_upload'])) {
-            $status['done'] = true;
+            $status['done']    = true;
             $status['message'] = 'The upload has been canceled';
         }
 
index a993c07ef0b2e42a8ec6abe66f9da52dde8e29a6..ace8fdabdf3aacaccb1442d2e7d4846b5de65d12 100644 (file)
@@ -4,6 +4,9 @@ namespace Laminas\ProgressBar\Upload;
 
 use Laminas\ProgressBar\Exception;
 
+use function is_array;
+use function is_callable;
+
 /**
  * Progress Bar Upload Handler for the UploadProgress extension
  */
@@ -27,17 +30,19 @@ class UploadProgress extends AbstractUploadHandler
             return false;
         }
 
-        $status  = [
-            'total'    => 0,
-            'current'  => 0,
-            'rate'     => 0,
-            'message'  => '',
-            'done'     => false
+        $status            = [
+            'total'   => 0,
+            'current' => 0,
+            'rate'    => 0,
+            'message' => '',
+            'done'    => false,
         ];
-        $status = $uploadInfo + $status;
+        $status            = $uploadInfo + $status;
         $status['total']   = $status['bytes_total'];
         $status['current'] = $status['bytes_uploaded'];
         $status['rate']    = $status['speed_average'];
+
+        // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator
         if ($status['total'] == $status['current']) {
             $status['done'] = true;
         }