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|null $alias = null, string $of = PhpNamespace::NameNormal)

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 94
GlobalFunction addFunction(string $name)

No description

Parameters

string $name

Return Value

GlobalFunction

at line 103
array getNamespaces()

No description

Return Value

array

at line 110
array getClasses()

No description

Return Value

array

at line 125
array getFunctions()

No description

Return Value

array

at line 140
PhpFile addUse(string $name, string|null $alias = null, string $of = PhpNamespace::NameNormal)

No description

Parameters

string $name
string|null $alias
string $of

Return Value

PhpFile

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

Adds declare(strict_types=1) to output.

Parameters

bool $on

Return Value

PhpFile

at line 158
bool hasStrictTypes()

No description

Return Value

bool

at line 165
bool getStrictTypes() deprecated

deprecated use hasStrictTypes()

No description

Return Value

bool

at line 171
string __toString()

No description

Return Value

string

Traits

SmartObject