final class PhpFile

Instance of PHP file.

Generates:

  • opening tag (<?php)
  • doc comments
  • one or more namespaces

Methods

static PhpFile
fromCode(string $code)

No description

addClass(string $name)

No description

addInterface(string $name)

No description

addTrait(string $name)

No description

addEnum(string $name)

No description

addNamespace(string|PhpNamespace $namespace)

No description

addFunction(string $name)

No description

array
getNamespaces()

No description

array
getClasses()

No description

array
getFunctions()

No description

addUse(string $name, string $alias = null, string $of = PhpNamespace::NAME_NORMAL)

No description

setStrictTypes(bool $on = true)

Adds declare(strict_types=1) to output.

bool
hasStrictTypes()

No description

bool
getStrictTypes() deprecated

No description

string
__toString()

No description

Details

at line 35
static PhpFile fromCode(string $code)

No description

Parameters

string $code

Return Value

PhpFile

at line 41
ClassType addClass(string $name)

No description

Parameters

string $name

Return Value

ClassType

at line 49
ClassType addInterface(string $name)

No description

Parameters

string $name

Return Value

ClassType

at line 57
ClassType addTrait(string $name)

No description

Parameters

string $name

Return Value

ClassType

at line 65
ClassType addEnum(string $name)

No description

Parameters

string $name

Return Value

ClassType

at line 74
PhpNamespace addNamespace(string|PhpNamespace $namespace)

No description

Parameters

string|PhpNamespace $namespace

Return Value

PhpNamespace

at line 93
GlobalFunction addFunction(string $name)

No description

Parameters

string $name

Return Value

GlobalFunction

at line 102
array getNamespaces()

No description

Return Value

array

at line 109
array getClasses()

No description

Return Value

array

at line 123
array getFunctions()

No description

Return Value

array

at line 137
PhpFile addUse(string $name, string $alias = null, string $of = PhpNamespace::NAME_NORMAL)

No description

Parameters

string $name
string $alias
string $of

Return Value

PhpFile

at line 148
PhpFile setStrictTypes(bool $on = true)

Adds declare(strict_types=1) to output.

Parameters

bool $on

Return Value

PhpFile

at line 155
bool hasStrictTypes()

No description

Return Value

bool

at line 162
bool getStrictTypes() deprecated

deprecated use hasStrictTypes()

No description

Return Value

bool

at line 168
string __toString()

No description

Return Value

string

Traits

SmartObject