public function __construct($stream, $source = null)
{
if (!is_resource($stream)) {
throw new InvalidArgumentException("Stream should be valid resource");
}
$metadata = stream_get_meta_data($stream);
if ($source) {
$metadata['source'] = $source;
}
if (preg_match('/resource=(.+)$/', $metadata['uri'], $matches)) {
$metadata['uri'] = PathResolver::realpath($matches[1]);
}
parent::__construct($metadata, ArrayObject::ARRAY_AS_PROPS);
}