Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor
/cache
/.phpunit.cache
/build

composer.lock
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "<12"
},
"config": {
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="test/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="test/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Music/Scale.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setNote(int $note, bool $on): void
$this->notes[$note] = $on;
}

public function getNote(int $note): int
public function getNote(int $note): bool
{
return $this->notes[($note + 12 - $this->key) % 12];
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpTabs/Music/Song.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Song extends SongBase
/**
* Get the list of instruments
*
* @return array<key,array<int,string>>
* @return array<int, array{id: int, name: string}>
*/
public function getInstruments(): array
{
Expand Down Expand Up @@ -52,7 +52,7 @@ public function countInstruments(): int
/**
* Gets an instrument by channelId
*
* @return array<int,array<int,string>>
* @return array{id: int, name: string}|null
*/
public function getInstrument(int $index): ?array
{
Expand Down
5 changes: 3 additions & 2 deletions src/PhpTabs/PhpTabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ public function setTablature(Tablature $tablature): self
public function fromArray(array $data): self
{
$importer = new Importer($data);
$tabulature = new Tablature();
$tabulature->setSong($importer->getSong());

$this->setTablature(new Tablature())
->setSong($importer->getSong());
$this->setTablature($tabulature);

return $this;
}
Expand Down
7 changes: 1 addition & 6 deletions src/PhpTabs/Reader/GuitarPro/GuitarPro3Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ final class GuitarPro3Reader extends GuitarProReaderBase
*/
protected $tripletFeel;

/**
* @var int
*/
protected $keySignature;

/**
* @param \PhpTabs\Component\InputStream $file An input file to read
*/
Expand Down Expand Up @@ -135,7 +130,7 @@ private function readMeasureHeaders(Song $song, int $count): void
/**
* Loops on tracks to read
*
* @param array<PhpTabs\Music\Channel> $channels
* @param array<\PhpTabs\Music\Channel> $channels
*/
private function readTracks(Song $song, int $count, array $channels): void
{
Expand Down
7 changes: 1 addition & 6 deletions src/PhpTabs/Reader/GuitarPro/GuitarPro4Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ final class GuitarPro4Reader extends GuitarProReaderBase
*/
protected $tripletFeel;

/**
* @var int
*/
protected $keySignature;

/**
* @var \PhpTabs\Component\Tablature
*/
Expand Down Expand Up @@ -185,7 +180,7 @@ private function readMeasureHeaders(Song $song, int $count): void
/**
* Loop on tracks to read
*
* @param array<PhpTabs\Music\Channel> $channels
* @param array<\PhpTabs\Music\Channel> $channels
*/
private function readTracks(Song $song, int $count, array $channels, Lyric $lyric, int $lyricTrack): void
{
Expand Down
5 changes: 0 additions & 5 deletions src/PhpTabs/Reader/GuitarPro/GuitarPro5Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ final class GuitarPro5Reader extends GuitarProReaderBase
'FICHIER GUITAR PRO v5.10',
];

/**
* @var int
*/
protected $keySignature;

/**
* @var \PhpTabs\Component\Tablature
*/
Expand Down
5 changes: 5 additions & 0 deletions src/PhpTabs/Reader/GuitarPro/GuitarProReaderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ abstract class GuitarProReaderBase implements GuitarProReaderInterface
*/
private $file;

/**
* @var int
*/
protected $keySignature;

/**
* @param \PhpTabs\Component\InputStream $file An input file to read
*/
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Reader/GuitarPro/Helper/GuitarPro3Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class GuitarPro3Track extends AbstractReader
/**
* Reads track informations
*
* @param array<PhpTabs\Music\Channel> $channels
* @param array<\PhpTabs\Music\Channel> $channels
*/
public function readTrack(Song $song, array $channels = []): Track
{
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Reader/GuitarPro/Helper/GuitarPro4Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class GuitarPro4Track extends AbstractReader
/**
* Reads track informations
*
* @param array<PhpTabs\Music\Channel> $channels
* @param array<\PhpTabs\Music\Channel> $channels
*/
public function readTrack(Song $song, array $channels, Lyric $lyrics): Track
{
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Reader/GuitarPro/Helper/GuitarPro5Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class GuitarPro5Track extends AbstractReader
/**
* Read track informations
*
* @param array<PhpTabs\Music\Channel> $channels
* @param array<\PhpTabs\Music\Channel> $channels
*/
public function readTrack(Song $song, array $channels, Lyric $lyrics): Track
{
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Reader/Midi/MidiAdjuster.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private function adjustStrings(Beat $beat): void
}

/**
* @param array<TabString> $strings
* @param array<\PhpTabs\Music\TabString> $strings
*/
private function getStringForValue(array $strings, int $value): int
{
Expand Down
17 changes: 16 additions & 1 deletion src/PhpTabs/Reader/Midi/MidiReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ final class MidiReader extends MidiReaderBase
*/
private $settings;

/**
* @var Tablature|null
*/
private $tablature;

/**
* @var MidiSequence
*/
private $sequence;

/**
* @var ChannelRouter
*/
private $channelRouter;

/**
* @param \PhpTabs\Component\InputStream $file An input file to read
*/
Expand All @@ -92,7 +107,7 @@ public function __construct(InputStream $file)

$this->setTablature($song);

$this->settings = (new MidiSettings())->getDefaults();
$this->settings = MidiSettings::getDefaults();
$this->sequence = $this->getSequence();
$this->initFields($this->sequence);

Expand Down
6 changes: 3 additions & 3 deletions src/PhpTabs/Renderer/Ascii/AsciiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public function drawBarSegment(): void
public function drawNote(string $fret): void
{
$this->movePoint(
$this->getPosX() + mb_strlen(strval($fret)),
$this->getPosX() + mb_strlen($fret),
$this->getPosY()
);

$this->append(strval($fret));
$this->append($fret);
}

/**
Expand Down Expand Up @@ -205,7 +205,7 @@ public function output(): string

for ($line = 0; $line <= $maxLines; $line++) {
for ($col = 0; $col <= $maxCols; $col++) {
if (isset($this->content[$line], $this->content[$line][$col])) {
if (isset($this->content[$line][$col])) {
$content .= $this->content[$line][$col];
}
}
Expand Down
1 change: 0 additions & 1 deletion src/PhpTabs/Writer/Midi/MidiSequenceParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ private function makeBeats(MidiSequenceHelper $helper, Channel $channel, Track $
$stroke[] = 0;
}

$track->getStrings();
$previous = null;

$countBeats = $measure->countBeats();
Expand Down
2 changes: 1 addition & 1 deletion src/PhpTabs/Writer/Midi/MidiWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(Song $song)
$channelRouter = new ChannelRouter();
$channelRouterConfigurator = new ChannelRouterConfigurator($channelRouter);
$channelRouterConfigurator->configureRouter($song->getChannels());
$settings = (new MidiSettings())->getDefaults();
$settings = MidiSettings::getDefaults();

$midiSequenceParser = new MidiSequenceParser(
$song,
Expand Down