PHP 클래스 Google\Cloud\Dev\Snippet\Parser\Snippet

상속: implements JsonSerializable
파일 보기 프로젝트 열기: GoogleCloudPlatform/gcloud-php

공개 메소드들

메소드 설명
__construct ( string $identifier, array $config = [] ) Create a snippet
addLocal ( string $name, mixed $value ) : void Add a local variable to make available in the snippet execution scope.
addUse ( string $name ) : void Add a use statement for a class.
content ( ) : string The snippet content.
file ( ) : string The file in which the snippet is found.
identifier ( ) : string A unique identifier for the snippet.
index ( ) : integer The Snippet Index
insertAfterLine ( integer $line, string $content ) : void Inject new code after a given line.
invoke ( $returnVar = null ) : mixed Eval the snippet and return the result.
jsonSerialize ( )
line ( ) : integer The line number where the snippet's method or class is declared.
name ( ) : string The snippet name
regexReplace ( string $pattern, string $new ) : void Find something with a regex and replace it.
replace ( string $old, string $new ) : void Replace a string in the snippet with a new one.
setLine ( integer $line, string $content ) : void Replace a line with new code.

비공개 메소드들

메소드 설명
createReturnVar ( $returnVar )

메소드 상세

__construct() 공개 메소드

Create a snippet
public __construct ( string $identifier, array $config = [] )
$identifier string The snippet ID
$config array The snippet config

addLocal() 공개 메소드

Add a local variable to make available in the snippet execution scope.
public addLocal ( string $name, mixed $value ) : void
$name string The variable name
$value mixed The variable value
리턴 void

addUse() 공개 메소드

Add a use statement for a class.
public addUse ( string $name ) : void
$name string The class name to import.
리턴 void

content() 공개 메소드

The snippet content.
public content ( ) : string
리턴 string

file() 공개 메소드

The file in which the snippet is found.
public file ( ) : string
리턴 string

identifier() 공개 메소드

This identifier is deterministic and will remain constant unless the snippet is modified or moved.
public identifier ( ) : string
리턴 string

index() 공개 메소드

The Snippet Index
public index ( ) : integer
리턴 integer

insertAfterLine() 공개 메소드

Hopefully this is obvious, but be careful using this, and only use it when no other feasible options present themselves. It's pretty easy to make your test useless when you're modifying the thing you are trying to test. This is provided for cases when a snippet relies on a global, or on something else which can not be overridden or mocked.
public insertAfterLine ( integer $line, string $content ) : void
$line integer The line number (0-indexed) to write in after.
$content string The PHP code to inject.
리턴 void

invoke() 공개 메소드

Eval the snippet and return the result.
public invoke ( $returnVar = null ) : mixed
리턴 mixed

jsonSerialize() 공개 메소드

public jsonSerialize ( )

line() 공개 메소드

Note that this is NOT the line number where the snippet is declared. It indicates the method or class which the snippet annotates.
public line ( ) : integer
리턴 integer

name() 공개 메소드

The snippet name
public name ( ) : string
리턴 string

regexReplace() 공개 메소드

Hopefully this is obvious, but be careful using this, and only use it when no other feasible options present themselves. It's pretty easy to make your test useless when you're modifying the thing you are trying to test. This is provided for cases when a snippet relies on a global, or on something else which can not be overridden or mocked.
public regexReplace ( string $pattern, string $new ) : void
$pattern string The regex pattern to search for.
$new string The new string to insert.
리턴 void

replace() 공개 메소드

Hopefully this is obvious, but be careful using this, and only use it when no other feasible options present themselves. It's pretty easy to make your test useless when you're modifying the thing you are trying to test. This is provided for cases when a snippet relies on a global, or on something else which can not be overridden or mocked.
public replace ( string $old, string $new ) : void
$old string The string to be replaced.
$new string The new string to insert.
리턴 void

setLine() 공개 메소드

Hopefully this is obvious, but be careful using this, and only use it when no other feasible options present themselves. It's pretty easy to make your test useless when you're overwriting the thing you are trying to test. This is provided for cases when a snippet relies on a global, or on something else which can not be overridden or mocked.
public setLine ( integer $line, string $content ) : void
$line integer The line number (0-indexed) to replace.
$content string The PHP code to inject.
리턴 void