Skip to content

Latest commit

 

History

History
290 lines (201 loc) · 5.25 KB

Stream.md

File metadata and controls

290 lines (201 loc) · 5.25 KB

Stream

  • class Stream (php\io\Stream)
  • package std
  • source php/io/Stream.php

Child Classes

FileStream, MiscStream, ResourceStream, NetStream

Description

Class Stream


Properties


Static Methods

  • Stream ::of()
  • Stream ::getContents() - Create a stream, call and return the result of the readFully() method, finally call the close() method.
  • Stream ::putContents() - Create a stream, call and return the result of the write() method, finally call the close() method.
  • Stream ::tryAccess() - Open a stream and close it after calling $onAccess automatically.
  • Stream ::exists() - Checks stream is exists. It tries to open a stream and if all is ok, returns true and closes it.
  • Stream ::register()
  • Stream ::unregister()

Methods


Static Methods

of()

Stream::of(string $path, string $mode): Stream

getContents()

Stream::getContents(string $path, string $mode): string

Create a stream, call and return the result of the readFully() method, finally call the close() method.


putContents()

Stream::putContents(string $path, string $data, string $mode): void

Create a stream, call and return the result of the write() method, finally call the close() method.


tryAccess()

Stream::tryAccess(string $path, callable $onAccess, string $mode): void

Open a stream and close it after calling $onAccess automatically.


exists()

Stream::exists(string $path): bool

Checks stream is exists. It tries to open a stream and if all is ok, returns true and closes it.


register()

Stream::register(string $protocol, string $className): void

unregister()

Stream::unregister(mixed $protocol): void

Methods

getPath()

getPath(): string

getMode()

getMode(): string

read()

read(int $length): mixed

readFully()

readFully(): mixed

readAll()

readAll(): mixed

Alias of readFully().


write()

write(string $value, null|int $length): int

parseAs()

parseAs(string $format, int $flags): mixed

Alias of readFormatted().


readFormatted()

readFormatted(string $format, int $flags): mixed

writeFormatted()

writeFormatted(mixed $value, string $format, int $flags): mixed

eof()

eof(): bool

seek()

seek(int $position): mixed

getPosition()

getPosition(): int

close()

close(): mixed

__construct()

__construct(string $path, null|string $mode): Stream

setContext()

setContext(mixed $context): void

getContext()

getContext(): mixed

__toString()

__toString(): string

Alias of readFully() with converting to string always.


eachLine()

eachLine(callable $callback, string|null $encoding): void

Each line of stream.