smiley 1 月之前
父节点
当前提交
53e2d8f7fc
共有 1 个文件被更改,包括 4 次插入10 次删除
  1. 4 10
      src/Common/LuminanceSourceAbstract.php

+ 4 - 10
src/Common/LuminanceSourceAbstract.php

@@ -16,7 +16,7 @@ namespace chillerlan\QRCode\Common;
 use chillerlan\QRCode\QROptions;
 use chillerlan\QRCode\Decoder\QRCodeDecoderException;
 use chillerlan\Settings\SettingsContainerInterface;
-use function array_slice, array_splice, file_exists, is_file, is_readable, realpath;
+use function array_slice, file_exists, is_file, is_readable, realpath;
 
 /**
  * The purpose of this class hierarchy is to abstract different bitmap implementations across
@@ -28,7 +28,7 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
 
 	protected SettingsContainerInterface|QROptions $options;
 	/** @var int[] */
-	protected array $luminances;
+	protected array $luminances = [];
 	protected int   $width;
 	protected int   $height;
 
@@ -36,8 +36,6 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
 		$this->width   = $width;
 		$this->height  = $height;
 		$this->options = $options;
-
-		$this->luminances = [];
 	}
 
 	public function getLuminances():array{
@@ -54,15 +52,11 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
 
 	public function getRow(int $y):array{
 
-		if($y < 0 || $y >= $this->getHeight()){
+		if($y < 0 || $y >= $this->height){
 			throw new QRCodeDecoderException('Requested row is outside the image: '.$y);
 		}
 
-		$arr = [];
-
-		array_splice($arr, 0, $this->width, array_slice($this->luminances, ($y * $this->width), $this->width));
-
-		return $arr;
+		return array_slice($this->luminances, ($y * $this->width), $this->width);
 	}
 
 	protected function setLuminancePixel(int $r, int $g, int $b):void{