From 299b9242b59fb9e6aca82c09168f451aaf71f5c5 Mon Sep 17 00:00:00 2001 From: Christian Scheb Date: Tue, 11 Aug 2020 22:58:55 +0200 Subject: [PATCH] Add function name in tombstone #5 --- src/analyzer/Source/TombstoneExtractor.php | 4 ++-- src/analyzer/Source/TombstoneVisitor.php | 2 +- src/core/Format/AnalyzerLogFormat.php | 4 ++++ src/core/Model/Tombstone.php | 19 +++++++++++++++---- src/core/Model/Vampire.php | 5 +++++ src/logger/Graveyard/BufferedGraveyard.php | 4 ++-- src/logger/Graveyard/Graveyard.php | 4 ++-- src/logger/Graveyard/GraveyardInterface.php | 2 +- src/logger/Graveyard/VampireFactory.php | 4 ++-- src/logger/tombstone-function.php | 2 +- .../Analyzer/Log/fixtures/allValid.tombstone | 4 ++-- .../Log/fixtures/malformedData.tombstone | 4 ++-- .../Report/fixtures/AnalyzerResultFixture.php | 12 ++++++------ .../Source/TombstoneExtractorTest.php | 2 +- tests/Core/Format/AnalyzerLogFormatTest.php | 4 ++-- tests/Core/Model/TombstoneTest.php | 4 ++-- tests/Core/Model/VampireTest.php | 2 +- tests/Fixture.php | 4 ++-- .../Graveyard/BufferedGraveyardTest.php | 14 +++++++------- .../Logger/Graveyard/GraveyardBuilderTest.php | 8 ++++---- tests/Logger/Graveyard/GraveyardTest.php | 8 ++++---- tests/Logger/Graveyard/VampireFactoryTest.php | 8 ++++---- 22 files changed, 72 insertions(+), 52 deletions(-) diff --git a/src/analyzer/Source/TombstoneExtractor.php b/src/analyzer/Source/TombstoneExtractor.php index d5dc8bc..0df0c81 100644 --- a/src/analyzer/Source/TombstoneExtractor.php +++ b/src/analyzer/Source/TombstoneExtractor.php @@ -68,13 +68,13 @@ public function extractTombstones(FilePathInterface $filePath): void $this->currentFile = null; } - public function onTombstoneFound(array $arguments, int $line, ?string $method): void + public function onTombstoneFound(string $functionName, array $arguments, int $line, ?string $method): void { if (null === $this->currentFile) { throw new \RuntimeException('Current file not available.'); } - $tombstone = new Tombstone($arguments, $this->currentFile, $line, $method); + $tombstone = new Tombstone($functionName, $arguments, $this->currentFile, $line, $method); $this->tombstoneIndex->addTombstone($tombstone); } } diff --git a/src/analyzer/Source/TombstoneVisitor.php b/src/analyzer/Source/TombstoneVisitor.php index 0dc45f9..04698d8 100644 --- a/src/analyzer/Source/TombstoneVisitor.php +++ b/src/analyzer/Source/TombstoneVisitor.php @@ -85,7 +85,7 @@ private function visitFunctionCallNode(FuncCall $node): void $methodName = $this->getCurrentMethodName(); $arguments = $this->extractArguments($node); /** @psalm-suppress PossiblyNullArgument */ - $this->tombstoneCallback->onTombstoneFound($arguments, $line, $methodName); + $this->tombstoneCallback->onTombstoneFound('tombstone', $arguments, $line, $methodName); } } diff --git a/src/core/Format/AnalyzerLogFormat.php b/src/core/Format/AnalyzerLogFormat.php index c51e4a5..bb60035 100644 --- a/src/core/Format/AnalyzerLogFormat.php +++ b/src/core/Format/AnalyzerLogFormat.php @@ -14,6 +14,7 @@ class AnalyzerLogFormat { private const CURRENT_VERSION = 10000; // 1.0.0 private const FIELD_VERSION = 'v'; + private const FIELD_FUNCTION_NAME = 'fn'; private const FIELD_ARGUMENTS = 'a'; private const FIELD_FILE = 'f'; private const FIELD_LINE = 'l'; @@ -28,6 +29,7 @@ class AnalyzerLogFormat ]; private const REQUIRED_FIELDS_LOG = [ self::FIELD_INVOCATION_DATE, + self::FIELD_FUNCTION_NAME, self::FIELD_ARGUMENTS, self::FIELD_FILE, self::FIELD_LINE, @@ -37,6 +39,7 @@ public static function vampireToLog(Vampire $vampire): string { return json_encode([ self::FIELD_VERSION => self::CURRENT_VERSION, + self::FIELD_FUNCTION_NAME => $vampire->getFunctionName(), self::FIELD_ARGUMENTS => $vampire->getArguments(), self::FIELD_FILE => $vampire->getFile()->getReferencePath(), self::FIELD_LINE => $vampire->getLine(), @@ -84,6 +87,7 @@ public static function logToVampire(string $log, RootPath $rootDir): Vampire $data[self::FIELD_INVOKER] ?? null, self::decodeStackTrace($data[self::FIELD_STACKTRACE] ?? [], $rootDir), new Tombstone( + $data[self::FIELD_FUNCTION_NAME], $data[self::FIELD_ARGUMENTS], $rootDir->createFilePath($data[self::FIELD_FILE]), $data[self::FIELD_LINE], diff --git a/src/core/Model/Tombstone.php b/src/core/Model/Tombstone.php index de44224..5cf5d2b 100644 --- a/src/core/Model/Tombstone.php +++ b/src/core/Model/Tombstone.php @@ -6,6 +6,11 @@ class Tombstone { + /** + * @var string + */ + private $functionName; + /** * @var array * @psalm-type list @@ -37,8 +42,9 @@ class Tombstone */ private $vampires = []; - public function __construct(array $arguments, FilePathInterface $file, int $line, ?string $method) + public function __construct(string $functionName, array $arguments, FilePathInterface $file, int $line, ?string $method) { + $this->functionName = $functionName; $this->arguments = $arguments; $this->tombstoneDate = $this->findDate($arguments); $this->file = $file; @@ -53,17 +59,17 @@ public function __toString(): string $argumentsList = '"'.implode('", "', $this->arguments).'"'; } - return 'tombstone('.$argumentsList.')'; + return $this->functionName.'('.$argumentsList.')'; } public function getHash(): int { - return crc32($this->file->getReferencePath()."\n".$this->line."\n".implode(',', $this->arguments)); + return crc32($this->file->getReferencePath()."\n".$this->line."\n".$this->functionName."\n".implode(',', $this->arguments)); } public function inscriptionEquals(Tombstone $tombstone): bool { - return $tombstone->getArguments() === $this->arguments; + return $tombstone->getFunctionName() === $this->functionName && $tombstone->getArguments() === $this->arguments; } private function findDate(array $arguments): ?string @@ -77,6 +83,11 @@ private function findDate(array $arguments): ?string return null; } + public function getFunctionName(): string + { + return $this->functionName; + } + public function getArguments(): array { return $this->arguments; diff --git a/src/core/Model/Vampire.php b/src/core/Model/Vampire.php index 3c2bf03..2b198dd 100644 --- a/src/core/Model/Vampire.php +++ b/src/core/Model/Vampire.php @@ -60,6 +60,11 @@ public function getTombstone(): Tombstone return $this->tombstone; } + public function getFunctionName(): string + { + return $this->tombstone->getFunctionName(); + } + public function getArguments(): array { return $this->tombstone->getArguments(); diff --git a/src/logger/Graveyard/BufferedGraveyard.php b/src/logger/Graveyard/BufferedGraveyard.php index 0aec24b..c0529fb 100644 --- a/src/logger/Graveyard/BufferedGraveyard.php +++ b/src/logger/Graveyard/BufferedGraveyard.php @@ -31,10 +31,10 @@ public function setAutoFlush(bool $autoFlush): void $this->autoFlush = $autoFlush; } - public function tombstone(array $arguments, array $trace, array $metadata): void + public function tombstone(string $functionName, array $arguments, array $trace, array $metadata): void { if ($this->autoFlush) { - $this->graveyard->tombstone($arguments, $trace, $metadata); + $this->graveyard->tombstone($functionName, $arguments, $trace, $metadata); } else { $this->tombstoneCalls[] = \func_get_args(); } diff --git a/src/logger/Graveyard/Graveyard.php b/src/logger/Graveyard/Graveyard.php index 9ce6049..279da94 100644 --- a/src/logger/Graveyard/Graveyard.php +++ b/src/logger/Graveyard/Graveyard.php @@ -32,10 +32,10 @@ public function __construct(VampireFactory $vampireFactory, ?LoggerInterface $lo $this->handlers = $handlers; } - public function tombstone(array $arguments, array $trace, array $metadata): void + public function tombstone(string $functionName, array $arguments, array $trace, array $metadata): void { try { - $vampire = $this->vampireFactory->createFromCall($arguments, $trace, $metadata); + $vampire = $this->vampireFactory->createFromCall($functionName, $arguments, $trace, $metadata); foreach ($this->handlers as $handler) { $handler->log($vampire); } diff --git a/src/logger/Graveyard/GraveyardInterface.php b/src/logger/Graveyard/GraveyardInterface.php index 9f5ad0f..2e01a3e 100644 --- a/src/logger/Graveyard/GraveyardInterface.php +++ b/src/logger/Graveyard/GraveyardInterface.php @@ -6,7 +6,7 @@ interface GraveyardInterface { - public function tombstone(array $arguments, array $trace, array $metadata): void; + public function tombstone(string $functionName, array $arguments, array $trace, array $metadata): void; public function flush(): void; } diff --git a/src/logger/Graveyard/VampireFactory.php b/src/logger/Graveyard/VampireFactory.php index 60167f5..22d86f9 100644 --- a/src/logger/Graveyard/VampireFactory.php +++ b/src/logger/Graveyard/VampireFactory.php @@ -28,7 +28,7 @@ public function __construct(RootPath $rootPath, int $stackTraceDepth) $this->stackTraceDepth = $stackTraceDepth; } - public function createFromCall(array $arguments, array $trace, array $metadata): Vampire + public function createFromCall(string $functionName, array $arguments, array $trace, array $metadata): Vampire { // This is the call to the tombstone $tombstoneCall = $trace[0]; @@ -47,7 +47,7 @@ public function createFromCall(array $arguments, array $trace, array $metadata): $invoker = $this->getMethodFromFrame($trace[2]); } - $tombstone = new Tombstone($arguments, $file, $line, $method); + $tombstone = new Tombstone($functionName, $arguments, $file, $line, $method); $stackTrace = null; if ($this->stackTraceDepth > 0) { diff --git a/src/logger/tombstone-function.php b/src/logger/tombstone-function.php index 80c4776..75c6a18 100644 --- a/src/logger/tombstone-function.php +++ b/src/logger/tombstone-function.php @@ -9,6 +9,6 @@ function tombstone(string ...$arguments): void { $trace = \Scheb\Tombstone\Logger\Tracing\TraceProvider::getTraceHere(); - \Scheb\Tombstone\Logger\Graveyard\GraveyardRegistry::getGraveyard()->tombstone($arguments, $trace, []); + \Scheb\Tombstone\Logger\Graveyard\GraveyardRegistry::getGraveyard()->tombstone(__FUNCTION__, $arguments, $trace, []); } } diff --git a/tests/Analyzer/Log/fixtures/allValid.tombstone b/tests/Analyzer/Log/fixtures/allValid.tombstone index 942478d..8b7e304 100644 --- a/tests/Analyzer/Log/fixtures/allValid.tombstone +++ b/tests/Analyzer/Log/fixtures/allValid.tombstone @@ -1,2 +1,2 @@ -{"v":10000,"a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} -{"v":10000,"a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} +{"v":10000,"fn":"tombstone","a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} +{"v":10000,"fn":"tombstone","a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} diff --git a/tests/Analyzer/Log/fixtures/malformedData.tombstone b/tests/Analyzer/Log/fixtures/malformedData.tombstone index 706c8b8..a5c19ae 100644 --- a/tests/Analyzer/Log/fixtures/malformedData.tombstone +++ b/tests/Analyzer/Log/fixtures/malformedData.tombstone @@ -1,3 +1,3 @@ -{"v":10000,"a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} +{"v":10000,"fn":"tombstone","a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} malformed -{"v":10000,"a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} +{"v":10000,"fn":"tombstone","a":["label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"\/path\/to\/file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"} diff --git a/tests/Analyzer/Report/fixtures/AnalyzerResultFixture.php b/tests/Analyzer/Report/fixtures/AnalyzerResultFixture.php index ca5f78d..8cc7040 100644 --- a/tests/Analyzer/Report/fixtures/AnalyzerResultFixture.php +++ b/tests/Analyzer/Report/fixtures/AnalyzerResultFixture.php @@ -15,12 +15,12 @@ class AnalyzerResultFixture public static function getAnalyzerResult(): AnalyzerResult { $rootDir = new RootPath(__DIR__.'/source'); - $functionTombstone = new Tombstone(['2020-01-01', 'globalFunction'], $rootDir->createFilePath('functions.php'), 7, 'globalFunction'); - $globalScope = new Tombstone(['2020-01-01', 'globalScope'], $rootDir->createFilePath('functions.php'), 10, null); - $class1Tombstone = new Tombstone(['2020-01-01', 'Class1'], $rootDir->createFilePath('Class1.php'), 11, 'Foo\\Class1::staticMethod'); - $class2Tombstone = new Tombstone(['2020-01-01', 'Class2'], $rootDir->createFilePath('Bar/Class2.php'), 11, 'Foo\\Bar\\Class2->publicMethod'); - $class3Tombstone = new Tombstone(['2020-01-01', 'Class3'], $rootDir->createFilePath('Bar/Class3.php'), 11, 'Foo\\Bar\\Class3->someOtherMethod'); - $deletedTombstone = new Tombstone(['2020-01-01', 'Class1'], $rootDir->createFilePath('Class1.php'), 18, 'Foo\\Class1->deletedMethod'); + $functionTombstone = new Tombstone('tombstone', ['2020-01-01', 'globalFunction'], $rootDir->createFilePath('functions.php'), 7, 'globalFunction'); + $globalScope = new Tombstone('tombstone', ['2020-01-01', 'globalScope'], $rootDir->createFilePath('functions.php'), 10, null); + $class1Tombstone = new Tombstone('tombstone', ['2020-01-01', 'Class1'], $rootDir->createFilePath('Class1.php'), 11, 'Foo\\Class1::staticMethod'); + $class2Tombstone = new Tombstone('tombstone', ['2020-01-01', 'Class2'], $rootDir->createFilePath('Bar/Class2.php'), 11, 'Foo\\Bar\\Class2->publicMethod'); + $class3Tombstone = new Tombstone('tombstone', ['2020-01-01', 'Class3'], $rootDir->createFilePath('Bar/Class3.php'), 11, 'Foo\\Bar\\Class3->someOtherMethod'); + $deletedTombstone = new Tombstone('tombstone', ['2020-01-01', 'Class1'], $rootDir->createFilePath('Class1.php'), 18, 'Foo\\Class1->deletedMethod'); $vampire1 = new Vampire('2020-02-01', 'invoker1', new StackTrace(), $globalScope, []); $globalScope->addVampire($vampire1); diff --git a/tests/Analyzer/Source/TombstoneExtractorTest.php b/tests/Analyzer/Source/TombstoneExtractorTest.php index d57083e..30a6ede 100644 --- a/tests/Analyzer/Source/TombstoneExtractorTest.php +++ b/tests/Analyzer/Source/TombstoneExtractorTest.php @@ -76,7 +76,7 @@ public function extractTombstones_tombstoneFound_addToTombstoneIndex(): void ->method('traverse') ->with($this->identicalTo($statements)) ->willReturnCallback(function (array $statements): array { - $this->extractor->onTombstoneFound(['args'], 123, 'method'); + $this->extractor->onTombstoneFound('tombstone', ['args'], 123, 'method'); return $statements; }); diff --git a/tests/Core/Format/AnalyzerLogFormatTest.php b/tests/Core/Format/AnalyzerLogFormatTest.php index 15adc72..a5880f9 100644 --- a/tests/Core/Format/AnalyzerLogFormatTest.php +++ b/tests/Core/Format/AnalyzerLogFormatTest.php @@ -13,7 +13,7 @@ class AnalyzerLogFormatTest extends TestCase { public const TOMBSTONE_ARGUMENTS = ['2014-01-01', 'label']; - public const LOG_RECORD = '{"v":10000,"a":["2014-01-01","label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"}'; + public const LOG_RECORD = '{"v":10000,"fn":"tombstone","a":["2014-01-01","label"],"f":"file","l":123,"m":"method","d":{"metaField":"metaValue"},"s":[{"f":"file1.php","l":11,"m":"ClassName->method"}],"id":"2015-01-01","im":"invoker"}'; /** * @test @@ -63,7 +63,7 @@ public function logToVampire_missingData_throwException(): void */ public function logToVampire_missingDataInStackTrace_truncateStackTrace(): void { - $returnValue = AnalyzerLogFormat::logToVampire('{"v":10000,"a":[],"f":"file","l":123,"s":[{"f":"file1","l":1},{"f":"file2"},{"f":"file3","l":3}],"id":"2015-01-01"}', new RootPath(__DIR__)); + $returnValue = AnalyzerLogFormat::logToVampire('{"v":10000,"fn":"tombstone","a":[],"f":"file","l":123,"s":[{"f":"file1","l":1},{"f":"file2"},{"f":"file3","l":3}],"id":"2015-01-01"}', new RootPath(__DIR__)); $this->assertCount(1, $returnValue->getStackTrace()); } diff --git a/tests/Core/Model/TombstoneTest.php b/tests/Core/Model/TombstoneTest.php index d0bf1fb..57a5a09 100644 --- a/tests/Core/Model/TombstoneTest.php +++ b/tests/Core/Model/TombstoneTest.php @@ -21,7 +21,7 @@ private function createTombstone(string $file, string ...$arguments): Tombstone { $rootPath = new RootPath(self::ROOT_DIR); - return new Tombstone($arguments, $rootPath->createFilePath($file), 123, 'method'); + return new Tombstone('tombstone', $arguments, $rootPath->createFilePath($file), 123, 'method'); } /** @@ -58,7 +58,7 @@ public function getHash_valuesSet_returnCorrectHash(): void { $tombstone = $this->createTombstone('file'); $hash = $tombstone->getHash(); - $this->assertEquals(596497885, $hash); + $this->assertEquals(1385567777, $hash); } /** diff --git a/tests/Core/Model/VampireTest.php b/tests/Core/Model/VampireTest.php index d51525e..6a481d6 100644 --- a/tests/Core/Model/VampireTest.php +++ b/tests/Core/Model/VampireTest.php @@ -63,6 +63,6 @@ public function getHash_valuesSet_returnCorrectHash(): void { $vampire = Fixture::getVampire(); $hash = $vampire->getHash(); - $this->assertEquals(1397077150, $hash); + $this->assertEquals(2405246921, $hash); } } diff --git a/tests/Fixture.php b/tests/Fixture.php index f7ef079..173e013 100644 --- a/tests/Fixture.php +++ b/tests/Fixture.php @@ -18,7 +18,7 @@ class Fixture public static function getVampire(string ...$arguments): Vampire { $rootPath = new RootPath(self::ROOT_DIR); - $tombstone = new Tombstone($arguments, $rootPath->createFilePath('file'), 123, 'method'); + $tombstone = new Tombstone('tombstone', $arguments, $rootPath->createFilePath('file'), 123, 'method'); $stackTrace = new StackTrace(new StackTraceFrame($rootPath->createFilePath('/path/to/file1.php'), 11, 'ClassName->method')); return new Vampire('2015-01-01', 'invoker', $stackTrace, $tombstone, ['metaField' => 'metaValue']); @@ -28,7 +28,7 @@ public static function getTombstone(string ...$arguments): Tombstone { $rootPath = new RootPath(self::ROOT_DIR); - return new Tombstone($arguments, $rootPath->createFilePath('file'), 123, 'method'); + return new Tombstone('tombstone', $arguments, $rootPath->createFilePath('file'), 123, 'method'); } public static function getTraceFixture(): array diff --git a/tests/Logger/Graveyard/BufferedGraveyardTest.php b/tests/Logger/Graveyard/BufferedGraveyardTest.php index 070e87f..629e354 100644 --- a/tests/Logger/Graveyard/BufferedGraveyardTest.php +++ b/tests/Logger/Graveyard/BufferedGraveyardTest.php @@ -37,7 +37,7 @@ public function tombstone_tombstoneInvoked_notAddToInnerGraveyard(): void ->expects($this->never()) ->method($this->anything()); - $this->graveyard->tombstone(['args'], ['trace1'], ['metaField' => 'metaValue']); + $this->graveyard->tombstone('tombstone', ['args'], ['trace1'], ['metaField' => 'metaValue']); } /** @@ -48,10 +48,10 @@ public function tombstone_autoFlushEnabled_directlyAddToInnerGraveyard(): void $this->innerGraveyard ->expects($this->once()) ->method('tombstone') - ->with(['args'], ['trace1'], ['metaField' => 'metaValue']); + ->with('tombstone', ['args'], ['trace1'], ['metaField' => 'metaValue']); $this->graveyard->setAutoFlush(true); - $this->graveyard->tombstone(['args'], ['trace1'], ['metaField' => 'metaValue']); + $this->graveyard->tombstone('tombstone', ['args'], ['trace1'], ['metaField' => 'metaValue']); } /** @@ -63,18 +63,18 @@ public function flush_tombstonesBuffered_addBufferedTombstonesAndFlush(): void ->expects($this->exactly(2)) ->method('tombstone') ->withConsecutive( - [['args'], ['trace1'], ['metaField' => 'metaValue1']], - [['args'], ['trace2'], ['metaField' => 'metaValue2']] + ['tombstone', ['args'], ['trace1'], ['metaField' => 'metaValue1']], + ['tombstone', ['args'], ['trace2'], ['metaField' => 'metaValue2']] ); $this->innerGraveyard ->expects($this->exactly(2)) ->method('flush'); - $this->graveyard->tombstone(['args'], ['trace1'], ['metaField' => 'metaValue1']); + $this->graveyard->tombstone('tombstone', ['args'], ['trace1'], ['metaField' => 'metaValue1']); $this->graveyard->flush(); - $this->graveyard->tombstone(['args'], ['trace2'], ['metaField' => 'metaValue2']); + $this->graveyard->tombstone('tombstone', ['args'], ['trace2'], ['metaField' => 'metaValue2']); $this->graveyard->flush(); } } diff --git a/tests/Logger/Graveyard/GraveyardBuilderTest.php b/tests/Logger/Graveyard/GraveyardBuilderTest.php index 6348934..f982dce 100644 --- a/tests/Logger/Graveyard/GraveyardBuilderTest.php +++ b/tests/Logger/Graveyard/GraveyardBuilderTest.php @@ -70,7 +70,7 @@ public function build_withHandler_logTombstonesToHandler(): void ->expects($this->once()) ->method('log'); - $graveyard->tombstone([], Fixture::getTraceFixture(), []); + $graveyard->tombstone('tombstone', [], Fixture::getTraceFixture(), []); } /** @@ -95,7 +95,7 @@ public function build_withLogger_logExceptionsToLogger(): void ->expects($this->once()) ->method('error'); - $graveyard->tombstone([], Fixture::getTraceFixture(), []); + $graveyard->tombstone('tombstone', [], Fixture::getTraceFixture(), []); } /** @@ -115,7 +115,7 @@ public function build_stackTraceDepthSet_logTruncatedStackTrace(): void ->stackTraceDepth(2) ->build(); - $graveyard->tombstone([], Fixture::getTraceFixture(), []); + $graveyard->tombstone('tombstone', [], Fixture::getTraceFixture(), []); } /** @@ -134,7 +134,7 @@ public function build_rootDirSet_logRelativePaths(): void ->withHandler($handler) ->build(); - $graveyard->tombstone([], Fixture::getTraceFixture(), []); + $graveyard->tombstone('tombstone', [], Fixture::getTraceFixture(), []); } /** diff --git a/tests/Logger/Graveyard/GraveyardTest.php b/tests/Logger/Graveyard/GraveyardTest.php index a567e4f..8ab69e6 100644 --- a/tests/Logger/Graveyard/GraveyardTest.php +++ b/tests/Logger/Graveyard/GraveyardTest.php @@ -72,10 +72,10 @@ public function tombstone_traceGiven_createVampire(): void $this->vampireFactory ->expects($this->once()) ->method('createFromCall') - ->with(['label'], $trace, ['metaField' => 'metaValue']) + ->with('tombstone', ['label'], $trace, ['metaField' => 'metaValue']) ->willReturn($this->createMock(Vampire::class)); - $this->graveyard->tombstone(['label'], $trace, ['metaField' => 'metaValue']); + $this->graveyard->tombstone('tombstone', ['label'], $trace, ['metaField' => 'metaValue']); } /** @@ -91,7 +91,7 @@ public function tombstone_handlersRegistered_callAllHandlers(): void ->with($this->identicalTo($vampire)); $trace = Fixture::getTraceFixture(); - $this->graveyard->tombstone(['label'], $trace, ['metaField' => 'metaValue']); + $this->graveyard->tombstone('tombstone', ['label'], $trace, ['metaField' => 'metaValue']); } /** @@ -112,7 +112,7 @@ public function tombstone_exceptionHappened_logError(): void ->with('Exception while tracking a tombstone call: Exception message (123)'); $trace = Fixture::getTraceFixture(); - $this->graveyard->tombstone([], $trace, []); + $this->graveyard->tombstone('tombstone', [], $trace, []); } /** diff --git a/tests/Logger/Graveyard/VampireFactoryTest.php b/tests/Logger/Graveyard/VampireFactoryTest.php index 23c4d96..bbc535f 100644 --- a/tests/Logger/Graveyard/VampireFactoryTest.php +++ b/tests/Logger/Graveyard/VampireFactoryTest.php @@ -24,7 +24,7 @@ public function createFromCall_dataGiven_returnCorrectlyConstructedVampire(): vo $stackTrace = Fixture::getTraceFixture(); $metadata = ['metaField' => 'metaValue']; - $vampire = $factory->createFromCall(['label', '2015-08-19'], $stackTrace, $metadata); + $vampire = $factory->createFromCall('tombstone', ['label', '2015-08-19'], $stackTrace, $metadata); $this->assertInstanceOf(Vampire::class, $vampire); $this->assertInstanceOf(Tombstone::class, $vampire->getTombstone()); @@ -57,7 +57,7 @@ public function createFromCall_rootDirSetMatchesFilePath_logRelativePath(): void $factory = new VampireFactory(new RootPath(Fixture::ROOT_DIR), self::LONG_STACK_TRACE_DEPTH); $stackTrace = Fixture::getTraceFixture(); - $vampire = $factory->createFromCall([], $stackTrace, []); + $vampire = $factory->createFromCall('tombstone', [], $stackTrace, []); $this->assertEquals('file1.php', $vampire->getFile()->getReferencePath()); @@ -75,7 +75,7 @@ public function createFromCall_rootDirNotMatchedFilePath_logAbsolutePath(): void $factory = new VampireFactory(new RootPath('/other/path'), self::LONG_STACK_TRACE_DEPTH); $stackTrace = Fixture::getTraceFixture(); - $vampire = $factory->createFromCall(['label'], $stackTrace, []); + $vampire = $factory->createFromCall('tombstone', ['label'], $stackTrace, []); $this->assertEquals('/path/to/file1.php', $vampire->getFile()->getAbsolutePath()); @@ -93,7 +93,7 @@ public function createFromCall_largeTrace_limitStackTrace(): void $factory = new VampireFactory(new RootPath(__DIR__), 2); $stackTrace = Fixture::getTraceFixture(); - $vampire = $factory->createFromCall([], $stackTrace, []); + $vampire = $factory->createFromCall('tombstone', [], $stackTrace, []); $stackTrace = $vampire->getStackTrace(); $this->assertCount(2, $stackTrace);