Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / paragonie / random_compat / lib / random_bytes_libsodium.php
index 4af1a242279f7e2f759f13e4d45336d1e2889b9c..7a95e2b40cf3136017c2806a4b352a14361232a0 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * The MIT License (MIT)
  *
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -43,6 +43,7 @@ if (!is_callable('random_bytes')) {
     function random_bytes($bytes)
     {
         try {
+            /** @var int $bytes */
             $bytes = RandomCompat_intval($bytes);
         } catch (TypeError $ex) {
             throw new TypeError(
@@ -60,6 +61,7 @@ if (!is_callable('random_bytes')) {
          * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
          * generated in one invocation.
          */
+        /** @var string|bool $buf */
         if ($bytes > 2147483647) {
             $buf = '';
             for ($i = 0; $i < $bytes; $i += 1073741824) {
@@ -69,10 +71,11 @@ if (!is_callable('random_bytes')) {
                 $buf .= \Sodium\randombytes_buf($n);
             }
         } else {
+            /** @var string|bool $buf */
             $buf = \Sodium\randombytes_buf($bytes);
         }
 
-        if ($buf !== false) {
+        if (is_string($buf)) {
             if (RandomCompat_strlen($buf) === $bytes) {
                 return $buf;
             }