2020-08-10 16:49:53 +02:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Test\Config\Plugin\Hook;
|
|
|
|
|
2021-01-06 15:05:53 +01:00
|
|
|
use Psalm\Plugin\EventHandler\AfterFileAnalysisInterface;
|
|
|
|
use Psalm\Plugin\EventHandler\BeforeFileAnalysisInterface;
|
|
|
|
use Psalm\Plugin\EventHandler\Event\AfterFileAnalysisEvent;
|
|
|
|
use Psalm\Plugin\EventHandler\Event\BeforeFileAnalysisEvent;
|
2020-08-10 16:49:53 +02:00
|
|
|
|
|
|
|
class FileProvider implements
|
|
|
|
AfterFileAnalysisInterface,
|
|
|
|
BeforeFileAnalysisInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Called before a file has been checked
|
|
|
|
*/
|
2021-01-06 15:05:53 +01:00
|
|
|
public static function beforeAnalyzeFile(BeforeFileAnalysisEvent $event): void
|
|
|
|
{
|
|
|
|
$codebase = $event->getCodebase();
|
|
|
|
$statements_source = $event->getStatementsSource();
|
2020-08-10 16:49:53 +02:00
|
|
|
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
|
|
|
|
$file_storage->custom_metadata['before-analysis'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before a file has been checked
|
|
|
|
*/
|
2021-01-06 15:05:53 +01:00
|
|
|
public static function afterAnalyzeFile(AfterFileAnalysisEvent $event): void
|
|
|
|
{
|
|
|
|
$codebase = $event->getCodebase();
|
|
|
|
$statements_source = $event->getStatementsSource();
|
2020-08-10 16:49:53 +02:00
|
|
|
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
|
|
|
|
$file_storage->custom_metadata['after-analysis'] = true;
|
|
|
|
}
|
|
|
|
}
|