Skip to content

Commit 2341ef3

Browse files
committed
Fix Lyric inconsistency
1 parent 45e57c8 commit 2341ef3

22 files changed

+50
-47
lines changed

src/PhpTabs/Music/Lyric.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ class Lyric
1717
{
1818
const REGEX = " ";
1919

20+
/**
21+
* @var int
22+
*/
2023
private $from;
24+
25+
/**
26+
* @var string
27+
*/
2128
private $lyrics;
2229

2330
public function __construct()
2431
{
2532
$this->from = 1;
26-
$this->lyrics = [];
33+
$this->lyrics = '';
2734
}
2835

2936
public function getFrom(): int
@@ -36,16 +43,12 @@ public function setFrom(int $from): void
3643
$this->from = $from;
3744
}
3845

39-
public function getLyrics(): array
46+
public function getLyrics(): string
4047
{
4148
return $this->lyrics;
4249
}
4350

44-
/**
45-
* @param array|string $lyrics
46-
* @todo Fix given type either string or array
47-
*/
48-
public function setLyrics($lyrics): void
51+
public function setLyrics(string $lyrics): void
4952
{
5053
$this->lyrics = $lyrics;
5154
}
@@ -65,7 +68,7 @@ public function getLyricBeats(): array
6568

6669
public function isEmpty(): bool
6770
{
68-
return count($this->getLyrics()) == 0;
71+
return strlen($this->getLyrics()) === 0;
6972
}
7073

7174
public function copyFrom(Lyric $lyric): void

src/PhpTabs/Writer/GuitarPro/GuitarPro5Writer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ private function writeLyrics(Song $song): void
230230
}
231231
}
232232

233-
$this->writeInt($lyricTrack == null ? 0 : $lyricTrack->getNumber());
234-
$this->writeInt($lyricTrack == null ? 0 : $lyricTrack->getLyrics()->getFrom());
233+
$this->writeInt(is_null($lyricTrack) ? 0 : $lyricTrack->getNumber());
234+
$this->writeInt(is_null($lyricTrack) ? 0 : $lyricTrack->getLyrics()->getFrom());
235235
$this->writeStringInteger(
236-
$lyricTrack == null ? '' : $lyricTrack->getLyrics()->getLyrics()
236+
is_null($lyricTrack) ? '' : $lyricTrack->getLyrics()->getLyrics()
237237
);
238238

239239
for ($i = 0; $i < 4; $i++) {
240-
$this->writeInt($lyricTrack === null ? 0 : 1);
240+
$this->writeInt(is_null($lyricTrack) ? 0 : 1);
241241
$this->writeStringInteger('');
242242
}
243243
}

test/PhpTabs/files/json/testSimpleMidi.mid.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
},
158158
"lyrics": {
159159
"from": 1,
160-
"lyrics": []
160+
"lyrics": ""
161161
},
162162
"measures": [
163163
{
@@ -3304,7 +3304,7 @@
33043304
},
33053305
"lyrics": {
33063306
"from": 1,
3307-
"lyrics": []
3307+
"lyrics": ""
33083308
},
33093309
"measures": [
33103310
{

test/PhpTabs/files/json/testSimpleTab.gp3.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
},
184184
"lyrics": {
185185
"from": 1,
186-
"lyrics": []
186+
"lyrics": ""
187187
},
188188
"measures": [
189189
{
@@ -3262,7 +3262,7 @@
32623262
},
32633263
"lyrics": {
32643264
"from": 1,
3265-
"lyrics": []
3265+
"lyrics": ""
32663266
},
32673267
"measures": [
32683268
{

test/PhpTabs/files/json/testSimpleTab.gp4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
},
184184
"lyrics": {
185185
"from": 1,
186-
"lyrics": []
186+
"lyrics": ""
187187
},
188188
"measures": [
189189
{
@@ -3262,7 +3262,7 @@
32623262
},
32633263
"lyrics": {
32643264
"from": 1,
3265-
"lyrics": []
3265+
"lyrics": ""
32663266
},
32673267
"measures": [
32683268
{

test/PhpTabs/files/json/testSimpleTab.gp5.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
},
184184
"lyrics": {
185185
"from": 1,
186-
"lyrics": []
186+
"lyrics": ""
187187
},
188188
"measures": [
189189
{
@@ -3262,7 +3262,7 @@
32623262
},
32633263
"lyrics": {
32643264
"from": 1,
3265-
"lyrics": []
3265+
"lyrics": ""
32663266
},
32673267
"measures": [
32683268
{

test/PhpTabs/files/json/testSimpleTab.mid.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
},
158158
"lyrics": {
159159
"from": 1,
160-
"lyrics": []
160+
"lyrics": ""
161161
},
162162
"measures": [
163163
{
@@ -3196,7 +3196,7 @@
31963196
},
31973197
"lyrics": {
31983198
"from": 1,
3199-
"lyrics": []
3199+
"lyrics": ""
32003200
},
32013201
"measures": [
32023202
{

test/PhpTabs/files/serialized/testSimpleMidi.mid.ser

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test/PhpTabs/files/serialized/testSimpleTab.gp3.ser

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test/PhpTabs/files/serialized/testSimpleTab.gp4.ser

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)