class JsonParsedDataStorage implements ParsedDataPersistentStorageProvider (View source)

JSON storage for parsed entities.

Handles file I/O operations while delegating serialization to a pluggable serializer. Optionally coordinates with PhpDocStorage for separated PhpDoc storage.

Methods

__construct(string $pathToJsonFile, EntitySerializerInterface $serializer, bool $loadExisting = true, PhpDocStorage|null $phpDocStorage = null, bool $ownsPhpDocStorage = true)

No description

array
getEntities()

No description

void
addEntity(mixed $entity)

No description

void
clearEntities()

No description

void
save()

Save entities to persistent storage

void
load()

Load entities from the cache file.

Details

__construct(string $pathToJsonFile, EntitySerializerInterface $serializer, bool $loadExisting = true, PhpDocStorage|null $phpDocStorage = null, bool $ownsPhpDocStorage = true)

No description

Parameters

string $pathToJsonFile

Path to JSON file

EntitySerializerInterface $serializer

Serializer to use (StubsEntitySerializer or ReflectionEntitySerializer)

bool $loadExisting

Whether to load existing file

PhpDocStorage|null $phpDocStorage

Optional PhpDoc storage for separated PhpDoc

bool $ownsPhpDocStorage

Whether this storage is responsible for saving PhpDocStorage

array getEntities()

No description

Return Value

array

void addEntity(mixed $entity)

No description

Parameters

mixed $entity

Return Value

void

void clearEntities()

No description

Return Value

void

void save()

Save entities to persistent storage

Return Value

void

void load()

Load entities from the cache file.

A missing file yields no entities and is not an error: callers decide whether to regenerate (see Runner::isStubsCacheComplete()), and MultiFileJsonStorage constructs a storage per entity type whether or not every file has been written yet.

A file that exists but cannot be read as JSON is a different matter and throws. Returning no entities there is indistinguishable from a legitimately empty cache, and the consequences are silent: a truncated StubsClasses.json yielded zero classes while the other four type files loaded normally, so every class-level check iterated an empty list and reported success. The suite stayed green while validating nothing. This happened — commit 51b2a776 carried a 2.3 MB prefix of a 20.4 MB file.

Return Value

void

Exceptions

RuntimeException