1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/tests/Config/Plugin/Hook/FileProvider.php

41 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace Psalm\Test\Config\Plugin\Hook;
use Psalm\Codebase;
use Psalm\Context;
use Psalm\Plugin\Hook\AfterFileAnalysisInterface;
use Psalm\Plugin\Hook\BeforeFileAnalysisInterface;
use Psalm\StatementsSource;
use Psalm\Storage\FileStorage;
class FileProvider implements
AfterFileAnalysisInterface,
BeforeFileAnalysisInterface
{
/**
* Called before a file has been checked
*/
public static function beforeAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
): void {
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
$file_storage->custom_metadata['before-analysis'] = true;
}
/**
* Called before a file has been checked
*/
public static function afterAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
): void {
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
$file_storage->custom_metadata['after-analysis'] = true;
}
}