Skip to content

Commit 5eb12ed

Browse files
committed
Allow default header comment accept multi copyrights
1 parent ec9fdf8 commit 5eb12ed

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Config.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,15 @@ public function setHeaderComment(string $header) : static
319319

320320
public function setDefaultHeaderComment(
321321
string $packageName,
322-
string $copyright = ''
322+
array | string $copyright = []
323323
) : static {
324+
$copyright = (array) $copyright;
324325
$copyrightLines = "\n";
325326
if ($copyright) {
326-
$copyrightLines .= "\n" . '(c) ' . $copyright . "\n";
327+
$copyrightLines .= "\n";
328+
foreach ($copyright as $cr) {
329+
$copyrightLines .= '(c) ' . $cr . "\n";
330+
}
327331
}
328332
$header = <<<EOF
329333
This file is part of {$packageName}.{$copyrightLines}

tests/ConfigTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,11 @@ public function testDefaultHeaderComment() : void
5454
$header = $this->config->getRules()['header_comment']['header'];
5555
self::assertStringContainsString('Bazz', $header);
5656
self::assertStringContainsString('(c) Acme', $header);
57+
$this->config->setDefaultHeaderComment('Bazz', ['Acme', 'OK']);
58+
// @phpstan-ignore-next-line
59+
$header = $this->config->getRules()['header_comment']['header'];
60+
self::assertStringContainsString('Bazz', $header);
61+
self::assertStringContainsString('(c) Acme', $header);
62+
self::assertStringContainsString('(c) OK', $header);
5763
}
5864
}

0 commit comments

Comments
 (0)