mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-24 16:27:54 +00:00
:octocat: QRData::setData(): clear BitBuffer before write
This commit is contained in:
@@ -155,4 +155,16 @@ final class BitBuffer{
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the buffer and resets the stats
|
||||
*/
|
||||
public function clear():self{
|
||||
$this->buffer = [];
|
||||
$this->length = 0;
|
||||
$this->bytesRead = 0;
|
||||
$this->bitsRead = 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ final class QRData{
|
||||
|
||||
/**
|
||||
* Sets the data string (internally called by the constructor)
|
||||
*
|
||||
* Subsequent calls will overwrite the current state - use the QRCode::add*Segement() method instead
|
||||
*/
|
||||
public function setData(array $dataSegments):self{
|
||||
$this->dataSegments = $dataSegments;
|
||||
@@ -84,6 +86,7 @@ final class QRData{
|
||||
|
||||
$this->version = new Version($version);
|
||||
|
||||
$this->bitBuffer->clear();
|
||||
$this->writeBitBuffer();
|
||||
|
||||
return $this;
|
||||
|
||||
Reference in New Issue
Block a user