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

:octocat: change classnames to "self" on several returns

codemasher 4 лет назад
Родитель
Сommit
17d0bc0dd9

+ 3 - 3
src/Common/BitBuffer.php

@@ -44,7 +44,7 @@ final class BitBuffer{
 	/**
 	 * clears the buffer
 	 */
-	public function clear():BitBuffer{
+	public function clear():self{
 		$this->buffer = [];
 		$this->length = 0;
 
@@ -54,7 +54,7 @@ final class BitBuffer{
 	/**
 	 * appends a sequence of bits
 	 */
-	public function put(int $num, int $length):BitBuffer{
+	public function put(int $num, int $length):self{
 
 		for($i = 0; $i < $length; $i++){
 			$this->putBit((($num >> ($length - $i - 1)) & 1) === 1);
@@ -66,7 +66,7 @@ final class BitBuffer{
 	/**
 	 * appends a single bit
 	 */
-	public function putBit(bool $bit):BitBuffer{
+	public function putBit(bool $bit):self{
 		$bufIndex = (int)floor($this->length / 8);
 
 		if(count($this->buffer) <= $bufIndex){

+ 5 - 5
src/Common/GenericGFPoly.php

@@ -121,7 +121,7 @@ final class GenericGFPoly{
 	 *
 	 * @return \chillerlan\QRCode\Common\GenericGFPoly
 	 */
-	public function multiply(GenericGFPoly $other):GenericGFPoly{
+	public function multiply(GenericGFPoly $other):self{
 
 		if($this->isZero() || $other->isZero()){
 			return new self([0]);
@@ -171,7 +171,7 @@ final class GenericGFPoly{
 	 *
 	 * @return \chillerlan\QRCode\Common\GenericGFPoly
 	 */
-	public function multiplyInt(int $scalar):GenericGFPoly{
+	public function multiplyInt(int $scalar):self{
 
 		if($scalar === 0){
 			return new self([0]);
@@ -196,7 +196,7 @@ final class GenericGFPoly{
 	 *
 	 * @return \chillerlan\QRCode\Common\GenericGFPoly
 	 */
-	public function multiplyByMonomial(int $degree, int $coefficient):GenericGFPoly{
+	public function multiplyByMonomial(int $degree, int $coefficient):self{
 
 		if($degree < 0){
 			throw new InvalidArgumentException();
@@ -220,7 +220,7 @@ final class GenericGFPoly{
 	 *
 	 * @return \chillerlan\QRCode\Common\GenericGFPoly
 	 */
-	public function mod(GenericGFPoly $other):GenericGFPoly{
+	public function mod(GenericGFPoly $other):self{
 
 		if(count($this->coefficients) - count($other->coefficients) < 0){
 			return $this;
@@ -240,7 +240,7 @@ final class GenericGFPoly{
 	 *
 	 * @return \chillerlan\QRCode\Common\GenericGFPoly
 	 */
-	public function addOrSubtract(GenericGFPoly $other):GenericGFPoly{
+	public function addOrSubtract(GenericGFPoly $other):self{
 
 		if($this->isZero()){
 			return $other;

+ 1 - 1
src/Data/QRData.php

@@ -76,7 +76,7 @@ final class QRData{
 	/**
 	 * Sets the data string (internally called by the constructor)
 	 */
-	public function setData(array $dataSegments):QRData{
+	public function setData(array $dataSegments):self{
 		$this->dataSegments = $dataSegments;
 
 		$version = $this->options->version === QRCode::VERSION_AUTO

+ 14 - 14
src/Data/QRMatrix.php

@@ -92,7 +92,7 @@ final class QRMatrix{
 	/**
 	 * shortcut to initialize the matrix
 	 */
-	public function init(MaskPattern $maskPattern, bool $test = null):QRMatrix{
+	public function init(MaskPattern $maskPattern, bool $test = null):self{
 		return $this
 			->setFinderPattern()
 			->setSeparators()
@@ -171,7 +171,7 @@ final class QRMatrix{
 	 *   true  => $M_TYPE | 0x800
 	 *   false => $M_TYPE
 	 */
-	public function set(int $x, int $y, bool $value, int $M_TYPE):QRMatrix{
+	public function set(int $x, int $y, bool $value, int $M_TYPE):self{
 		$this->matrix[$y][$x] = $M_TYPE | ($value ? $this::IS_DARK : 0);
 
 		return $this;
@@ -180,7 +180,7 @@ final class QRMatrix{
 	/**
 	 * Flips the value of the module
 	 */
-	public function flip(int $x, int $y):QRMatrix{
+	public function flip(int $x, int $y):self{
 		$this->matrix[$y][$x] ^= $this::IS_DARK;
 
 		return $this;
@@ -208,7 +208,7 @@ final class QRMatrix{
 	/**
 	 * Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
 	 */
-	public function setDarkModule():QRMatrix{
+	public function setDarkModule():self{
 		$this->set(8, 4 * $this->version->getVersionNumber() + 9, true, $this::M_DARKMODULE);
 
 		return $this;
@@ -219,7 +219,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 7.3.2
 	 */
-	public function setFinderPattern():QRMatrix{
+	public function setFinderPattern():self{
 
 		$pos = [
 			[0, 0], // top left
@@ -254,7 +254,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 7.3.3
 	 */
-	public function setSeparators():QRMatrix{
+	public function setSeparators():self{
 
 		$h = [
 			[7, 0],
@@ -284,7 +284,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 7.3.5
 	 */
-	public function setAlignmentPattern():QRMatrix{
+	public function setAlignmentPattern():self{
 		$alignmentPattern = $this->version->getAlignmentPattern();
 
 		foreach($alignmentPattern as $y){
@@ -315,7 +315,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 7.3.4
 	 */
-	public function setTimingPattern():QRMatrix{
+	public function setTimingPattern():self{
 
 		foreach(range(8, $this->moduleCount - 8 - 1) as $i){
 
@@ -337,7 +337,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 8.10
 	 */
-	public function setVersionNumber(bool $test = null):QRMatrix{
+	public function setVersionNumber(bool $test = null):self{
 		$bits = $this->version->getVersionPattern();
 
 		if($bits !== null){
@@ -361,7 +361,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 8.9
 	 */
-	public function setFormatInfo(MaskPattern $maskPattern, bool $test = null):QRMatrix{
+	public function setFormatInfo(MaskPattern $maskPattern, bool $test = null):self{
 		$bits = $this->eccLevel->getformatPattern($maskPattern);
 
 		for($i = 0; $i < 15; $i++){
@@ -401,7 +401,7 @@ final class QRMatrix{
 	 *
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
-	public function setQuietZone(int $size = null):QRMatrix{
+	public function setQuietZone(int $size = null):self{
 
 		if($this->matrix[$this->moduleCount - 1][$this->moduleCount - 1] === $this::M_NULL){
 			throw new QRCodeDataException('use only after writing data');
@@ -448,7 +448,7 @@ final class QRMatrix{
 	 *
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
-	public function setLogoSpace(int $width, int $height, int $startX = null, int $startY = null):QRMatrix{
+	public function setLogoSpace(int $width, int $height, int $startX = null, int $startY = null):self{
 
 		// for logos we operate in ECC H (30%) only
 		if($this->eccLevel->getLevel() !== EccLevel::H){
@@ -510,7 +510,7 @@ final class QRMatrix{
 	 *
 	 * @return \chillerlan\QRCode\Data\QRMatrix
 	 */
-	public function mapData(SplFixedArray $data):QRMatrix{
+	public function mapData(SplFixedArray $data):self{
 		$byteCount         = $data->count();
 		$y                 = $this->moduleCount - 1;
 		$inc               = -1;
@@ -565,7 +565,7 @@ final class QRMatrix{
 	 *
 	 * ISO/IEC 18004:2000 Section 8.8.1
 	 */
-	public function mask(MaskPattern $maskPattern):QRMatrix{
+	public function mask(MaskPattern $maskPattern):self{
 		$this->maskPattern = $maskPattern;
 		$mask              = $this->maskPattern->getMask();
 

+ 1 - 1
src/Detector/AlignmentPattern.php

@@ -23,7 +23,7 @@ final class AlignmentPattern extends ResultPoint{
 	 * Combines this object's current estimate of a finder pattern position and module size
 	 * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two.
 	 */
-	public function combineEstimate(float $i, float $j, float $newModuleSize):AlignmentPattern{
+	public function combineEstimate(float $i, float $j, float $newModuleSize):self{
 		return new self(
 			($this->x + $j) / 2.0,
 			($this->y + $i) / 2.0,

+ 1 - 1
src/Detector/FinderPattern.php

@@ -55,7 +55,7 @@ final class FinderPattern extends ResultPoint{
 	 * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average
 	 * based on count.
 	 */
-	public function combineEstimate(float $i, float $j, float $newModuleSize):FinderPattern{
+	public function combineEstimate(float $i, float $j, float $newModuleSize):self{
 		$combinedCount = $this->count + 1;
 
 		return new self(

+ 6 - 6
src/Detector/PerspectiveTransform.php

@@ -36,7 +36,7 @@ final class PerspectiveTransform{
 		float $a11, float $a21, float $a31,
 		float $a12, float $a22, float $a32,
 		float $a13, float $a23, float $a33
-	):PerspectiveTransform{
+	):self{
 		$this->a11 = $a11;
 		$this->a12 = $a12;
 		$this->a13 = $a13;
@@ -53,7 +53,7 @@ final class PerspectiveTransform{
 	public function quadrilateralToQuadrilateral(
 		float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3,
 		float $x0p, float $y0p, float $x1p, float $y1p, float $x2p, float $y2p, float $x3p, float $y3p
-	):PerspectiveTransform{
+	):self{
 		return (new self)
 			->squareToQuadrilateral($x0p, $y0p, $x1p, $y1p, $x2p, $y2p, $x3p, $y3p)
 			->times($this->quadrilateralToSquare($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3));
@@ -62,14 +62,14 @@ final class PerspectiveTransform{
 	private function quadrilateralToSquare(
 		float $x0, float $y0, float $x1, float $y1,
 		float $x2, float $y2, float $x3, float $y3
-	):PerspectiveTransform{
+	):self{
 		// Here, the adjoint serves as the inverse:
 		return $this
 			->squareToQuadrilateral($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3)
 			->buildAdjoint();
 	}
 
-	private function buildAdjoint():PerspectiveTransform{
+	private function buildAdjoint():self{
 		// Adjoint is the transpose of the cofactor matrix:
 		return $this->set(
 			$this->a22 * $this->a33 - $this->a23 * $this->a32,
@@ -87,7 +87,7 @@ final class PerspectiveTransform{
 	private function squareToQuadrilateral(
 		float $x0, float $y0, float $x1, float $y1,
 		float $x2, float $y2, float $x3, float $y3
-	):PerspectiveTransform{
+	):self{
 		$dx3 = $x0 - $x1 + $x2 - $x3;
 		$dy3 = $y0 - $y1 + $y2 - $y3;
 
@@ -111,7 +111,7 @@ final class PerspectiveTransform{
 		);
 	}
 
-	private function times(PerspectiveTransform $other):PerspectiveTransform{
+	private function times(PerspectiveTransform $other):self{
 		return $this->set(
 			$this->a11 * $other->a11 + $this->a21 * $other->a12 + $this->a31 * $other->a13,
 			$this->a11 * $other->a21 + $this->a21 * $other->a22 + $this->a31 * $other->a23,

+ 7 - 7
src/QRCode.php

@@ -104,7 +104,7 @@ class QRCode{
 	/**
 	 * QRCode constructor.
 	 *
-	 * Sets the options instance, determines the current mb-encoding and sets it to UTF-8
+	 * Sets the options instance
 	 */
 	public function __construct(SettingsContainerInterface $options = null){
 		$this->options = $options ?? new QROptions;
@@ -240,7 +240,7 @@ class QRCode{
 	/**
 	 * ISO/IEC 18004:2000 8.3.2 - Numeric Mode
 	 */
-	public function addNumberSegment(string $data):QRCode{
+	public function addNumberSegment(string $data):self{
 		$this->addSegment(new Number($data));
 
 		return $this;
@@ -249,7 +249,7 @@ class QRCode{
 	/**
 	 * ISO/IEC 18004:2000 8.3.3 - Alphanumeric Mode
 	 */
-	public function addAlphaNumSegment(string $data):QRCode{
+	public function addAlphaNumSegment(string $data):self{
 		$this->addSegment(new AlphaNum($data));
 
 		return $this;
@@ -258,7 +258,7 @@ class QRCode{
 	/**
 	 * ISO/IEC 18004:2000 8.3.5 - Kanji Mode
 	 */
-	public function addKanjiSegment(string $data):QRCode{
+	public function addKanjiSegment(string $data):self{
 		$this->addSegment(new Kanji($data));
 
 		return $this;
@@ -267,7 +267,7 @@ class QRCode{
 	/**
 	 * ISO/IEC 18004:2000 8.3.4 - 8-bit Byte Mode
 	 */
-	public function addByteSegment(string $data):QRCode{
+	public function addByteSegment(string $data):self{
 		$this->addSegment(new Byte($data));
 
 		return $this;
@@ -276,7 +276,7 @@ class QRCode{
 	/**
 	 * ISO/IEC 18004:2000 8.3.1 - Extended Channel Interpretation (ECI) Mode
 	 */
-	public function addEciDesignator(int $encoding):QRCode{
+	public function addEciDesignator(int $encoding):self{
 		$this->addSegment(new ECI($encoding));
 
 		return $this;
@@ -287,7 +287,7 @@ class QRCode{
 	 *
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 */
-	public function addEciSegment(int $encoding, string $data):QRCode{
+	public function addEciSegment(int $encoding, string $data):self{
 		// validate the encoding id
 		$eciCharset = new ECICharset($encoding);
 		// get charset name