codemasher 6 lat temu
rodzic
commit
d0a8f97a3e
2 zmienionych plików z 7 dodań i 3 usunięć
  1. 2 2
      examples/QRImageWithText.php
  2. 5 1
      src/Output/QRImage.php

+ 2 - 2
examples/QRImageWithText.php

@@ -88,10 +88,10 @@ class QRImageWithText extends QRImage{
 
 
 		$fontColor = \imagecolorallocate($this->image, ...$textColor);
 		$fontColor = \imagecolorallocate($this->image, ...$textColor);
 		$w         = \imagefontwidth($textSize);
 		$w         = \imagefontwidth($textSize);
-		$x         =  round(($bgWidth - strlen($text) * $w) / 2);
+		$x         =  \round(($bgWidth - \strlen($text) * $w) / 2);
 
 
 		// loop through the string and draw the letters
 		// loop through the string and draw the letters
-		foreach(str_split($text) as $i => $chr){
+		foreach(\str_split($text) as $i => $chr){
 			\imagechar($this->image, $textSize, $i * $w + $x, $this->length, $chr, $fontColor);
 			\imagechar($this->image, $textSize, $i * $w + $x, $this->length, $chr, $fontColor);
 		}
 		}
 	}
 	}

+ 5 - 1
src/Output/QRImage.php

@@ -65,7 +65,11 @@ class QRImage extends QROutputAbstract{
 	 */
 	 */
 	public function dump(string $file = null):string{
 	public function dump(string $file = null):string{
 		$this->image = \imagecreatetruecolor($this->length, $this->length);
 		$this->image = \imagecreatetruecolor($this->length, $this->length);
-		$background  = \imagecolorallocate($this->image, ...$this->options->imageTransparencyBG);
+
+		// avoid: Indirect modification of overloaded property $imageTransparencyBG has no effect
+		// https://stackoverflow.com/a/10455217
+		$tbg = $this->options->imageTransparencyBG;
+		$background  = \imagecolorallocate($this->image, ...$tbg);
 
 
 		if((bool)$this->options->imageTransparent && \in_array($this->options->outputType, $this::TRANSPARENCY_TYPES, true)){
 		if((bool)$this->options->imageTransparent && \in_array($this->options->outputType, $this::TRANSPARENCY_TYPES, true)){
 			\imagecolortransparent($this->image, $background);
 			\imagecolortransparent($this->image, $background);