Просмотр исходного кода

:octocat: Byte: string "0" fails with empty()

smiley 3 лет назад
Родитель
Сommit
cda00d293a
2 измененных файлов с 2 добавлено и 1 удалено
  1. 1 1
      src/Data/Byte.php
  2. 1 0
      tests/Data/ByteTest.php

+ 1 - 1
src/Data/Byte.php

@@ -38,7 +38,7 @@ final class Byte extends QRDataModeAbstract{
 	 * @inheritDoc
 	 */
 	public static function validateString(string $string):bool{
-		return !empty($string);
+		return $string !== '';
 	}
 
 	/**

+ 1 - 0
tests/Data/ByteTest.php

@@ -27,6 +27,7 @@ final class ByteTest extends DatainterfaceTestAbstract{
 		return [
 			["\x01\x02\x03", true],
 			['            ', true], // not empty!
+			['0', true], // should survive !empty()
 			['', false],
 		];
 	}