id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
222,200
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.depth
|
public function depth()
{
$depth = substr_count($this->_name, '.');
$depth += substr_count($this->_name, '\\');
$depth += substr_count($this->_name, '/');
return $depth;
}
|
php
|
public function depth()
{
$depth = substr_count($this->_name, '.');
$depth += substr_count($this->_name, '\\');
$depth += substr_count($this->_name, '/');
return $depth;
}
|
[
"public",
"function",
"depth",
"(",
")",
"{",
"$",
"depth",
"=",
"substr_count",
"(",
"$",
"this",
"->",
"_name",
",",
"'.'",
")",
";",
"$",
"depth",
"+=",
"substr_count",
"(",
"$",
"this",
"->",
"_name",
",",
"'\\\\'",
")",
";",
"$",
"depth",
"+=",
"substr_count",
"(",
"$",
"this",
"->",
"_name",
",",
"'/'",
")",
";",
"return",
"$",
"depth",
";",
"}"
] |
Calculate the depth of this package from the root.
@return int
|
[
"Calculate",
"the",
"depth",
"of",
"this",
"package",
"from",
"the",
"root",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L95-L102
|
222,201
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.addClass
|
public function addClass(&$class)
{
if (isset($this->_classes[$class->name()])) {
$phpdoctor =& $this->_root->phpdoctor();
echo "\n";
$phpdoctor->warning('Found class '.$class->name().' again, overwriting previous version');
}
$this->_classes[$class->name()] =& $class;
}
|
php
|
public function addClass(&$class)
{
if (isset($this->_classes[$class->name()])) {
$phpdoctor =& $this->_root->phpdoctor();
echo "\n";
$phpdoctor->warning('Found class '.$class->name().' again, overwriting previous version');
}
$this->_classes[$class->name()] =& $class;
}
|
[
"public",
"function",
"addClass",
"(",
"&",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_classes",
"[",
"$",
"class",
"->",
"name",
"(",
")",
"]",
")",
")",
"{",
"$",
"phpdoctor",
"=",
"&",
"$",
"this",
"->",
"_root",
"->",
"phpdoctor",
"(",
")",
";",
"echo",
"\"\\n\"",
";",
"$",
"phpdoctor",
"->",
"warning",
"(",
"'Found class '",
".",
"$",
"class",
"->",
"name",
"(",
")",
".",
"' again, overwriting previous version'",
")",
";",
"}",
"$",
"this",
"->",
"_classes",
"[",
"$",
"class",
"->",
"name",
"(",
")",
"]",
"=",
"&",
"$",
"class",
";",
"}"
] |
Add a class to this package.
@param ClassDoc class
|
[
"Add",
"a",
"class",
"to",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L108-L116
|
222,202
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.addFunction
|
public function addFunction(&$function)
{
if (isset($this->_functions[$function->name()])) {
$phpdoctor =& $this->_root->phpdoctor();
echo "\n";
$phpdoctor->warning('Found function '.$function->name().' again, overwriting previous version');
}
$this->_functions[$function->name()] =& $function;
}
|
php
|
public function addFunction(&$function)
{
if (isset($this->_functions[$function->name()])) {
$phpdoctor =& $this->_root->phpdoctor();
echo "\n";
$phpdoctor->warning('Found function '.$function->name().' again, overwriting previous version');
}
$this->_functions[$function->name()] =& $function;
}
|
[
"public",
"function",
"addFunction",
"(",
"&",
"$",
"function",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_functions",
"[",
"$",
"function",
"->",
"name",
"(",
")",
"]",
")",
")",
"{",
"$",
"phpdoctor",
"=",
"&",
"$",
"this",
"->",
"_root",
"->",
"phpdoctor",
"(",
")",
";",
"echo",
"\"\\n\"",
";",
"$",
"phpdoctor",
"->",
"warning",
"(",
"'Found function '",
".",
"$",
"function",
"->",
"name",
"(",
")",
".",
"' again, overwriting previous version'",
")",
";",
"}",
"$",
"this",
"->",
"_functions",
"[",
"$",
"function",
"->",
"name",
"(",
")",
"]",
"=",
"&",
"$",
"function",
";",
"}"
] |
Add a function to this package.
@param MethodDoc function
|
[
"Add",
"a",
"function",
"to",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L133-L141
|
222,203
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.&
|
function &exceptions()
{
$exceptions = NULL;
foreach ($this->_classes as $name => $exception) {
if ($exception->isException()) {
$exceptions[$name] =& $this->_classes[$name];
}
}
return $exceptions;
}
|
php
|
function &exceptions()
{
$exceptions = NULL;
foreach ($this->_classes as $name => $exception) {
if ($exception->isException()) {
$exceptions[$name] =& $this->_classes[$name];
}
}
return $exceptions;
}
|
[
"function",
"&",
"exceptions",
"(",
")",
"{",
"$",
"exceptions",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"this",
"->",
"_classes",
"as",
"$",
"name",
"=>",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"exception",
"->",
"isException",
"(",
")",
")",
"{",
"$",
"exceptions",
"[",
"$",
"name",
"]",
"=",
"&",
"$",
"this",
"->",
"_classes",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"exceptions",
";",
"}"
] |
Get exceptions in this package.
@return ClassDoc[] An array of exceptions
|
[
"Get",
"exceptions",
"in",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L156-L166
|
222,204
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.&
|
function &interfaces()
{
$interfaces = NULL;
foreach ($this->_classes as $name => $interface) {
if ($interface->isInterface()) {
$interfaces[$name] =& $this->_classes[$name];
}
}
return $interfaces;
}
|
php
|
function &interfaces()
{
$interfaces = NULL;
foreach ($this->_classes as $name => $interface) {
if ($interface->isInterface()) {
$interfaces[$name] =& $this->_classes[$name];
}
}
return $interfaces;
}
|
[
"function",
"&",
"interfaces",
"(",
")",
"{",
"$",
"interfaces",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"this",
"->",
"_classes",
"as",
"$",
"name",
"=>",
"$",
"interface",
")",
"{",
"if",
"(",
"$",
"interface",
"->",
"isInterface",
"(",
")",
")",
"{",
"$",
"interfaces",
"[",
"$",
"name",
"]",
"=",
"&",
"$",
"this",
"->",
"_classes",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"interfaces",
";",
"}"
] |
Get interfaces in this package.
@return ClassDoc[] An array of interfaces
|
[
"Get",
"interfaces",
"in",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L172-L182
|
222,205
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.&
|
function &traits()
{
$traits = NULL;
foreach ($this->_classes as $name => $trait) {
if ($trait->isTrait()) {
$traits[$name] =& $this->_classes[$name];
}
}
return $traits;
}
|
php
|
function &traits()
{
$traits = NULL;
foreach ($this->_classes as $name => $trait) {
if ($trait->isTrait()) {
$traits[$name] =& $this->_classes[$name];
}
}
return $traits;
}
|
[
"function",
"&",
"traits",
"(",
")",
"{",
"$",
"traits",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"this",
"->",
"_classes",
"as",
"$",
"name",
"=>",
"$",
"trait",
")",
"{",
"if",
"(",
"$",
"trait",
"->",
"isTrait",
"(",
")",
")",
"{",
"$",
"traits",
"[",
"$",
"name",
"]",
"=",
"&",
"$",
"this",
"->",
"_classes",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"traits",
";",
"}"
] |
Get traits in this package.
@return ClassDoc[] An array of traits
|
[
"Get",
"traits",
"in",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L188-L198
|
222,206
|
peej/phpdoctor
|
classes/packageDoc.php
|
packageDoc.&
|
function &findClass($className)
{
$return = NULL;
if (isset($this->_classes[$className])) {
$return =& $this->_classes[$className];
}
return $return;
}
|
php
|
function &findClass($className)
{
$return = NULL;
if (isset($this->_classes[$className])) {
$return =& $this->_classes[$className];
}
return $return;
}
|
[
"function",
"&",
"findClass",
"(",
"$",
"className",
")",
"{",
"$",
"return",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_classes",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"return",
"=",
"&",
"$",
"this",
"->",
"_classes",
"[",
"$",
"className",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Lookup for a class within this package.
@param str className Name of the class to lookup
@return ClassDoc A class
|
[
"Lookup",
"for",
"a",
"class",
"within",
"this",
"package",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/packageDoc.php#L239-L247
|
222,207
|
peej/phpdoctor
|
classes/doc.php
|
doc.set
|
public function set($member, $value)
{
$member = '_'.$member;
$members = get_object_vars($this);
if (array_key_exists($member, $members)) {
if (is_array($this->$member)) {
$this->{$member}[] = $value;
} else {
$this->$member = $value;
}
return TRUE;
}
return FALSE;
}
|
php
|
public function set($member, $value)
{
$member = '_'.$member;
$members = get_object_vars($this);
if (array_key_exists($member, $members)) {
if (is_array($this->$member)) {
$this->{$member}[] = $value;
} else {
$this->$member = $value;
}
return TRUE;
}
return FALSE;
}
|
[
"public",
"function",
"set",
"(",
"$",
"member",
",",
"$",
"value",
")",
"{",
"$",
"member",
"=",
"'_'",
".",
"$",
"member",
";",
"$",
"members",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"member",
",",
"$",
"members",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"$",
"member",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"member",
"}",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"$",
"member",
"=",
"$",
"value",
";",
"}",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Setter method.
@param str member Name of the member to set
@param mixed value The value to set member to
@return bool
|
[
"Setter",
"method",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/doc.php#L76-L91
|
222,208
|
peej/phpdoctor
|
classes/doc.php
|
doc.getFileContents
|
public function getFileContents($filename)
{
if ($contents = file_get_contents($filename)) {
if (preg_match('/<body ?.*?>(.+)<\/body>/s', $contents, $matches)) {
return $matches[1];
} else { // it's not HTML, so output it as plain text
return $contents;
}
}
return FALSE;
}
|
php
|
public function getFileContents($filename)
{
if ($contents = file_get_contents($filename)) {
if (preg_match('/<body ?.*?>(.+)<\/body>/s', $contents, $matches)) {
return $matches[1];
} else { // it's not HTML, so output it as plain text
return $contents;
}
}
return FALSE;
}
|
[
"public",
"function",
"getFileContents",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/<body ?.*?>(.+)<\\/body>/s'",
",",
"$",
"contents",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"// it's not HTML, so output it as plain text",
"return",
"$",
"contents",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] |
Get body of a text document
@param str filename
@return str
|
[
"Get",
"body",
"of",
"a",
"text",
"document"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/doc.php#L351-L361
|
222,209
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.addConstant
|
public function addConstant(&$constant)
{
if (!isset($this->_constants[$constant->name()])) {
$this->_constants[$constant->name()] =& $constant;
}
}
|
php
|
public function addConstant(&$constant)
{
if (!isset($this->_constants[$constant->name()])) {
$this->_constants[$constant->name()] =& $constant;
}
}
|
[
"public",
"function",
"addConstant",
"(",
"&",
"$",
"constant",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_constants",
"[",
"$",
"constant",
"->",
"name",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_constants",
"[",
"$",
"constant",
"->",
"name",
"(",
")",
"]",
"=",
"&",
"$",
"constant",
";",
"}",
"}"
] |
Add a constant to this class.
@param FieldDoc field
|
[
"Add",
"a",
"constant",
"to",
"this",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L107-L112
|
222,210
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.addField
|
public function addField(&$field)
{
if (!isset($this->_fields[$field->name()])) {
$this->_fields[$field->name()] =& $field;
}
}
|
php
|
public function addField(&$field)
{
if (!isset($this->_fields[$field->name()])) {
$this->_fields[$field->name()] =& $field;
}
}
|
[
"public",
"function",
"addField",
"(",
"&",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_fields",
"[",
"$",
"field",
"->",
"name",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_fields",
"[",
"$",
"field",
"->",
"name",
"(",
")",
"]",
"=",
"&",
"$",
"field",
";",
"}",
"}"
] |
Add a field to this class.
@param FieldDoc field
|
[
"Add",
"a",
"field",
"to",
"this",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L118-L123
|
222,211
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.&
|
function &fieldNamed($fieldName)
{
$return = NULL;
if (isset($this->_fields[$fieldName])) {
$return =& $this->_fields[$fieldName];
}
return $return;
}
|
php
|
function &fieldNamed($fieldName)
{
$return = NULL;
if (isset($this->_fields[$fieldName])) {
$return =& $this->_fields[$fieldName];
}
return $return;
}
|
[
"function",
"&",
"fieldNamed",
"(",
"$",
"fieldName",
")",
"{",
"$",
"return",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_fields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"return",
"=",
"&",
"$",
"this",
"->",
"_fields",
"[",
"$",
"fieldName",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return a field in this class.
@return FieldDoc
|
[
"Return",
"a",
"field",
"in",
"this",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L161-L169
|
222,212
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.&
|
function &methods($regularOnly = FALSE)
{
if ($regularOnly) {
$return = array();
foreach ($this->_methods as $method) {
if (!$method->isConstructor() && !$method->isDestructor()) {
$return[] = $method;
}
}
} else {
$return = $this->_methods;
}
return $return;
}
|
php
|
function &methods($regularOnly = FALSE)
{
if ($regularOnly) {
$return = array();
foreach ($this->_methods as $method) {
if (!$method->isConstructor() && !$method->isDestructor()) {
$return[] = $method;
}
}
} else {
$return = $this->_methods;
}
return $return;
}
|
[
"function",
"&",
"methods",
"(",
"$",
"regularOnly",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"regularOnly",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_methods",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"$",
"method",
"->",
"isConstructor",
"(",
")",
"&&",
"!",
"$",
"method",
"->",
"isDestructor",
"(",
")",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"method",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"_methods",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return the methods in this class.
@param bool regularOnly Do not return constructors and destructors
@return MethodDoc[]
|
[
"Return",
"the",
"methods",
"in",
"this",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L176-L190
|
222,213
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.&
|
function &methodNamed($methodName)
{
$return = NULL;
if (isset($this->_methods[$methodName])) {
$return =& $this->_methods[$methodName];
}
return $return;
}
|
php
|
function &methodNamed($methodName)
{
$return = NULL;
if (isset($this->_methods[$methodName])) {
$return =& $this->_methods[$methodName];
}
return $return;
}
|
[
"function",
"&",
"methodNamed",
"(",
"$",
"methodName",
")",
"{",
"$",
"return",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_methods",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"$",
"return",
"=",
"&",
"$",
"this",
"->",
"_methods",
"[",
"$",
"methodName",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return a method in this class.
@return MethodDoc
|
[
"Return",
"a",
"method",
"in",
"this",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L196-L204
|
222,214
|
peej/phpdoctor
|
classes/classDoc.php
|
classDoc.subclasses
|
public function subclasses()
{
$return = array();
foreach ($this->_root->classes() as $classDoc) {
if ($classDoc->subclassOf($this)) {
$return[] = $classDoc;
}
}
return $return;
}
|
php
|
public function subclasses()
{
$return = array();
foreach ($this->_root->classes() as $classDoc) {
if ($classDoc->subclassOf($this)) {
$return[] = $classDoc;
}
}
return $return;
}
|
[
"public",
"function",
"subclasses",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_root",
"->",
"classes",
"(",
")",
"as",
"$",
"classDoc",
")",
"{",
"if",
"(",
"$",
"classDoc",
"->",
"subclassOf",
"(",
"$",
"this",
")",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"classDoc",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return the known subclasses of this class
@return classDoc[]
|
[
"Return",
"the",
"known",
"subclasses",
"of",
"this",
"class"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/classDoc.php#L375-L385
|
222,215
|
peej/phpdoctor
|
classes/fieldDoc.php
|
fieldDoc.typeAsString
|
public function typeAsString()
{
$myPackage =& $this->containingPackage();
$classDoc =& $this->_type->asClassDoc();
if ($classDoc) {
$packageDoc =& $classDoc->containingPackage();
return '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->name().$this->_type->dimension().'</a>';
} else {
return $this->_type->typeName().$this->_type->dimension();
}
}
|
php
|
public function typeAsString()
{
$myPackage =& $this->containingPackage();
$classDoc =& $this->_type->asClassDoc();
if ($classDoc) {
$packageDoc =& $classDoc->containingPackage();
return '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->name().$this->_type->dimension().'</a>';
} else {
return $this->_type->typeName().$this->_type->dimension();
}
}
|
[
"public",
"function",
"typeAsString",
"(",
")",
"{",
"$",
"myPackage",
"=",
"&",
"$",
"this",
"->",
"containingPackage",
"(",
")",
";",
"$",
"classDoc",
"=",
"&",
"$",
"this",
"->",
"_type",
"->",
"asClassDoc",
"(",
")",
";",
"if",
"(",
"$",
"classDoc",
")",
"{",
"$",
"packageDoc",
"=",
"&",
"$",
"classDoc",
"->",
"containingPackage",
"(",
")",
";",
"return",
"'<a href=\"'",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"myPackage",
"->",
"depth",
"(",
")",
"+",
"1",
")",
".",
"$",
"classDoc",
"->",
"asPath",
"(",
")",
".",
"'\">'",
".",
"$",
"classDoc",
"->",
"name",
"(",
")",
".",
"$",
"this",
"->",
"_type",
"->",
"dimension",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_type",
"->",
"typeName",
"(",
")",
".",
"$",
"this",
"->",
"_type",
"->",
"dimension",
"(",
")",
";",
"}",
"}"
] |
Format a field type for outputting. Recognised types are turned into
HTML anchor tags to the documentation page for the class defining them.
@return str The string representation of the field type
|
[
"Format",
"a",
"field",
"type",
"for",
"outputting",
".",
"Recognised",
"types",
"are",
"turned",
"into",
"HTML",
"anchor",
"tags",
"to",
"the",
"documentation",
"page",
"for",
"the",
"class",
"defining",
"them",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/fieldDoc.php#L105-L116
|
222,216
|
thedevsaddam/laravel-schema
|
src/Schema/Helper.php
|
Helper.getValueIfExist
|
public function getValueIfExist($queries, $keyString)
{
foreach ($queries as $query) {
if ($query->Variable_name == $keyString) {
return $query->Value;
}
}
}
|
php
|
public function getValueIfExist($queries, $keyString)
{
foreach ($queries as $query) {
if ($query->Variable_name == $keyString) {
return $query->Value;
}
}
}
|
[
"public",
"function",
"getValueIfExist",
"(",
"$",
"queries",
",",
"$",
"keyString",
")",
"{",
"foreach",
"(",
"$",
"queries",
"as",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"->",
"Variable_name",
"==",
"$",
"keyString",
")",
"{",
"return",
"$",
"query",
"->",
"Value",
";",
"}",
"}",
"}"
] |
Fetch queries value if key exist
@param $queries
@param $keyString
@return mixed
|
[
"Fetch",
"queries",
"value",
"if",
"key",
"exist"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Schema/Helper.php#L86-L93
|
222,217
|
petercoles/Betfair-Exchange
|
src/Api/Betting.php
|
Betting.prepare
|
public function prepare($params)
{
$this->params = !empty($params) ? $params[ 0 ] : [ ];
// force mandatory fields
$this->filter();
$this->maxRecords();
}
|
php
|
public function prepare($params)
{
$this->params = !empty($params) ? $params[ 0 ] : [ ];
// force mandatory fields
$this->filter();
$this->maxRecords();
}
|
[
"public",
"function",
"prepare",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"!",
"empty",
"(",
"$",
"params",
")",
"?",
"$",
"params",
"[",
"0",
"]",
":",
"[",
"]",
";",
"// force mandatory fields",
"$",
"this",
"->",
"filter",
"(",
")",
";",
"$",
"this",
"->",
"maxRecords",
"(",
")",
";",
"}"
] |
Prepare parameters for API requests, ensuring the mandatory requirments are satisfied
@param array $params
|
[
"Prepare",
"parameters",
"for",
"API",
"requests",
"ensuring",
"the",
"mandatory",
"requirments",
"are",
"satisfied"
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Betting.php#L19-L26
|
222,218
|
petercoles/Betfair-Exchange
|
src/Api/Betting.php
|
Betting.filter
|
protected function filter()
{
$lists = [
'listCompetitions',
'listCountries',
'listEvents',
'listEventTypes',
'listMarketTypes',
'listVenues',
'listMarketCatalogue'
];
if (in_array($this->method, $lists) && empty($this->params[ 'filter' ])) {
$this->params[ 'filter' ] = new \stdClass;
}
}
|
php
|
protected function filter()
{
$lists = [
'listCompetitions',
'listCountries',
'listEvents',
'listEventTypes',
'listMarketTypes',
'listVenues',
'listMarketCatalogue'
];
if (in_array($this->method, $lists) && empty($this->params[ 'filter' ])) {
$this->params[ 'filter' ] = new \stdClass;
}
}
|
[
"protected",
"function",
"filter",
"(",
")",
"{",
"$",
"lists",
"=",
"[",
"'listCompetitions'",
",",
"'listCountries'",
",",
"'listEvents'",
",",
"'listEventTypes'",
",",
"'listMarketTypes'",
",",
"'listVenues'",
",",
"'listMarketCatalogue'",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"method",
",",
"$",
"lists",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'filter'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"'filter'",
"]",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"}"
] |
Ensure that a filter parameter is passed where mandatory
|
[
"Ensure",
"that",
"a",
"filter",
"parameter",
"is",
"passed",
"where",
"mandatory"
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Betting.php#L31-L46
|
222,219
|
peej/phpdoctor
|
formatters/htmlStandardFormatter.php
|
htmlStandardFormatter._addListMarkupUL
|
public function _addListMarkupUL($txt)
{
// Create unordered lists. -, +, # and o are recogized as bullet points
// $li_rx: regex capturing a list entry, including those extending over multiple lines and
// those padded with empty lines
// $ul_rx: regex capturing an unordered list - at least two list entries required
$li_rx = '^([ \t]+([\-+#o])[ \t]+)(\S.*(?:\n [ \t]+(?!\2)(?![ \t]).*|\n[ \t]*)*\n)';
$ul_rx = "(?:$li_rx){2,}";
$txt = preg_replace("/$ul_rx/m", "\n\n<ul>\n$0\n</ul>\n\n", $txt);
if (preg_match_all("%<ul>.*?</ul>%s", $txt, $outerLists)) {
$lists = preg_replace("/$li_rx/m", "<li>$3</li>", $outerLists[0]);
$txt = str_replace($outerLists[0], $lists, $txt);
// Cleanup: Making sure that the lists won't appear inside a <p> (by removing double newlines around ul tags)
// and won't have empty paragraphs in between list items (by removing double newlines between different li tags).
$txt = preg_replace('%\s*<ul>\s*(<li>.+?</li>)\s*</ul>\s*%s', "<ul>\n$1\n</ul>", $txt);
$txt = preg_replace('%\s*</li>\s*%', "</li>\n", $txt);
// Inside <li>s which contain multiple paragraphs, use <p>s with a css hook.
preg_match_all("%<li>.*?</li>%s", $txt, $items);
$adjustedItems = preg_replace("%[ \t]*\n[ \t]*\n[ \t]*%", '</p><p class="list">', $items[0]);
$adjustedItems = preg_replace('%^<li>(.*?</p><p class="list">.*?)</li>$%s', "<li><p class=\"list\">$1</p></li>", $adjustedItems);
$txt = str_replace($items[0], $adjustedItems, $txt);
}
return $txt;
}
|
php
|
public function _addListMarkupUL($txt)
{
// Create unordered lists. -, +, # and o are recogized as bullet points
// $li_rx: regex capturing a list entry, including those extending over multiple lines and
// those padded with empty lines
// $ul_rx: regex capturing an unordered list - at least two list entries required
$li_rx = '^([ \t]+([\-+#o])[ \t]+)(\S.*(?:\n [ \t]+(?!\2)(?![ \t]).*|\n[ \t]*)*\n)';
$ul_rx = "(?:$li_rx){2,}";
$txt = preg_replace("/$ul_rx/m", "\n\n<ul>\n$0\n</ul>\n\n", $txt);
if (preg_match_all("%<ul>.*?</ul>%s", $txt, $outerLists)) {
$lists = preg_replace("/$li_rx/m", "<li>$3</li>", $outerLists[0]);
$txt = str_replace($outerLists[0], $lists, $txt);
// Cleanup: Making sure that the lists won't appear inside a <p> (by removing double newlines around ul tags)
// and won't have empty paragraphs in between list items (by removing double newlines between different li tags).
$txt = preg_replace('%\s*<ul>\s*(<li>.+?</li>)\s*</ul>\s*%s', "<ul>\n$1\n</ul>", $txt);
$txt = preg_replace('%\s*</li>\s*%', "</li>\n", $txt);
// Inside <li>s which contain multiple paragraphs, use <p>s with a css hook.
preg_match_all("%<li>.*?</li>%s", $txt, $items);
$adjustedItems = preg_replace("%[ \t]*\n[ \t]*\n[ \t]*%", '</p><p class="list">', $items[0]);
$adjustedItems = preg_replace('%^<li>(.*?</p><p class="list">.*?)</li>$%s', "<li><p class=\"list\">$1</p></li>", $adjustedItems);
$txt = str_replace($items[0], $adjustedItems, $txt);
}
return $txt;
}
|
[
"public",
"function",
"_addListMarkupUL",
"(",
"$",
"txt",
")",
"{",
"// Create unordered lists. -, +, # and o are recogized as bullet points",
"// $li_rx: regex capturing a list entry, including those extending over multiple lines and",
"// those padded with empty lines",
"// $ul_rx: regex capturing an unordered list - at least two list entries required",
"$",
"li_rx",
"=",
"'^([ \\t]+([\\-+#o])[ \\t]+)(\\S.*(?:\\n [ \\t]+(?!\\2)(?![ \\t]).*|\\n[ \\t]*)*\\n)'",
";",
"$",
"ul_rx",
"=",
"\"(?:$li_rx){2,}\"",
";",
"$",
"txt",
"=",
"preg_replace",
"(",
"\"/$ul_rx/m\"",
",",
"\"\\n\\n<ul>\\n$0\\n</ul>\\n\\n\"",
",",
"$",
"txt",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"\"%<ul>.*?</ul>%s\"",
",",
"$",
"txt",
",",
"$",
"outerLists",
")",
")",
"{",
"$",
"lists",
"=",
"preg_replace",
"(",
"\"/$li_rx/m\"",
",",
"\"<li>$3</li>\"",
",",
"$",
"outerLists",
"[",
"0",
"]",
")",
";",
"$",
"txt",
"=",
"str_replace",
"(",
"$",
"outerLists",
"[",
"0",
"]",
",",
"$",
"lists",
",",
"$",
"txt",
")",
";",
"// Cleanup: Making sure that the lists won't appear inside a <p> (by removing double newlines around ul tags)",
"// and won't have empty paragraphs in between list items (by removing double newlines between different li tags).",
"$",
"txt",
"=",
"preg_replace",
"(",
"'%\\s*<ul>\\s*(<li>.+?</li>)\\s*</ul>\\s*%s'",
",",
"\"<ul>\\n$1\\n</ul>\"",
",",
"$",
"txt",
")",
";",
"$",
"txt",
"=",
"preg_replace",
"(",
"'%\\s*</li>\\s*%'",
",",
"\"</li>\\n\"",
",",
"$",
"txt",
")",
";",
"// Inside <li>s which contain multiple paragraphs, use <p>s with a css hook.",
"preg_match_all",
"(",
"\"%<li>.*?</li>%s\"",
",",
"$",
"txt",
",",
"$",
"items",
")",
";",
"$",
"adjustedItems",
"=",
"preg_replace",
"(",
"\"%[ \\t]*\\n[ \\t]*\\n[ \\t]*%\"",
",",
"'</p><p class=\"list\">'",
",",
"$",
"items",
"[",
"0",
"]",
")",
";",
"$",
"adjustedItems",
"=",
"preg_replace",
"(",
"'%^<li>(.*?</p><p class=\"list\">.*?)</li>$%s'",
",",
"\"<li><p class=\\\"list\\\">$1</p></li>\"",
",",
"$",
"adjustedItems",
")",
";",
"$",
"txt",
"=",
"str_replace",
"(",
"$",
"items",
"[",
"0",
"]",
",",
"$",
"adjustedItems",
",",
"$",
"txt",
")",
";",
"}",
"return",
"$",
"txt",
";",
"}"
] |
Detects unordered lists and adds the necessary markup.
@param string $txt the text to parse and modify
@return string
|
[
"Detects",
"unordered",
"lists",
"and",
"adds",
"the",
"necessary",
"markup",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/formatters/htmlStandardFormatter.php#L30-L60
|
222,220
|
thedevsaddam/laravel-schema
|
src/Console/Commands/HelpSchema.php
|
HelpSchema.showHelp
|
public function showHelp()
{
$this->generateBody();
$this->info('Laravel Schema version: ' . $this->version);
$this->table($this->headers, $this->body);
$this->comment('Visit https://packagist.org/packages/thedevsaddam/laravel-schema for more details.');
}
|
php
|
public function showHelp()
{
$this->generateBody();
$this->info('Laravel Schema version: ' . $this->version);
$this->table($this->headers, $this->body);
$this->comment('Visit https://packagist.org/packages/thedevsaddam/laravel-schema for more details.');
}
|
[
"public",
"function",
"showHelp",
"(",
")",
"{",
"$",
"this",
"->",
"generateBody",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Laravel Schema version: '",
".",
"$",
"this",
"->",
"version",
")",
";",
"$",
"this",
"->",
"table",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"this",
"->",
"body",
")",
";",
"$",
"this",
"->",
"comment",
"(",
"'Visit https://packagist.org/packages/thedevsaddam/laravel-schema for more details.'",
")",
";",
"}"
] |
Display schema help information in a table
@return bool
|
[
"Display",
"schema",
"help",
"information",
"in",
"a",
"table"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/HelpSchema.php#L62-L68
|
222,221
|
thedevsaddam/laravel-schema
|
src/Console/Commands/HelpSchema.php
|
HelpSchema.generateBody
|
private function generateBody()
{
$data = $this->readHelpGuide();
$this->version = $data['version'];
foreach ($data['help'] as $key => $value) {
$data = [$key, $value];
array_push($this->body, $data);
}
}
|
php
|
private function generateBody()
{
$data = $this->readHelpGuide();
$this->version = $data['version'];
foreach ($data['help'] as $key => $value) {
$data = [$key, $value];
array_push($this->body, $data);
}
}
|
[
"private",
"function",
"generateBody",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"readHelpGuide",
"(",
")",
";",
"$",
"this",
"->",
"version",
"=",
"$",
"data",
"[",
"'version'",
"]",
";",
"foreach",
"(",
"$",
"data",
"[",
"'help'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"=",
"[",
"$",
"key",
",",
"$",
"value",
"]",
";",
"array_push",
"(",
"$",
"this",
"->",
"body",
",",
"$",
"data",
")",
";",
"}",
"}"
] |
Generate the table body
|
[
"Generate",
"the",
"table",
"body"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/HelpSchema.php#L73-L82
|
222,222
|
thedevsaddam/laravel-schema
|
src/Console/Commands/HelpSchema.php
|
HelpSchema.readHelpGuide
|
private function readHelpGuide()
{
try {
$help = file_get_contents(realpath(__DIR__ . "/../../Schema/help.json"));
return json_decode($help, true);
} catch (\Exception $e) {
$this->error($e->getMessage());
}
}
|
php
|
private function readHelpGuide()
{
try {
$help = file_get_contents(realpath(__DIR__ . "/../../Schema/help.json"));
return json_decode($help, true);
} catch (\Exception $e) {
$this->error($e->getMessage());
}
}
|
[
"private",
"function",
"readHelpGuide",
"(",
")",
"{",
"try",
"{",
"$",
"help",
"=",
"file_get_contents",
"(",
"realpath",
"(",
"__DIR__",
".",
"\"/../../Schema/help.json\"",
")",
")",
";",
"return",
"json_decode",
"(",
"$",
"help",
",",
"true",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Read help.json file
@return mixed
|
[
"Read",
"help",
".",
"json",
"file"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/HelpSchema.php#L88-L96
|
222,223
|
SmarchSoftware/watchtower
|
src/Controllers/PermissionController.php
|
PermissionController.editRole
|
public function editRole($id)
{
if ( Shinobi::can( config('watchtower.acl.permission.role', false) ) ) {
$permission = Permission::findOrFail($id);
$roles = $permission->roles;
$available_roles = Role::whereDoesntHave('permissions', function ($query) use ($id) {
$query->where('permission_id', $id);
})->get();
return view( config('watchtower.views.permissions.role'), compact('permission', 'roles', 'available_roles') );
}
return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync permission roles' ]);
}
|
php
|
public function editRole($id)
{
if ( Shinobi::can( config('watchtower.acl.permission.role', false) ) ) {
$permission = Permission::findOrFail($id);
$roles = $permission->roles;
$available_roles = Role::whereDoesntHave('permissions', function ($query) use ($id) {
$query->where('permission_id', $id);
})->get();
return view( config('watchtower.views.permissions.role'), compact('permission', 'roles', 'available_roles') );
}
return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync permission roles' ]);
}
|
[
"public",
"function",
"editRole",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"Shinobi",
"::",
"can",
"(",
"config",
"(",
"'watchtower.acl.permission.role'",
",",
"false",
")",
")",
")",
"{",
"$",
"permission",
"=",
"Permission",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"roles",
"=",
"$",
"permission",
"->",
"roles",
";",
"$",
"available_roles",
"=",
"Role",
"::",
"whereDoesntHave",
"(",
"'permissions'",
",",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'permission_id'",
",",
"$",
"id",
")",
";",
"}",
")",
"->",
"get",
"(",
")",
";",
"return",
"view",
"(",
"config",
"(",
"'watchtower.views.permissions.role'",
")",
",",
"compact",
"(",
"'permission'",
",",
"'roles'",
",",
"'available_roles'",
")",
")",
";",
"}",
"return",
"view",
"(",
"config",
"(",
"'watchtower.views.layouts.unauthorized'",
")",
",",
"[",
"'message'",
"=>",
"'sync permission roles'",
"]",
")",
";",
"}"
] |
Show the form for editing the permission roles.
@param int $id
@return Response
|
[
"Show",
"the",
"form",
"for",
"editing",
"the",
"permission",
"roles",
"."
] |
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
|
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/PermissionController.php#L189-L204
|
222,224
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._buildFileList
|
public function _buildFileList($files, $dir)
{
$list = array();
$dir = realpath($dir);
if (!$dir) {
return $list;
}
$dir = $this->fixPath($dir);
foreach ($files as $filename) {
$filename = $this->makeAbsolutePath(trim($filename), $dir);
$globResults = glob($filename); // switch slashes since old versions of glob need forward slashes
if ($globResults) {
foreach ($globResults as $filepath) {
$okay = TRUE;
foreach ($this->_ignore as $ignore) {
if (strstr($filepath, trim($ignore))) {
$okay = FALSE;
}
}
if ($okay) {
$list[] = realpath($filepath);
}
}
} elseif (!$this->_subdirs) {
$this->error('Could not find file "'.$filename.'"');
}
}
if ($this->_subdirs) { // recurse into subdir
$globResults = glob($dir.'*', GLOB_ONLYDIR); // get subdirs
if ($globResults) {
foreach ($globResults as $dirName) {
$okay = TRUE;
foreach ($this->_ignore as $ignore) {
if (strstr($dirName, trim($ignore))) {
$okay = FALSE;
}
}
if ($okay && (GLOB_ONLYDIR || is_dir($dirName))) { // handle missing only dir support
$list = array_merge($list, $this->_buildFileList($files, $this->makeAbsolutePath($dirName, $this->_path)));
}
}
}
}
return $list;
}
|
php
|
public function _buildFileList($files, $dir)
{
$list = array();
$dir = realpath($dir);
if (!$dir) {
return $list;
}
$dir = $this->fixPath($dir);
foreach ($files as $filename) {
$filename = $this->makeAbsolutePath(trim($filename), $dir);
$globResults = glob($filename); // switch slashes since old versions of glob need forward slashes
if ($globResults) {
foreach ($globResults as $filepath) {
$okay = TRUE;
foreach ($this->_ignore as $ignore) {
if (strstr($filepath, trim($ignore))) {
$okay = FALSE;
}
}
if ($okay) {
$list[] = realpath($filepath);
}
}
} elseif (!$this->_subdirs) {
$this->error('Could not find file "'.$filename.'"');
}
}
if ($this->_subdirs) { // recurse into subdir
$globResults = glob($dir.'*', GLOB_ONLYDIR); // get subdirs
if ($globResults) {
foreach ($globResults as $dirName) {
$okay = TRUE;
foreach ($this->_ignore as $ignore) {
if (strstr($dirName, trim($ignore))) {
$okay = FALSE;
}
}
if ($okay && (GLOB_ONLYDIR || is_dir($dirName))) { // handle missing only dir support
$list = array_merge($list, $this->_buildFileList($files, $this->makeAbsolutePath($dirName, $this->_path)));
}
}
}
}
return $list;
}
|
[
"public",
"function",
"_buildFileList",
"(",
"$",
"files",
",",
"$",
"dir",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"dir",
"=",
"realpath",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"return",
"$",
"list",
";",
"}",
"$",
"dir",
"=",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"filename",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"makeAbsolutePath",
"(",
"trim",
"(",
"$",
"filename",
")",
",",
"$",
"dir",
")",
";",
"$",
"globResults",
"=",
"glob",
"(",
"$",
"filename",
")",
";",
"// switch slashes since old versions of glob need forward slashes",
"if",
"(",
"$",
"globResults",
")",
"{",
"foreach",
"(",
"$",
"globResults",
"as",
"$",
"filepath",
")",
"{",
"$",
"okay",
"=",
"TRUE",
";",
"foreach",
"(",
"$",
"this",
"->",
"_ignore",
"as",
"$",
"ignore",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"filepath",
",",
"trim",
"(",
"$",
"ignore",
")",
")",
")",
"{",
"$",
"okay",
"=",
"FALSE",
";",
"}",
"}",
"if",
"(",
"$",
"okay",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"realpath",
"(",
"$",
"filepath",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"_subdirs",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Could not find file \"'",
".",
"$",
"filename",
".",
"'\"'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"_subdirs",
")",
"{",
"// recurse into subdir",
"$",
"globResults",
"=",
"glob",
"(",
"$",
"dir",
".",
"'*'",
",",
"GLOB_ONLYDIR",
")",
";",
"// get subdirs",
"if",
"(",
"$",
"globResults",
")",
"{",
"foreach",
"(",
"$",
"globResults",
"as",
"$",
"dirName",
")",
"{",
"$",
"okay",
"=",
"TRUE",
";",
"foreach",
"(",
"$",
"this",
"->",
"_ignore",
"as",
"$",
"ignore",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"dirName",
",",
"trim",
"(",
"$",
"ignore",
")",
")",
")",
"{",
"$",
"okay",
"=",
"FALSE",
";",
"}",
"}",
"if",
"(",
"$",
"okay",
"&&",
"(",
"GLOB_ONLYDIR",
"||",
"is_dir",
"(",
"$",
"dirName",
")",
")",
")",
"{",
"// handle missing only dir support",
"$",
"list",
"=",
"array_merge",
"(",
"$",
"list",
",",
"$",
"this",
"->",
"_buildFileList",
"(",
"$",
"files",
",",
"$",
"this",
"->",
"makeAbsolutePath",
"(",
"$",
"dirName",
",",
"$",
"this",
"->",
"_path",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] |
Build a complete list of file to parse. Expand out wildcards and
traverse directories if asked to.
@param str[] files Array of filenames to expand
|
[
"Build",
"a",
"complete",
"list",
"of",
"file",
"to",
"parse",
".",
"Expand",
"out",
"wildcards",
"and",
"traverse",
"directories",
"if",
"asked",
"to",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L342-L390
|
222,225
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor.makeAbsolutePath
|
public function makeAbsolutePath($path, $prefix)
{
if (
substr($path, 0, 1) == '/' || // unix root
substr($path, 1, 2) == ':\\' || // windows root
substr($path, 0, 2) == '~/' || // unix home directory
substr($path, 0, 2) == '\\\\' || // windows network location
preg_match('|^[a-z]+://|', $path) // url
) {
return $path;
} else {
if (substr($path, 0, 2) == './') {
$path = substr($path, 2);
}
$absPath = $this->fixPath($prefix).$path;
$count = 1;
while ($count > 0) {
$absPath = preg_replace('|\w+/\.\./|', '', $absPath, -1, $count);
}
return $absPath;
}
}
|
php
|
public function makeAbsolutePath($path, $prefix)
{
if (
substr($path, 0, 1) == '/' || // unix root
substr($path, 1, 2) == ':\\' || // windows root
substr($path, 0, 2) == '~/' || // unix home directory
substr($path, 0, 2) == '\\\\' || // windows network location
preg_match('|^[a-z]+://|', $path) // url
) {
return $path;
} else {
if (substr($path, 0, 2) == './') {
$path = substr($path, 2);
}
$absPath = $this->fixPath($prefix).$path;
$count = 1;
while ($count > 0) {
$absPath = preg_replace('|\w+/\.\./|', '', $absPath, -1, $count);
}
return $absPath;
}
}
|
[
"public",
"function",
"makeAbsolutePath",
"(",
"$",
"path",
",",
"$",
"prefix",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1",
")",
"==",
"'/'",
"||",
"// unix root",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"2",
")",
"==",
"':\\\\'",
"||",
"// windows root",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"2",
")",
"==",
"'~/'",
"||",
"// unix home directory",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"2",
")",
"==",
"'\\\\\\\\'",
"||",
"// windows network location",
"preg_match",
"(",
"'|^[a-z]+://|'",
",",
"$",
"path",
")",
"// url",
")",
"{",
"return",
"$",
"path",
";",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"2",
")",
"==",
"'./'",
")",
"{",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"2",
")",
";",
"}",
"$",
"absPath",
"=",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"prefix",
")",
".",
"$",
"path",
";",
"$",
"count",
"=",
"1",
";",
"while",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"absPath",
"=",
"preg_replace",
"(",
"'|\\w+/\\.\\./|'",
",",
"''",
",",
"$",
"absPath",
",",
"-",
"1",
",",
"$",
"count",
")",
";",
"}",
"return",
"$",
"absPath",
";",
"}",
"}"
] |
Turn path into an absolute path using the given prefix?
@param str path Path to make absolute
@param str prefix Absolute path to append to relative path
@return str
|
[
"Turn",
"path",
"into",
"an",
"absolute",
"path",
"using",
"the",
"given",
"prefix?"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L457-L479
|
222,226
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor.docletPath
|
public function docletPath()
{
//return $this->makeAbsolutePath($this->fixPath($this->_docletPath).$this->fixPath($this->_doclet), $this->_path);
return realpath($this->fixPath($this->_docletPath).$this->fixPath($this->_doclet)).'/';
}
|
php
|
public function docletPath()
{
//return $this->makeAbsolutePath($this->fixPath($this->_docletPath).$this->fixPath($this->_doclet), $this->_path);
return realpath($this->fixPath($this->_docletPath).$this->fixPath($this->_doclet)).'/';
}
|
[
"public",
"function",
"docletPath",
"(",
")",
"{",
"//return $this->makeAbsolutePath($this->fixPath($this->_docletPath).$this->fixPath($this->_doclet), $this->_path);",
"return",
"realpath",
"(",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"this",
"->",
"_docletPath",
")",
".",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"this",
"->",
"_doclet",
")",
")",
".",
"'/'",
";",
"}"
] |
Return the path PHPDoctor is running from.
@return str
|
[
"Return",
"the",
"path",
"PHPDoctor",
"is",
"running",
"from",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L500-L504
|
222,227
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor.execute
|
public function execute(&$rootDoc)
{
$docletFile = $this->fixPath($this->_docletPath).$this->_doclet.'/'.$this->_doclet.'.php';
if (is_file($docletFile)) { // load doclet
$this->message('Loading doclet "'.$this->_doclet.'"');
require_once($this->fixPath($this->_docletPath).'/doclet.php');
require_once($docletFile);
$doclet =& new $this->_doclet($rootDoc, $this->getFormatter());
} else {
$this->error('Could not find doclet "'.$docletFile.'"');
}
$this->message('Done ('.round($this->_getTime() - $this->_startTime, 2).' seconds)');
}
|
php
|
public function execute(&$rootDoc)
{
$docletFile = $this->fixPath($this->_docletPath).$this->_doclet.'/'.$this->_doclet.'.php';
if (is_file($docletFile)) { // load doclet
$this->message('Loading doclet "'.$this->_doclet.'"');
require_once($this->fixPath($this->_docletPath).'/doclet.php');
require_once($docletFile);
$doclet =& new $this->_doclet($rootDoc, $this->getFormatter());
} else {
$this->error('Could not find doclet "'.$docletFile.'"');
}
$this->message('Done ('.round($this->_getTime() - $this->_startTime, 2).' seconds)');
}
|
[
"public",
"function",
"execute",
"(",
"&",
"$",
"rootDoc",
")",
"{",
"$",
"docletFile",
"=",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"this",
"->",
"_docletPath",
")",
".",
"$",
"this",
"->",
"_doclet",
".",
"'/'",
".",
"$",
"this",
"->",
"_doclet",
".",
"'.php'",
";",
"if",
"(",
"is_file",
"(",
"$",
"docletFile",
")",
")",
"{",
"// load doclet",
"$",
"this",
"->",
"message",
"(",
"'Loading doclet \"'",
".",
"$",
"this",
"->",
"_doclet",
".",
"'\"'",
")",
";",
"require_once",
"(",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"this",
"->",
"_docletPath",
")",
".",
"'/doclet.php'",
")",
";",
"require_once",
"(",
"$",
"docletFile",
")",
";",
"$",
"doclet",
"=",
"&",
"new",
"$",
"this",
"->",
"_doclet",
"(",
"$",
"rootDoc",
",",
"$",
"this",
"->",
"getFormatter",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"'Could not find doclet \"'",
".",
"$",
"docletFile",
".",
"'\"'",
")",
";",
"}",
"$",
"this",
"->",
"message",
"(",
"'Done ('",
".",
"round",
"(",
"$",
"this",
"->",
"_getTime",
"(",
")",
"-",
"$",
"this",
"->",
"_startTime",
",",
"2",
")",
".",
"' seconds)'",
")",
";",
"}"
] |
Loads and runs the doclet.
@param RootDoc rootDoc
@return bool
|
[
"Loads",
"and",
"runs",
"the",
"doclet",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1189-L1201
|
222,228
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor.getFormatter
|
public function getFormatter()
{
$formatterFile = $this->fixPath($this->_formatterPath).$this->_formatter.'.php';
if (is_file($formatterFile)) {
require_once($formatterFile);
return new $this->_formatter();
} else {
$this->error('Could not find formatter "'.$formatterFile.'"');
exit;
}
}
|
php
|
public function getFormatter()
{
$formatterFile = $this->fixPath($this->_formatterPath).$this->_formatter.'.php';
if (is_file($formatterFile)) {
require_once($formatterFile);
return new $this->_formatter();
} else {
$this->error('Could not find formatter "'.$formatterFile.'"');
exit;
}
}
|
[
"public",
"function",
"getFormatter",
"(",
")",
"{",
"$",
"formatterFile",
"=",
"$",
"this",
"->",
"fixPath",
"(",
"$",
"this",
"->",
"_formatterPath",
")",
".",
"$",
"this",
"->",
"_formatter",
".",
"'.php'",
";",
"if",
"(",
"is_file",
"(",
"$",
"formatterFile",
")",
")",
"{",
"require_once",
"(",
"$",
"formatterFile",
")",
";",
"return",
"new",
"$",
"this",
"->",
"_formatter",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"'Could not find formatter \"'",
".",
"$",
"formatterFile",
".",
"'\"'",
")",
";",
"exit",
";",
"}",
"}"
] |
Creates the formatter and returns it.
@return TextFormatter
|
[
"Creates",
"the",
"formatter",
"and",
"returns",
"it",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1207-L1218
|
222,229
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._mergeArrays
|
public function _mergeArrays($one, $two)
{
foreach ($two as $key => $item) {
if (isset($one[$key]) && is_array($one[$key]) && is_array($item)) {
$one[$key] = $this->_mergeArrays($one[$key], $item);
} else {
$one[$key] = $item;
}
}
return $one;
}
|
php
|
public function _mergeArrays($one, $two)
{
foreach ($two as $key => $item) {
if (isset($one[$key]) && is_array($one[$key]) && is_array($item)) {
$one[$key] = $this->_mergeArrays($one[$key], $item);
} else {
$one[$key] = $item;
}
}
return $one;
}
|
[
"public",
"function",
"_mergeArrays",
"(",
"$",
"one",
",",
"$",
"two",
")",
"{",
"foreach",
"(",
"$",
"two",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"one",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"one",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"one",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"_mergeArrays",
"(",
"$",
"one",
"[",
"$",
"key",
"]",
",",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"one",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"one",
";",
"}"
] |
Recursively merge two arrays into a single array. This differs
from the PHP function array_merge_recursive as it replaces values
with the same index from the first array with items from the
second.
@param mixed[] one Array one
@param mixed[] two Array two
@return mixed[] Merged array
|
[
"Recursively",
"merge",
"two",
"arrays",
"into",
"a",
"single",
"array",
".",
"This",
"differs",
"from",
"the",
"PHP",
"function",
"array_merge_recursive",
"as",
"it",
"replaces",
"values",
"with",
"the",
"same",
"index",
"from",
"the",
"first",
"array",
"with",
"items",
"from",
"the",
"second",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1246-L1257
|
222,230
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._getNext
|
public function _getNext(&$tokens, $key, $whatToGet, $maxDist=0)
{
$start = $key;
$key++;
if (!is_array($whatToGet)) $whatToGet = array($whatToGet);
while (!is_array($tokens[$key]) || !in_array($tokens[$key][0], $whatToGet)) {
$key++;
if (!isset($tokens[$key]) || (0 < $maxDist && (($key-$start) > $maxDist))) return FALSE;
}
return $tokens[$key][1];
}
|
php
|
public function _getNext(&$tokens, $key, $whatToGet, $maxDist=0)
{
$start = $key;
$key++;
if (!is_array($whatToGet)) $whatToGet = array($whatToGet);
while (!is_array($tokens[$key]) || !in_array($tokens[$key][0], $whatToGet)) {
$key++;
if (!isset($tokens[$key]) || (0 < $maxDist && (($key-$start) > $maxDist))) return FALSE;
}
return $tokens[$key][1];
}
|
[
"public",
"function",
"_getNext",
"(",
"&",
"$",
"tokens",
",",
"$",
"key",
",",
"$",
"whatToGet",
",",
"$",
"maxDist",
"=",
"0",
")",
"{",
"$",
"start",
"=",
"$",
"key",
";",
"$",
"key",
"++",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"whatToGet",
")",
")",
"$",
"whatToGet",
"=",
"array",
"(",
"$",
"whatToGet",
")",
";",
"while",
"(",
"!",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"in_array",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
",",
"$",
"whatToGet",
")",
")",
"{",
"$",
"key",
"++",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
")",
"||",
"(",
"0",
"<",
"$",
"maxDist",
"&&",
"(",
"(",
"$",
"key",
"-",
"$",
"start",
")",
">",
"$",
"maxDist",
")",
")",
")",
"return",
"FALSE",
";",
"}",
"return",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
";",
"}"
] |
Get next token of a certain type from token array
@param str[] tokens Token array to search
@param int key Key to start searching from
@param int whatToGet Type of token to look for
@param int maxDist Optional max distance from key to look at; default is 0 for all.
@return str Value of found token
|
[
"Get",
"next",
"token",
"of",
"a",
"certain",
"type",
"from",
"token",
"array"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1268-L1279
|
222,231
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._getPrev
|
public function _getPrev(&$tokens, $key, $whatToGet)
{
$key--;
if (!is_array($whatToGet)) $whatToGet = array($whatToGet);
while (!is_array($tokens[$key]) || !in_array($tokens[$key][0], $whatToGet)) {
$key--;
if (!isset($tokens[$key])) return FALSE;
}
return $tokens[$key][1];
}
|
php
|
public function _getPrev(&$tokens, $key, $whatToGet)
{
$key--;
if (!is_array($whatToGet)) $whatToGet = array($whatToGet);
while (!is_array($tokens[$key]) || !in_array($tokens[$key][0], $whatToGet)) {
$key--;
if (!isset($tokens[$key])) return FALSE;
}
return $tokens[$key][1];
}
|
[
"public",
"function",
"_getPrev",
"(",
"&",
"$",
"tokens",
",",
"$",
"key",
",",
"$",
"whatToGet",
")",
"{",
"$",
"key",
"--",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"whatToGet",
")",
")",
"$",
"whatToGet",
"=",
"array",
"(",
"$",
"whatToGet",
")",
";",
"while",
"(",
"!",
"is_array",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"in_array",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
",",
"$",
"whatToGet",
")",
")",
"{",
"$",
"key",
"--",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
")",
")",
"return",
"FALSE",
";",
"}",
"return",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
";",
"}"
] |
Get previous token of a certain type from token array
@param str[] tokens Token array to search
@param int key Key to start searching from
@param int whatToGet Type of token to look for
@return str Value of found token
|
[
"Get",
"previous",
"token",
"of",
"a",
"certain",
"type",
"from",
"token",
"array"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1289-L1299
|
222,232
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._getProgramElementName
|
public function _getProgramElementName(&$tokens, $key)
{
$name = '';
$key++;
while (
$tokens[$key] && (
$tokens[$key] == '&' || (
isset($tokens[$key][0]) && isset($tokens[$key][1]) && (
$tokens[$key][0] == T_WHITESPACE ||
$tokens[$key][0] == T_STRING ||
$tokens[$key][0] == T_NS_SEPARATOR
)
)
)) {
if (isset($tokens[$key][1])) {
$name .= $tokens[$key][1];
}
$key++;
}
return trim($name);
}
|
php
|
public function _getProgramElementName(&$tokens, $key)
{
$name = '';
$key++;
while (
$tokens[$key] && (
$tokens[$key] == '&' || (
isset($tokens[$key][0]) && isset($tokens[$key][1]) && (
$tokens[$key][0] == T_WHITESPACE ||
$tokens[$key][0] == T_STRING ||
$tokens[$key][0] == T_NS_SEPARATOR
)
)
)) {
if (isset($tokens[$key][1])) {
$name .= $tokens[$key][1];
}
$key++;
}
return trim($name);
}
|
[
"public",
"function",
"_getProgramElementName",
"(",
"&",
"$",
"tokens",
",",
"$",
"key",
")",
"{",
"$",
"name",
"=",
"''",
";",
"$",
"key",
"++",
";",
"while",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"&&",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"==",
"'&'",
"||",
"(",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
")",
"&&",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
")",
"&&",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"==",
"T_WHITESPACE",
"||",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"==",
"T_STRING",
"||",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"==",
"T_NS_SEPARATOR",
")",
")",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
")",
")",
"{",
"$",
"name",
".=",
"$",
"tokens",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
";",
"}",
"$",
"key",
"++",
";",
"}",
"return",
"trim",
"(",
"$",
"name",
")",
";",
"}"
] |
Get the next program element name from the token list
@param mixed[] tokens
@param int key
@return str
|
[
"Get",
"the",
"next",
"program",
"element",
"name",
"from",
"the",
"token",
"list"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1308-L1329
|
222,233
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor.processDocComment
|
public function processDocComment($comment, &$root)
{
if (substr(trim($comment), 0, 3) != '/**') return array(); // not doc comment, abort
$data = array(
'docComment' => $comment,
'tags' => array()
);
$explodedComment = preg_split('/\n[ \n\t\/]*\*+[ \t]*@/', "\n".$comment);
preg_match_all('/^[ \t]*[\/*]*\**( ?.*)[ \t\/*]*$/m', array_shift($explodedComment), $matches); // changed; we need the leading whitespace to detect multi-line list entries
if (isset($matches[1])) {
$txt = implode("\n", $matches[1]);
$data['tags']['@text'] = $this->createTag('@text', trim($txt, " \n\t\0\x0B*/"), $data, $root);
}
foreach ($explodedComment as $tag) { // process tags
// strip whitespace, newlines and asterisks
$tag = preg_replace('/(^[\s\n\*]+|[\s\*]*\*\/$)/m', ' ', $tag); // fixed: empty comment lines at end of docblock
$tag = preg_replace('/\n+/', '', $tag);
$tag = trim($tag);
$parts = preg_split('/\s+/', $tag);
$name = isset($parts[0]) ? array_shift($parts) : $tag;
$text = join(' ', $parts);
if ($name) {
switch ($name) {
case 'package': // place current element in package
case 'namespace':
if (!$this->_ignorePackageTags) { // unless we're ignoring package tags
$data['package'] = $text;
}
break;
case 'var': // set variable type
$data['type'] = $text;
break;
case 'access': // set access permission
$data['access'] = $text;
break;
case 'final': // element is final
$data['final'] = TRUE;
break;
case 'abstract': // element is abstract
$data['abstract'] = TRUE;
break;
case 'static': // element is static
$data['static'] = TRUE;
break;
default: //create tag
$name = '@'.$name;
if (isset($data['tags'][$name])) {
if (is_array($data['tags'][$name])) {
$data['tags'][$name][] = $this->createTag($name, $text, $data, $root);
} else {
$data['tags'][$name] = array($data['tags'][$name], $this->createTag($name, $text, $data, $root));
}
} else {
$data['tags'][$name] =& $this->createTag($name, $text, $data, $root);
}
}
}
}
return $data;
}
|
php
|
public function processDocComment($comment, &$root)
{
if (substr(trim($comment), 0, 3) != '/**') return array(); // not doc comment, abort
$data = array(
'docComment' => $comment,
'tags' => array()
);
$explodedComment = preg_split('/\n[ \n\t\/]*\*+[ \t]*@/', "\n".$comment);
preg_match_all('/^[ \t]*[\/*]*\**( ?.*)[ \t\/*]*$/m', array_shift($explodedComment), $matches); // changed; we need the leading whitespace to detect multi-line list entries
if (isset($matches[1])) {
$txt = implode("\n", $matches[1]);
$data['tags']['@text'] = $this->createTag('@text', trim($txt, " \n\t\0\x0B*/"), $data, $root);
}
foreach ($explodedComment as $tag) { // process tags
// strip whitespace, newlines and asterisks
$tag = preg_replace('/(^[\s\n\*]+|[\s\*]*\*\/$)/m', ' ', $tag); // fixed: empty comment lines at end of docblock
$tag = preg_replace('/\n+/', '', $tag);
$tag = trim($tag);
$parts = preg_split('/\s+/', $tag);
$name = isset($parts[0]) ? array_shift($parts) : $tag;
$text = join(' ', $parts);
if ($name) {
switch ($name) {
case 'package': // place current element in package
case 'namespace':
if (!$this->_ignorePackageTags) { // unless we're ignoring package tags
$data['package'] = $text;
}
break;
case 'var': // set variable type
$data['type'] = $text;
break;
case 'access': // set access permission
$data['access'] = $text;
break;
case 'final': // element is final
$data['final'] = TRUE;
break;
case 'abstract': // element is abstract
$data['abstract'] = TRUE;
break;
case 'static': // element is static
$data['static'] = TRUE;
break;
default: //create tag
$name = '@'.$name;
if (isset($data['tags'][$name])) {
if (is_array($data['tags'][$name])) {
$data['tags'][$name][] = $this->createTag($name, $text, $data, $root);
} else {
$data['tags'][$name] = array($data['tags'][$name], $this->createTag($name, $text, $data, $root));
}
} else {
$data['tags'][$name] =& $this->createTag($name, $text, $data, $root);
}
}
}
}
return $data;
}
|
[
"public",
"function",
"processDocComment",
"(",
"$",
"comment",
",",
"&",
"$",
"root",
")",
"{",
"if",
"(",
"substr",
"(",
"trim",
"(",
"$",
"comment",
")",
",",
"0",
",",
"3",
")",
"!=",
"'/**'",
")",
"return",
"array",
"(",
")",
";",
"// not doc comment, abort",
"$",
"data",
"=",
"array",
"(",
"'docComment'",
"=>",
"$",
"comment",
",",
"'tags'",
"=>",
"array",
"(",
")",
")",
";",
"$",
"explodedComment",
"=",
"preg_split",
"(",
"'/\\n[ \\n\\t\\/]*\\*+[ \\t]*@/'",
",",
"\"\\n\"",
".",
"$",
"comment",
")",
";",
"preg_match_all",
"(",
"'/^[ \\t]*[\\/*]*\\**( ?.*)[ \\t\\/*]*$/m'",
",",
"array_shift",
"(",
"$",
"explodedComment",
")",
",",
"$",
"matches",
")",
";",
"// changed; we need the leading whitespace to detect multi-line list entries",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"$",
"txt",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"'@text'",
"]",
"=",
"$",
"this",
"->",
"createTag",
"(",
"'@text'",
",",
"trim",
"(",
"$",
"txt",
",",
"\" \\n\\t\\0\\x0B*/\"",
")",
",",
"$",
"data",
",",
"$",
"root",
")",
";",
"}",
"foreach",
"(",
"$",
"explodedComment",
"as",
"$",
"tag",
")",
"{",
"// process tags",
"// strip whitespace, newlines and asterisks",
"$",
"tag",
"=",
"preg_replace",
"(",
"'/(^[\\s\\n\\*]+|[\\s\\*]*\\*\\/$)/m'",
",",
"' '",
",",
"$",
"tag",
")",
";",
"// fixed: empty comment lines at end of docblock",
"$",
"tag",
"=",
"preg_replace",
"(",
"'/\\n+/'",
",",
"''",
",",
"$",
"tag",
")",
";",
"$",
"tag",
"=",
"trim",
"(",
"$",
"tag",
")",
";",
"$",
"parts",
"=",
"preg_split",
"(",
"'/\\s+/'",
",",
"$",
"tag",
")",
";",
"$",
"name",
"=",
"isset",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
"?",
"array_shift",
"(",
"$",
"parts",
")",
":",
"$",
"tag",
";",
"$",
"text",
"=",
"join",
"(",
"' '",
",",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"name",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'package'",
":",
"// place current element in package",
"case",
"'namespace'",
":",
"if",
"(",
"!",
"$",
"this",
"->",
"_ignorePackageTags",
")",
"{",
"// unless we're ignoring package tags",
"$",
"data",
"[",
"'package'",
"]",
"=",
"$",
"text",
";",
"}",
"break",
";",
"case",
"'var'",
":",
"// set variable type",
"$",
"data",
"[",
"'type'",
"]",
"=",
"$",
"text",
";",
"break",
";",
"case",
"'access'",
":",
"// set access permission",
"$",
"data",
"[",
"'access'",
"]",
"=",
"$",
"text",
";",
"break",
";",
"case",
"'final'",
":",
"// element is final",
"$",
"data",
"[",
"'final'",
"]",
"=",
"TRUE",
";",
"break",
";",
"case",
"'abstract'",
":",
"// element is abstract",
"$",
"data",
"[",
"'abstract'",
"]",
"=",
"TRUE",
";",
"break",
";",
"case",
"'static'",
":",
"// element is static",
"$",
"data",
"[",
"'static'",
"]",
"=",
"TRUE",
";",
"break",
";",
"default",
":",
"//create tag",
"$",
"name",
"=",
"'@'",
".",
"$",
"name",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"createTag",
"(",
"$",
"name",
",",
"$",
"text",
",",
"$",
"data",
",",
"$",
"root",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
",",
"$",
"this",
"->",
"createTag",
"(",
"$",
"name",
",",
"$",
"text",
",",
"$",
"data",
",",
"$",
"root",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"[",
"'tags'",
"]",
"[",
"$",
"name",
"]",
"=",
"&",
"$",
"this",
"->",
"createTag",
"(",
"$",
"name",
",",
"$",
"text",
",",
"$",
"data",
",",
"$",
"root",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Process a doc comment into a doc tag array.
@param str comment The comment to process
@param RootDoc root The root object
@return mixed[] Array of doc comment data
|
[
"Process",
"a",
"doc",
"comment",
"into",
"a",
"doc",
"tag",
"array",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1338-L1403
|
222,234
|
peej/phpdoctor
|
classes/phpDoctor.php
|
phpDoctor._includeElements
|
public function _includeElements(&$element)
{
if ($element->isGlobal() && !$element->isFinal() && !$this->_globals) {
return FALSE;
} elseif ($element->isGlobal() && $element->isFinal() && !$this->_constants) {
return FALSE;
} elseif (!$this->_private && $element->isPrivate()) {
return FALSE;
} elseif ($this->_private) {
return TRUE;
} elseif ($this->_protected && ($element->isPublic() || $element->isProtected())) {
return TRUE;
} elseif ($this->_public && $element->isPublic()) {
return TRUE;
}
return FALSE;
}
|
php
|
public function _includeElements(&$element)
{
if ($element->isGlobal() && !$element->isFinal() && !$this->_globals) {
return FALSE;
} elseif ($element->isGlobal() && $element->isFinal() && !$this->_constants) {
return FALSE;
} elseif (!$this->_private && $element->isPrivate()) {
return FALSE;
} elseif ($this->_private) {
return TRUE;
} elseif ($this->_protected && ($element->isPublic() || $element->isProtected())) {
return TRUE;
} elseif ($this->_public && $element->isPublic()) {
return TRUE;
}
return FALSE;
}
|
[
"public",
"function",
"_includeElements",
"(",
"&",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"isGlobal",
"(",
")",
"&&",
"!",
"$",
"element",
"->",
"isFinal",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"_globals",
")",
"{",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"element",
"->",
"isGlobal",
"(",
")",
"&&",
"$",
"element",
"->",
"isFinal",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"_constants",
")",
"{",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"_private",
"&&",
"$",
"element",
"->",
"isPrivate",
"(",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"_private",
")",
"{",
"return",
"TRUE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"_protected",
"&&",
"(",
"$",
"element",
"->",
"isPublic",
"(",
")",
"||",
"$",
"element",
"->",
"isProtected",
"(",
")",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"_public",
"&&",
"$",
"element",
"->",
"isPublic",
"(",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Is an element private and we are including private elements, or element is
protected and we are including protected elements.
@param ProgramElementDoc element The element to check
@return bool
|
[
"Is",
"an",
"element",
"private",
"and",
"we",
"are",
"including",
"private",
"elements",
"or",
"element",
"is",
"protected",
"and",
"we",
"are",
"including",
"protected",
"elements",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/phpDoctor.php#L1451-L1468
|
222,235
|
webtoucher/yii2-amqp
|
components/AmqpTrait.php
|
AmqpTrait.getAmqp
|
public function getAmqp()
{
if (empty($this->amqpContainer)) {
$this->amqpContainer = Yii::$app->amqp;
}
return $this->amqpContainer;
}
|
php
|
public function getAmqp()
{
if (empty($this->amqpContainer)) {
$this->amqpContainer = Yii::$app->amqp;
}
return $this->amqpContainer;
}
|
[
"public",
"function",
"getAmqp",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"amqpContainer",
")",
")",
"{",
"$",
"this",
"->",
"amqpContainer",
"=",
"Yii",
"::",
"$",
"app",
"->",
"amqp",
";",
"}",
"return",
"$",
"this",
"->",
"amqpContainer",
";",
"}"
] |
Returns AMQP object.
@return Amqp
|
[
"Returns",
"AMQP",
"object",
"."
] |
7a060ce88f2e31d7324b036a6b1d113a0d75bf02
|
https://github.com/webtoucher/yii2-amqp/blob/7a060ce88f2e31d7324b036a6b1d113a0d75bf02/components/AmqpTrait.php#L45-L51
|
222,236
|
peej/phpdoctor
|
classes/methodDoc.php
|
methodDoc.returnTypeAsString
|
public function returnTypeAsString()
{
$myPackage =& $this->containingPackage();
$classDoc =& $this->_returnType->asClassDoc();
if ($classDoc) {
$packageDoc =& $classDoc->containingPackage();
return '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->name().$this->_returnType->dimension().'</a>';
} else {
return $this->_returnType->typeName().$this->_returnType->dimension();
}
}
|
php
|
public function returnTypeAsString()
{
$myPackage =& $this->containingPackage();
$classDoc =& $this->_returnType->asClassDoc();
if ($classDoc) {
$packageDoc =& $classDoc->containingPackage();
return '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->name().$this->_returnType->dimension().'</a>';
} else {
return $this->_returnType->typeName().$this->_returnType->dimension();
}
}
|
[
"public",
"function",
"returnTypeAsString",
"(",
")",
"{",
"$",
"myPackage",
"=",
"&",
"$",
"this",
"->",
"containingPackage",
"(",
")",
";",
"$",
"classDoc",
"=",
"&",
"$",
"this",
"->",
"_returnType",
"->",
"asClassDoc",
"(",
")",
";",
"if",
"(",
"$",
"classDoc",
")",
"{",
"$",
"packageDoc",
"=",
"&",
"$",
"classDoc",
"->",
"containingPackage",
"(",
")",
";",
"return",
"'<a href=\"'",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"myPackage",
"->",
"depth",
"(",
")",
"+",
"1",
")",
".",
"$",
"classDoc",
"->",
"asPath",
"(",
")",
".",
"'\">'",
".",
"$",
"classDoc",
"->",
"name",
"(",
")",
".",
"$",
"this",
"->",
"_returnType",
"->",
"dimension",
"(",
")",
".",
"'</a>'",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_returnType",
"->",
"typeName",
"(",
")",
".",
"$",
"this",
"->",
"_returnType",
"->",
"dimension",
"(",
")",
";",
"}",
"}"
] |
Format a return type for outputting. Recognised types are turned into
HTML anchor tags to the documentation page for the class defining them.
@return str The string representation of the return type
|
[
"Format",
"a",
"return",
"type",
"for",
"outputting",
".",
"Recognised",
"types",
"are",
"turned",
"into",
"HTML",
"anchor",
"tags",
"to",
"the",
"documentation",
"page",
"for",
"the",
"class",
"defining",
"them",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/methodDoc.php#L83-L94
|
222,237
|
yii2mod/yii2-cron-log
|
behaviors/CronLoggerBehavior.php
|
CronLoggerBehavior.getActionParams
|
private function getActionParams()
{
$result = '';
$requestParams = Yii::$app->request->getParams();
ArrayHelper::remove($requestParams, 0);
foreach ($requestParams as $key => $value) {
if (is_string($key)) {
$result .= " --{$key}={$value}";
} else {
$result .= " {$value}";
}
}
return $result;
}
|
php
|
private function getActionParams()
{
$result = '';
$requestParams = Yii::$app->request->getParams();
ArrayHelper::remove($requestParams, 0);
foreach ($requestParams as $key => $value) {
if (is_string($key)) {
$result .= " --{$key}={$value}";
} else {
$result .= " {$value}";
}
}
return $result;
}
|
[
"private",
"function",
"getActionParams",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"requestParams",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getParams",
"(",
")",
";",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"requestParams",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"requestParams",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"result",
".=",
"\" --{$key}={$value}\"",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"\" {$value}\"",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get action params
@return string
|
[
"Get",
"action",
"params"
] |
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
|
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/behaviors/CronLoggerBehavior.php#L113-L128
|
222,238
|
petercoles/Betfair-Exchange
|
src/Api/Auth.php
|
Auth.init
|
public function init($appKey, $username, $password)
{
if ($appKey == self::$appKey && $this->sessionRemaining() > 5) {
$this->keepAlive();
} else {
$this->login($appKey, $username, $password);
}
}
|
php
|
public function init($appKey, $username, $password)
{
if ($appKey == self::$appKey && $this->sessionRemaining() > 5) {
$this->keepAlive();
} else {
$this->login($appKey, $username, $password);
}
}
|
[
"public",
"function",
"init",
"(",
"$",
"appKey",
",",
"$",
"username",
",",
"$",
"password",
")",
"{",
"if",
"(",
"$",
"appKey",
"==",
"self",
"::",
"$",
"appKey",
"&&",
"$",
"this",
"->",
"sessionRemaining",
"(",
")",
">",
"5",
")",
"{",
"$",
"this",
"->",
"keepAlive",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"login",
"(",
"$",
"appKey",
",",
"$",
"username",
",",
"$",
"password",
")",
";",
"}",
"}"
] |
Wrapper method for other methods to initiate and manage a Betfair session.
This method can be called safely multiple times in a script, or in a loop
for a long running process and will only trigger the authentication overhead
when really needed.
@param string $appKey
@param string $username
@param string $password
|
[
"Wrapper",
"method",
"for",
"other",
"methods",
"to",
"initiate",
"and",
"manage",
"a",
"Betfair",
"session",
".",
"This",
"method",
"can",
"be",
"called",
"safely",
"multiple",
"times",
"in",
"a",
"script",
"or",
"in",
"a",
"loop",
"for",
"a",
"long",
"running",
"process",
"and",
"will",
"only",
"trigger",
"the",
"authentication",
"overhead",
"when",
"really",
"needed",
"."
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Auth.php#L49-L56
|
222,239
|
petercoles/Betfair-Exchange
|
src/Api/Auth.php
|
Auth.persist
|
public function persist($appKey, $sessionToken)
{
if ($sessionToken === null) {
throw new Exception('Invalid session token');
}
self::$appKey = $appKey;
self::$sessionToken = $sessionToken;
return $this->keepAlive();
}
|
php
|
public function persist($appKey, $sessionToken)
{
if ($sessionToken === null) {
throw new Exception('Invalid session token');
}
self::$appKey = $appKey;
self::$sessionToken = $sessionToken;
return $this->keepAlive();
}
|
[
"public",
"function",
"persist",
"(",
"$",
"appKey",
",",
"$",
"sessionToken",
")",
"{",
"if",
"(",
"$",
"sessionToken",
"===",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid session token'",
")",
";",
"}",
"self",
"::",
"$",
"appKey",
"=",
"$",
"appKey",
";",
"self",
"::",
"$",
"sessionToken",
"=",
"$",
"sessionToken",
";",
"return",
"$",
"this",
"->",
"keepAlive",
"(",
")",
";",
"}"
] |
Accept app key and session token and extend session.
@param string $appKey
@param string $sessionToken
@return string
|
[
"Accept",
"app",
"key",
"and",
"session",
"token",
"and",
"extend",
"session",
"."
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Auth.php#L65-L75
|
222,240
|
petercoles/Betfair-Exchange
|
src/Api/Auth.php
|
Auth.keepAlive
|
public function keepAlive()
{
$result = $this->execute($this->httpClient->setEndPoint(self::ENDPOINT.'keepAlive/'));
self::$lastLogin = time();
return $result->token;
}
|
php
|
public function keepAlive()
{
$result = $this->execute($this->httpClient->setEndPoint(self::ENDPOINT.'keepAlive/'));
self::$lastLogin = time();
return $result->token;
}
|
[
"public",
"function",
"keepAlive",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"this",
"->",
"httpClient",
"->",
"setEndPoint",
"(",
"self",
"::",
"ENDPOINT",
".",
"'keepAlive/'",
")",
")",
";",
"self",
"::",
"$",
"lastLogin",
"=",
"time",
"(",
")",
";",
"return",
"$",
"result",
"->",
"token",
";",
"}"
] |
Execute Betfair API call to extend the current session.
Implicitly uses the already set app key and session token.
@return string
@throws Exception
|
[
"Execute",
"Betfair",
"API",
"call",
"to",
"extend",
"the",
"current",
"session",
".",
"Implicitly",
"uses",
"the",
"already",
"set",
"app",
"key",
"and",
"session",
"token",
"."
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Auth.php#L111-L118
|
222,241
|
petercoles/Betfair-Exchange
|
src/Api/Auth.php
|
Auth.logout
|
public function logout()
{
$this->execute($this->httpClient->setEndPoint(self::ENDPOINT.'logout/'));
self::$appKey = null;
self::$sessionToken = null;
self::$lastLogin = null;
}
|
php
|
public function logout()
{
$this->execute($this->httpClient->setEndPoint(self::ENDPOINT.'logout/'));
self::$appKey = null;
self::$sessionToken = null;
self::$lastLogin = null;
}
|
[
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"this",
"->",
"execute",
"(",
"$",
"this",
"->",
"httpClient",
"->",
"setEndPoint",
"(",
"self",
"::",
"ENDPOINT",
".",
"'logout/'",
")",
")",
";",
"self",
"::",
"$",
"appKey",
"=",
"null",
";",
"self",
"::",
"$",
"sessionToken",
"=",
"null",
";",
"self",
"::",
"$",
"lastLogin",
"=",
"null",
";",
"}"
] |
Execute Betfair API call to logout from their system.
Clear all local references to the session.
@throws Exception
|
[
"Execute",
"Betfair",
"API",
"call",
"to",
"logout",
"from",
"their",
"system",
".",
"Clear",
"all",
"local",
"references",
"to",
"the",
"session",
"."
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Auth.php#L126-L133
|
222,242
|
petercoles/Betfair-Exchange
|
src/Api/Auth.php
|
Auth.execute
|
public function execute($request)
{
$result = $request->authHeaders()->send();
if ($result->status === self::API_STATUS_FAIL) {
throw new Exception('Error: '.$result->error);
}
return $result;
}
|
php
|
public function execute($request)
{
$result = $request->authHeaders()->send();
if ($result->status === self::API_STATUS_FAIL) {
throw new Exception('Error: '.$result->error);
}
return $result;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"$",
"request",
"->",
"authHeaders",
"(",
")",
"->",
"send",
"(",
")",
";",
"if",
"(",
"$",
"result",
"->",
"status",
"===",
"self",
"::",
"API_STATUS_FAIL",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Error: '",
".",
"$",
"result",
"->",
"error",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Accept request, add auth headers and dispatch, then respond to any errors.
@param \PeterColes\Betfair\Http\Client $request
@return Mixed
@throws Exception
|
[
"Accept",
"request",
"add",
"auth",
"headers",
"and",
"dispatch",
"then",
"respond",
"to",
"any",
"errors",
"."
] |
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
|
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/Auth.php#L156-L165
|
222,243
|
webtoucher/yii2-amqp
|
components/AmqpInterpreter.php
|
AmqpInterpreter.log
|
public function log($message, $type = self::MESSAGE_INFO) {
$format = [$type == self::MESSAGE_ERROR ? Console::FG_RED : Console::FG_BLUE];
Console::stdout(Console::ansiFormat($message . PHP_EOL, $format));
}
|
php
|
public function log($message, $type = self::MESSAGE_INFO) {
$format = [$type == self::MESSAGE_ERROR ? Console::FG_RED : Console::FG_BLUE];
Console::stdout(Console::ansiFormat($message . PHP_EOL, $format));
}
|
[
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"type",
"=",
"self",
"::",
"MESSAGE_INFO",
")",
"{",
"$",
"format",
"=",
"[",
"$",
"type",
"==",
"self",
"::",
"MESSAGE_ERROR",
"?",
"Console",
"::",
"FG_RED",
":",
"Console",
"::",
"FG_BLUE",
"]",
";",
"Console",
"::",
"stdout",
"(",
"Console",
"::",
"ansiFormat",
"(",
"$",
"message",
".",
"PHP_EOL",
",",
"$",
"format",
")",
")",
";",
"}"
] |
Logs info and error messages.
@param $message
@param $type
|
[
"Logs",
"info",
"and",
"error",
"messages",
"."
] |
7a060ce88f2e31d7324b036a6b1d113a0d75bf02
|
https://github.com/webtoucher/yii2-amqp/blob/7a060ce88f2e31d7324b036a6b1d113a0d75bf02/components/AmqpInterpreter.php#L30-L33
|
222,244
|
SmarchSoftware/watchtower
|
src/Controllers/UserController.php
|
UserController.editUserRoles
|
public function editUserRoles($id)
{
if ( Shinobi::can( config('watchtower.acl.user.role', false) ) ) {
$user = $this->model::findOrFail($id);
$roles = $user->roles;
$available_roles = Role::whereDoesntHave('users', function ($query) use ($id) {
$query->where('user_id', $id);
})->get();
return view( config('watchtower.views.users.role'), compact('user', 'roles', 'available_roles') );
}
return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync user roles' ]);
}
|
php
|
public function editUserRoles($id)
{
if ( Shinobi::can( config('watchtower.acl.user.role', false) ) ) {
$user = $this->model::findOrFail($id);
$roles = $user->roles;
$available_roles = Role::whereDoesntHave('users', function ($query) use ($id) {
$query->where('user_id', $id);
})->get();
return view( config('watchtower.views.users.role'), compact('user', 'roles', 'available_roles') );
}
return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync user roles' ]);
}
|
[
"public",
"function",
"editUserRoles",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"Shinobi",
"::",
"can",
"(",
"config",
"(",
"'watchtower.acl.user.role'",
",",
"false",
")",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"model",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"roles",
"=",
"$",
"user",
"->",
"roles",
";",
"$",
"available_roles",
"=",
"Role",
"::",
"whereDoesntHave",
"(",
"'users'",
",",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'user_id'",
",",
"$",
"id",
")",
";",
"}",
")",
"->",
"get",
"(",
")",
";",
"return",
"view",
"(",
"config",
"(",
"'watchtower.views.users.role'",
")",
",",
"compact",
"(",
"'user'",
",",
"'roles'",
",",
"'available_roles'",
")",
")",
";",
"}",
"return",
"view",
"(",
"config",
"(",
"'watchtower.views.layouts.unauthorized'",
")",
",",
"[",
"'message'",
"=>",
"'sync user roles'",
"]",
")",
";",
"}"
] |
Show the form for editing the user roles.
@param int $id
@return Response
|
[
"Show",
"the",
"form",
"for",
"editing",
"the",
"user",
"roles",
"."
] |
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
|
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/UserController.php#L189-L204
|
222,245
|
peej/phpdoctor
|
doclets/modern/htmlWriter.php
|
HtmlWriter._processInlineTags
|
public function _processInlineTags(&$tag, $first = FALSE)
{
$description = '';
if (is_array($tag)) $tag = $tag[0];
if (is_object($tag)) {
if ($first) {
$tags =& $tag->firstSentenceTags($this->_doclet);
} else {
$tags =& $tag->inlineTags($this->_doclet);
}
if ($tags) {
foreach ($tags as $aTag) {
if ($aTag) {
$description .= $aTag->text($this->_doclet);
}
}
}
return $this->_doclet->formatter->toFormattedText($description);
}
return NULL;
}
|
php
|
public function _processInlineTags(&$tag, $first = FALSE)
{
$description = '';
if (is_array($tag)) $tag = $tag[0];
if (is_object($tag)) {
if ($first) {
$tags =& $tag->firstSentenceTags($this->_doclet);
} else {
$tags =& $tag->inlineTags($this->_doclet);
}
if ($tags) {
foreach ($tags as $aTag) {
if ($aTag) {
$description .= $aTag->text($this->_doclet);
}
}
}
return $this->_doclet->formatter->toFormattedText($description);
}
return NULL;
}
|
[
"public",
"function",
"_processInlineTags",
"(",
"&",
"$",
"tag",
",",
"$",
"first",
"=",
"FALSE",
")",
"{",
"$",
"description",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"tag",
")",
")",
"$",
"tag",
"=",
"$",
"tag",
"[",
"0",
"]",
";",
"if",
"(",
"is_object",
"(",
"$",
"tag",
")",
")",
"{",
"if",
"(",
"$",
"first",
")",
"{",
"$",
"tags",
"=",
"&",
"$",
"tag",
"->",
"firstSentenceTags",
"(",
"$",
"this",
"->",
"_doclet",
")",
";",
"}",
"else",
"{",
"$",
"tags",
"=",
"&",
"$",
"tag",
"->",
"inlineTags",
"(",
"$",
"this",
"->",
"_doclet",
")",
";",
"}",
"if",
"(",
"$",
"tags",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"aTag",
")",
"{",
"if",
"(",
"$",
"aTag",
")",
"{",
"$",
"description",
".=",
"$",
"aTag",
"->",
"text",
"(",
"$",
"this",
"->",
"_doclet",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"_doclet",
"->",
"formatter",
"->",
"toFormattedText",
"(",
"$",
"description",
")",
";",
"}",
"return",
"NULL",
";",
"}"
] |
Convert inline tags into a string for outputting.
@param Tag tag The text tag to process
@param bool first Process first line of tag only
@return str The string representation of the elements doc tags
|
[
"Convert",
"inline",
"tags",
"into",
"a",
"string",
"for",
"outputting",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/modern/htmlWriter.php#L233-L255
|
222,246
|
peej/phpdoctor
|
doclets/modern/frameOutputWriter.php
|
FrameOutputWriter.frameOutputWriter
|
public function frameOutputWriter(&$doclet)
{
parent::HTMLWriter($doclet);
ob_start();
echo <<<END
<frameset cols="20%,80%" frameborder="1" border="1" bordercolor="#bbb" framespacing="1">
<frame src="frame.html" name="index">
<frame src="namespaces.html" name="main">
<noframes>
<body>
<h2>Frame Alert</h2>
<p>This document is designed to be viewed using frames. If you see this message, you are using a non-frame-capable browser.<br>
Link to <a href="namespaces.html">Non-frame version</a>.</p>
</body>
</noframes>
</frameset>
END;
$this->_output = ob_get_contents();
ob_end_clean();
$this->_write('index.html', false, false, false);
}
|
php
|
public function frameOutputWriter(&$doclet)
{
parent::HTMLWriter($doclet);
ob_start();
echo <<<END
<frameset cols="20%,80%" frameborder="1" border="1" bordercolor="#bbb" framespacing="1">
<frame src="frame.html" name="index">
<frame src="namespaces.html" name="main">
<noframes>
<body>
<h2>Frame Alert</h2>
<p>This document is designed to be viewed using frames. If you see this message, you are using a non-frame-capable browser.<br>
Link to <a href="namespaces.html">Non-frame version</a>.</p>
</body>
</noframes>
</frameset>
END;
$this->_output = ob_get_contents();
ob_end_clean();
$this->_write('index.html', false, false, false);
}
|
[
"public",
"function",
"frameOutputWriter",
"(",
"&",
"$",
"doclet",
")",
"{",
"parent",
"::",
"HTMLWriter",
"(",
"$",
"doclet",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
" <<<END\n\n<frameset cols=\"20%,80%\" frameborder=\"1\" border=\"1\" bordercolor=\"#bbb\" framespacing=\"1\">\n\n<frame src=\"frame.html\" name=\"index\">\n<frame src=\"namespaces.html\" name=\"main\">\n\n<noframes>\n <body>\n <h2>Frame Alert</h2>\n <p>This document is designed to be viewed using frames. If you see this message, you are using a non-frame-capable browser.<br>\n Link to <a href=\"namespaces.html\">Non-frame version</a>.</p>\n </body>\n</noframes>\n\n</frameset>\nEND",
";",
"$",
"this",
"->",
"_output",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"$",
"this",
"->",
"_write",
"(",
"'index.html'",
",",
"false",
",",
"false",
",",
"false",
")",
";",
"}"
] |
Build the HTML frameset.
@param Doclet doclet
|
[
"Build",
"the",
"HTML",
"frameset",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/modern/frameOutputWriter.php#L33-L62
|
222,247
|
yii2mod/yii2-cron-log
|
actions/CronLogAction.php
|
CronLogAction.run
|
public function run()
{
$searchModel = Yii::createObject($this->searchClass);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->controller->render($this->view, [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
|
php
|
public function run()
{
$searchModel = Yii::createObject($this->searchClass);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->controller->render($this->view, [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"searchModel",
"=",
"Yii",
"::",
"createObject",
"(",
"$",
"this",
"->",
"searchClass",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"render",
"(",
"$",
"this",
"->",
"view",
",",
"[",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"]",
")",
";",
"}"
] |
Lists of all cron logs.
|
[
"Lists",
"of",
"all",
"cron",
"logs",
"."
] |
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
|
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/actions/CronLogAction.php#L28-L37
|
222,248
|
peej/phpdoctor
|
classes/rootDoc.php
|
rootDoc.addSource
|
public function addSource($filename, $source, $fileData)
{
$this->_sources[substr($filename, strlen($this->_phpdoctor->sourcePath()) + 1)] = array(
$source, $fileData
);
}
|
php
|
public function addSource($filename, $source, $fileData)
{
$this->_sources[substr($filename, strlen($this->_phpdoctor->sourcePath()) + 1)] = array(
$source, $fileData
);
}
|
[
"public",
"function",
"addSource",
"(",
"$",
"filename",
",",
"$",
"source",
",",
"$",
"fileData",
")",
"{",
"$",
"this",
"->",
"_sources",
"[",
"substr",
"(",
"$",
"filename",
",",
"strlen",
"(",
"$",
"this",
"->",
"_phpdoctor",
"->",
"sourcePath",
"(",
")",
")",
"+",
"1",
")",
"]",
"=",
"array",
"(",
"$",
"source",
",",
"$",
"fileData",
")",
";",
"}"
] |
Add a source file to this root.
@param str filename
@param str source
@param str[] fileData
|
[
"Add",
"a",
"source",
"file",
"to",
"this",
"root",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/rootDoc.php#L90-L95
|
222,249
|
peej/phpdoctor
|
classes/rootDoc.php
|
rootDoc.&
|
function &classes()
{
$classes = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageClasses = $this->_packages[$name]->allClasses(); // not by reference so as not to move the internal array pointer
if ($packageClasses) {
foreach ($packageClasses as $key => $pack) {
$classes[$key.'.'.$name] =& $packageClasses[$key];
}
}
}
ksort($classes);
return $classes;
}
|
php
|
function &classes()
{
$classes = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageClasses = $this->_packages[$name]->allClasses(); // not by reference so as not to move the internal array pointer
if ($packageClasses) {
foreach ($packageClasses as $key => $pack) {
$classes[$key.'.'.$name] =& $packageClasses[$key];
}
}
}
ksort($classes);
return $classes;
}
|
[
"function",
"&",
"classes",
"(",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"this",
"->",
"packages",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"name",
"=>",
"$",
"package",
")",
"{",
"$",
"packageClasses",
"=",
"$",
"this",
"->",
"_packages",
"[",
"$",
"name",
"]",
"->",
"allClasses",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"if",
"(",
"$",
"packageClasses",
")",
"{",
"foreach",
"(",
"$",
"packageClasses",
"as",
"$",
"key",
"=>",
"$",
"pack",
")",
"{",
"$",
"classes",
"[",
"$",
"key",
".",
"'.'",
".",
"$",
"name",
"]",
"=",
"&",
"$",
"packageClasses",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}",
"ksort",
"(",
"$",
"classes",
")",
";",
"return",
"$",
"classes",
";",
"}"
] |
Return a reference to the classes and interfaces to be documented.
@return ClassDoc[]
|
[
"Return",
"a",
"reference",
"to",
"the",
"classes",
"and",
"interfaces",
"to",
"be",
"documented",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/rootDoc.php#L137-L152
|
222,250
|
peej/phpdoctor
|
classes/rootDoc.php
|
rootDoc.&
|
function &functions()
{
$functions = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageFunctions = $this->_packages[$name]->functions(); // not by reference so as not to move the internal array pointer
if ($packageFunctions) {
foreach ($packageFunctions as $key => $pack) {
$functions[$name.'.'.$key] =& $packageFunctions[$key];
}
}
}
return $functions;
}
|
php
|
function &functions()
{
$functions = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageFunctions = $this->_packages[$name]->functions(); // not by reference so as not to move the internal array pointer
if ($packageFunctions) {
foreach ($packageFunctions as $key => $pack) {
$functions[$name.'.'.$key] =& $packageFunctions[$key];
}
}
}
return $functions;
}
|
[
"function",
"&",
"functions",
"(",
")",
"{",
"$",
"functions",
"=",
"array",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"this",
"->",
"packages",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"name",
"=>",
"$",
"package",
")",
"{",
"$",
"packageFunctions",
"=",
"$",
"this",
"->",
"_packages",
"[",
"$",
"name",
"]",
"->",
"functions",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"if",
"(",
"$",
"packageFunctions",
")",
"{",
"foreach",
"(",
"$",
"packageFunctions",
"as",
"$",
"key",
"=>",
"$",
"pack",
")",
"{",
"$",
"functions",
"[",
"$",
"name",
".",
"'.'",
".",
"$",
"key",
"]",
"=",
"&",
"$",
"packageFunctions",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"functions",
";",
"}"
] |
Return a reference to the functions to be documented.
@return MethodDoc[]
|
[
"Return",
"a",
"reference",
"to",
"the",
"functions",
"to",
"be",
"documented",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/rootDoc.php#L158-L172
|
222,251
|
peej/phpdoctor
|
classes/rootDoc.php
|
rootDoc.&
|
function &globals()
{
$globals = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageGlobals = $this->_packages[$name]->globals(); // not by reference so as not to move the internal array pointer
if ($packageGlobals) {
foreach ($packageGlobals as $key => $pack) {
$globals[$name.'.'.$key] =& $packageGlobals[$key];
}
}
}
ksort($globals);
return $globals;
}
|
php
|
function &globals()
{
$globals = array();
$packages = $this->packages(); // not by reference so as not to move the internal array pointer
foreach ($packages as $name => $package) {
$packageGlobals = $this->_packages[$name]->globals(); // not by reference so as not to move the internal array pointer
if ($packageGlobals) {
foreach ($packageGlobals as $key => $pack) {
$globals[$name.'.'.$key] =& $packageGlobals[$key];
}
}
}
ksort($globals);
return $globals;
}
|
[
"function",
"&",
"globals",
"(",
")",
"{",
"$",
"globals",
"=",
"array",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"this",
"->",
"packages",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"name",
"=>",
"$",
"package",
")",
"{",
"$",
"packageGlobals",
"=",
"$",
"this",
"->",
"_packages",
"[",
"$",
"name",
"]",
"->",
"globals",
"(",
")",
";",
"// not by reference so as not to move the internal array pointer",
"if",
"(",
"$",
"packageGlobals",
")",
"{",
"foreach",
"(",
"$",
"packageGlobals",
"as",
"$",
"key",
"=>",
"$",
"pack",
")",
"{",
"$",
"globals",
"[",
"$",
"name",
".",
"'.'",
".",
"$",
"key",
"]",
"=",
"&",
"$",
"packageGlobals",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}",
"ksort",
"(",
"$",
"globals",
")",
";",
"return",
"$",
"globals",
";",
"}"
] |
Return a reference to the globals to be documented.
@return FieldDoc[]
|
[
"Return",
"a",
"reference",
"to",
"the",
"globals",
"to",
"be",
"documented",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/rootDoc.php#L178-L193
|
222,252
|
peej/phpdoctor
|
classes/rootDoc.php
|
rootDoc.&
|
function &packageNamed($name, $create = FALSE)
{
$return = NULL;
if (isset($this->_packages[$name])) {
$return =& $this->_packages[$name];
} elseif ($create) {
$newPackage =& new packageDoc($name, $this);
$this->addPackage($newPackage);
$return =& $newPackage;
}
return $return;
}
|
php
|
function &packageNamed($name, $create = FALSE)
{
$return = NULL;
if (isset($this->_packages[$name])) {
$return =& $this->_packages[$name];
} elseif ($create) {
$newPackage =& new packageDoc($name, $this);
$this->addPackage($newPackage);
$return =& $newPackage;
}
return $return;
}
|
[
"function",
"&",
"packageNamed",
"(",
"$",
"name",
",",
"$",
"create",
"=",
"FALSE",
")",
"{",
"$",
"return",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_packages",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"return",
"=",
"&",
"$",
"this",
"->",
"_packages",
"[",
"$",
"name",
"]",
";",
"}",
"elseif",
"(",
"$",
"create",
")",
"{",
"$",
"newPackage",
"=",
"&",
"new",
"packageDoc",
"(",
"$",
"name",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"addPackage",
"(",
"$",
"newPackage",
")",
";",
"$",
"return",
"=",
"&",
"$",
"newPackage",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return a reference to a packageDoc for the specified package name. If a
package of the requested name does not exist, this method will create the
package object, add it to the root and return it.
@param str name Package name
@param bool create Create package if it does not exist
@return PackageDoc
|
[
"Return",
"a",
"reference",
"to",
"a",
"packageDoc",
"for",
"the",
"specified",
"package",
"name",
".",
"If",
"a",
"package",
"of",
"the",
"requested",
"name",
"does",
"not",
"exist",
"this",
"method",
"will",
"create",
"the",
"package",
"object",
"add",
"it",
"to",
"the",
"root",
"and",
"return",
"it",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/rootDoc.php#L203-L215
|
222,253
|
yii2mod/yii2-cron-log
|
behaviors/MutexConsoleCommandBehavior.php
|
MutexConsoleCommandBehavior.checkIsMutexAction
|
public function checkIsMutexAction($action)
{
return in_array(strtolower($action), $this->mutexActions) || in_array('*', $this->mutexActions);
}
|
php
|
public function checkIsMutexAction($action)
{
return in_array(strtolower($action), $this->mutexActions) || in_array('*', $this->mutexActions);
}
|
[
"public",
"function",
"checkIsMutexAction",
"(",
"$",
"action",
")",
"{",
"return",
"in_array",
"(",
"strtolower",
"(",
"$",
"action",
")",
",",
"$",
"this",
"->",
"mutexActions",
")",
"||",
"in_array",
"(",
"'*'",
",",
"$",
"this",
"->",
"mutexActions",
")",
";",
"}"
] |
Checks if specified action is among mutex actions.
@param string $action action name
@return bool whether action should be under mutex
|
[
"Checks",
"if",
"specified",
"action",
"is",
"among",
"mutex",
"actions",
"."
] |
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
|
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/behaviors/MutexConsoleCommandBehavior.php#L83-L86
|
222,254
|
thedevsaddam/laravel-schema
|
src/Console/Commands/QuerySchema.php
|
QuerySchema.performQuery
|
public function performQuery()
{
//change connection if provide
if ($this->option('c')) {
$this->schema->setConnection($this->option('c'));
$this->schema->switchWrapper();
}
$rawQuery = $this->option('r');
if (empty($rawQuery)) {
$this->warn('Please provide raw sql query as string (in single/double quote)!');
return false;
}
$result = $this->schema->rawQuery($rawQuery);
if (!!$result) {
(new Dumper)->dump($result);
}
$this->info('Query executed successfully!');
}
|
php
|
public function performQuery()
{
//change connection if provide
if ($this->option('c')) {
$this->schema->setConnection($this->option('c'));
$this->schema->switchWrapper();
}
$rawQuery = $this->option('r');
if (empty($rawQuery)) {
$this->warn('Please provide raw sql query as string (in single/double quote)!');
return false;
}
$result = $this->schema->rawQuery($rawQuery);
if (!!$result) {
(new Dumper)->dump($result);
}
$this->info('Query executed successfully!');
}
|
[
"public",
"function",
"performQuery",
"(",
")",
"{",
"//change connection if provide",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'c'",
")",
")",
"{",
"$",
"this",
"->",
"schema",
"->",
"setConnection",
"(",
"$",
"this",
"->",
"option",
"(",
"'c'",
")",
")",
";",
"$",
"this",
"->",
"schema",
"->",
"switchWrapper",
"(",
")",
";",
"}",
"$",
"rawQuery",
"=",
"$",
"this",
"->",
"option",
"(",
"'r'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rawQuery",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"'Please provide raw sql query as string (in single/double quote)!'",
")",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"schema",
"->",
"rawQuery",
"(",
"$",
"rawQuery",
")",
";",
"if",
"(",
"!",
"!",
"$",
"result",
")",
"{",
"(",
"new",
"Dumper",
")",
"->",
"dump",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"'Query executed successfully!'",
")",
";",
"}"
] |
Perform raw sql query
@return bool
|
[
"Perform",
"raw",
"sql",
"query"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/QuerySchema.php#L49-L68
|
222,255
|
peej/phpdoctor
|
classes/seeTag.php
|
seeTag._linkText
|
public function _linkText($link, $doclet)
{
$element =& $this->_resolveLink();
if ($element && $this->_parent) {
$package =& $this->_parent->containingPackage();
$path = str_repeat('../', $package->depth() + 1).$element->asPath();
return $doclet->formatLink($path, $link);
} elseif (preg_match('/^(https?|ftp):\/\//', $this->_link) === 1) {
return $doclet->formatLink($this->_link, $link);
} else {
return $link;
}
}
|
php
|
public function _linkText($link, $doclet)
{
$element =& $this->_resolveLink();
if ($element && $this->_parent) {
$package =& $this->_parent->containingPackage();
$path = str_repeat('../', $package->depth() + 1).$element->asPath();
return $doclet->formatLink($path, $link);
} elseif (preg_match('/^(https?|ftp):\/\//', $this->_link) === 1) {
return $doclet->formatLink($this->_link, $link);
} else {
return $link;
}
}
|
[
"public",
"function",
"_linkText",
"(",
"$",
"link",
",",
"$",
"doclet",
")",
"{",
"$",
"element",
"=",
"&",
"$",
"this",
"->",
"_resolveLink",
"(",
")",
";",
"if",
"(",
"$",
"element",
"&&",
"$",
"this",
"->",
"_parent",
")",
"{",
"$",
"package",
"=",
"&",
"$",
"this",
"->",
"_parent",
"->",
"containingPackage",
"(",
")",
";",
"$",
"path",
"=",
"str_repeat",
"(",
"'../'",
",",
"$",
"package",
"->",
"depth",
"(",
")",
"+",
"1",
")",
".",
"$",
"element",
"->",
"asPath",
"(",
")",
";",
"return",
"$",
"doclet",
"->",
"formatLink",
"(",
"$",
"path",
",",
"$",
"link",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^(https?|ftp):\\/\\//'",
",",
"$",
"this",
"->",
"_link",
")",
"===",
"1",
")",
"{",
"return",
"$",
"doclet",
"->",
"formatLink",
"(",
"$",
"this",
"->",
"_link",
",",
"$",
"link",
")",
";",
"}",
"else",
"{",
"return",
"$",
"link",
";",
"}",
"}"
] |
Generate the text to go into the seeTag link
@param str link
@param Doclet doclet
|
[
"Generate",
"the",
"text",
"to",
"go",
"into",
"the",
"seeTag",
"link"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/seeTag.php#L87-L100
|
222,256
|
peej/phpdoctor
|
doclets/standard/classWriter.php
|
classWriter.inheritFields
|
public function inheritFields(&$element, &$rootDoc, &$package)
{
$fields =& $element->fields();
if ($fields) {
ksort($fields);
$num = count($fields); $foo = 0;
echo '<table class="inherit">', "\n";
echo '<tr><th colspan="2">Fields inherited from ', $element->qualifiedName(), "</th></tr>\n";
echo '<tr><td>';
foreach ($fields as $field) {
echo '<a href="', str_repeat('../', $this->_depth), $field->asPath(), '">', $field->name(), '</a>';
if (++$foo < $num) {
echo ', ';
}
}
echo '</td></tr>';
echo "</table>\n\n";
if ($element->superclass()) {
$superclass =& $rootDoc->classNamed($element->superclass());
if ($superclass) {
$this->inheritFields($superclass, $rootDoc, $package);
}
}
}
}
|
php
|
public function inheritFields(&$element, &$rootDoc, &$package)
{
$fields =& $element->fields();
if ($fields) {
ksort($fields);
$num = count($fields); $foo = 0;
echo '<table class="inherit">', "\n";
echo '<tr><th colspan="2">Fields inherited from ', $element->qualifiedName(), "</th></tr>\n";
echo '<tr><td>';
foreach ($fields as $field) {
echo '<a href="', str_repeat('../', $this->_depth), $field->asPath(), '">', $field->name(), '</a>';
if (++$foo < $num) {
echo ', ';
}
}
echo '</td></tr>';
echo "</table>\n\n";
if ($element->superclass()) {
$superclass =& $rootDoc->classNamed($element->superclass());
if ($superclass) {
$this->inheritFields($superclass, $rootDoc, $package);
}
}
}
}
|
[
"public",
"function",
"inheritFields",
"(",
"&",
"$",
"element",
",",
"&",
"$",
"rootDoc",
",",
"&",
"$",
"package",
")",
"{",
"$",
"fields",
"=",
"&",
"$",
"element",
"->",
"fields",
"(",
")",
";",
"if",
"(",
"$",
"fields",
")",
"{",
"ksort",
"(",
"$",
"fields",
")",
";",
"$",
"num",
"=",
"count",
"(",
"$",
"fields",
")",
";",
"$",
"foo",
"=",
"0",
";",
"echo",
"'<table class=\"inherit\">'",
",",
"\"\\n\"",
";",
"echo",
"'<tr><th colspan=\"2\">Fields inherited from '",
",",
"$",
"element",
"->",
"qualifiedName",
"(",
")",
",",
"\"</th></tr>\\n\"",
";",
"echo",
"'<tr><td>'",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"echo",
"'<a href=\"'",
",",
"str_repeat",
"(",
"'../'",
",",
"$",
"this",
"->",
"_depth",
")",
",",
"$",
"field",
"->",
"asPath",
"(",
")",
",",
"'\">'",
",",
"$",
"field",
"->",
"name",
"(",
")",
",",
"'</a>'",
";",
"if",
"(",
"++",
"$",
"foo",
"<",
"$",
"num",
")",
"{",
"echo",
"', '",
";",
"}",
"}",
"echo",
"'</td></tr>'",
";",
"echo",
"\"</table>\\n\\n\"",
";",
"if",
"(",
"$",
"element",
"->",
"superclass",
"(",
")",
")",
"{",
"$",
"superclass",
"=",
"&",
"$",
"rootDoc",
"->",
"classNamed",
"(",
"$",
"element",
"->",
"superclass",
"(",
")",
")",
";",
"if",
"(",
"$",
"superclass",
")",
"{",
"$",
"this",
"->",
"inheritFields",
"(",
"$",
"superclass",
",",
"$",
"rootDoc",
",",
"$",
"package",
")",
";",
"}",
"}",
"}",
"}"
] |
Display the inherited fields of an element. This method calls itself
recursively if the element has a parent class.
@param ProgramElementDoc element
@param RootDoc rootDoc
@param PackageDoc package
|
[
"Display",
"the",
"inherited",
"fields",
"of",
"an",
"element",
".",
"This",
"method",
"calls",
"itself",
"recursively",
"if",
"the",
"element",
"has",
"a",
"parent",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/classWriter.php#L394-L418
|
222,257
|
peej/phpdoctor
|
doclets/standard/classWriter.php
|
classWriter.inheritMethods
|
public function inheritMethods(&$element, &$rootDoc, &$package)
{
$methods =& $element->methods();
if ($methods) {
ksort($methods);
$num = count($methods); $foo = 0;
echo '<table class="inherit">', "\n";
echo '<tr><th colspan="2">Methods inherited from ', $element->qualifiedName(), "</th></tr>\n";
echo '<tr><td>';
foreach ($methods as $method) {
echo '<a href="', str_repeat('../', $this->_depth), $method->asPath(), '">', $method->name(), '</a>';
if (++$foo < $num) {
echo ', ';
}
}
echo '</td></tr>';
echo "</table>\n\n";
if ($element->superclass()) {
$superclass =& $rootDoc->classNamed($element->superclass());
if ($superclass) {
$this->inheritMethods($superclass, $rootDoc, $package);
}
}
}
}
|
php
|
public function inheritMethods(&$element, &$rootDoc, &$package)
{
$methods =& $element->methods();
if ($methods) {
ksort($methods);
$num = count($methods); $foo = 0;
echo '<table class="inherit">', "\n";
echo '<tr><th colspan="2">Methods inherited from ', $element->qualifiedName(), "</th></tr>\n";
echo '<tr><td>';
foreach ($methods as $method) {
echo '<a href="', str_repeat('../', $this->_depth), $method->asPath(), '">', $method->name(), '</a>';
if (++$foo < $num) {
echo ', ';
}
}
echo '</td></tr>';
echo "</table>\n\n";
if ($element->superclass()) {
$superclass =& $rootDoc->classNamed($element->superclass());
if ($superclass) {
$this->inheritMethods($superclass, $rootDoc, $package);
}
}
}
}
|
[
"public",
"function",
"inheritMethods",
"(",
"&",
"$",
"element",
",",
"&",
"$",
"rootDoc",
",",
"&",
"$",
"package",
")",
"{",
"$",
"methods",
"=",
"&",
"$",
"element",
"->",
"methods",
"(",
")",
";",
"if",
"(",
"$",
"methods",
")",
"{",
"ksort",
"(",
"$",
"methods",
")",
";",
"$",
"num",
"=",
"count",
"(",
"$",
"methods",
")",
";",
"$",
"foo",
"=",
"0",
";",
"echo",
"'<table class=\"inherit\">'",
",",
"\"\\n\"",
";",
"echo",
"'<tr><th colspan=\"2\">Methods inherited from '",
",",
"$",
"element",
"->",
"qualifiedName",
"(",
")",
",",
"\"</th></tr>\\n\"",
";",
"echo",
"'<tr><td>'",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"echo",
"'<a href=\"'",
",",
"str_repeat",
"(",
"'../'",
",",
"$",
"this",
"->",
"_depth",
")",
",",
"$",
"method",
"->",
"asPath",
"(",
")",
",",
"'\">'",
",",
"$",
"method",
"->",
"name",
"(",
")",
",",
"'</a>'",
";",
"if",
"(",
"++",
"$",
"foo",
"<",
"$",
"num",
")",
"{",
"echo",
"', '",
";",
"}",
"}",
"echo",
"'</td></tr>'",
";",
"echo",
"\"</table>\\n\\n\"",
";",
"if",
"(",
"$",
"element",
"->",
"superclass",
"(",
")",
")",
"{",
"$",
"superclass",
"=",
"&",
"$",
"rootDoc",
"->",
"classNamed",
"(",
"$",
"element",
"->",
"superclass",
"(",
")",
")",
";",
"if",
"(",
"$",
"superclass",
")",
"{",
"$",
"this",
"->",
"inheritMethods",
"(",
"$",
"superclass",
",",
"$",
"rootDoc",
",",
"$",
"package",
")",
";",
"}",
"}",
"}",
"}"
] |
Display the inherited methods of an element. This method calls itself
recursively if the element has a parent class.
@param ProgramElementDoc element
@param RootDoc rootDoc
@param PackageDoc package
|
[
"Display",
"the",
"inherited",
"methods",
"of",
"an",
"element",
".",
"This",
"method",
"calls",
"itself",
"recursively",
"if",
"the",
"element",
"has",
"a",
"parent",
"class",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/classWriter.php#L427-L451
|
222,258
|
peej/phpdoctor
|
doclets/standard/htmlWriter.php
|
htmlWriter._nav
|
public function _nav($path)
{
$output = '<div class="header">'."\n";
$output .= '<h1>'.$this->_doclet->getHeader()."</h1>\n";
if ($this->_sections) {
$output .= "<ul>\n";
foreach ($this->_sections as $section) {
if (isset($section['selected']) && $section['selected']) {
$output .= '<li class="active">'.$section['title']."</li>\n";
} else {
if (isset($section['url'])) {
$output .= '<li><a href="'.str_repeat('../', $this->_depth).$section['url'].'">'.$section['title']."</a></li>\n";
} else {
$output .= '<li>'.$section['title'].'</li>';
}
}
}
$output .= "</ul>\n";
}
$output .= "</div>\n\n";
$output .= '<div class="small_links">'."\n";
$output .= '<a href="'.str_repeat('../', $this->_depth).'index.html" target="_top">Frames</a>'."\n";
$output .= '<a href="'.str_repeat('../', $this->_depth).$path.'" target="_top">No frames</a>'."\n";
$output .= "</div>\n";
$thisClass = strtolower(get_class($this));
if ($thisClass == 'classwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_field">Field</a> | <a href="#summary_method">Method</a> | <a href="#summary_constr">Constr</a>'."\n";
$output .= 'Detail: <a href="#detail_field">Field</a> | <a href="#detail_method">Method</a> | <a href="#summary_constr">Constr</a>'."\n";
$output .= "</div>\n";
} elseif ($thisClass == 'functionwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_function">Function</a>'."\n";
$output .= 'Detail: <a href="#detail_function">Function</a>'."\n";
$output .= "</div>\n";
} elseif ($thisClass == 'globalwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_global">Global</a>'."\n";
$output .= 'Detail: <a href="#detail_global">Global</a>'."\n";
$output .= "</div>\n";
}
return $output;
}
|
php
|
public function _nav($path)
{
$output = '<div class="header">'."\n";
$output .= '<h1>'.$this->_doclet->getHeader()."</h1>\n";
if ($this->_sections) {
$output .= "<ul>\n";
foreach ($this->_sections as $section) {
if (isset($section['selected']) && $section['selected']) {
$output .= '<li class="active">'.$section['title']."</li>\n";
} else {
if (isset($section['url'])) {
$output .= '<li><a href="'.str_repeat('../', $this->_depth).$section['url'].'">'.$section['title']."</a></li>\n";
} else {
$output .= '<li>'.$section['title'].'</li>';
}
}
}
$output .= "</ul>\n";
}
$output .= "</div>\n\n";
$output .= '<div class="small_links">'."\n";
$output .= '<a href="'.str_repeat('../', $this->_depth).'index.html" target="_top">Frames</a>'."\n";
$output .= '<a href="'.str_repeat('../', $this->_depth).$path.'" target="_top">No frames</a>'."\n";
$output .= "</div>\n";
$thisClass = strtolower(get_class($this));
if ($thisClass == 'classwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_field">Field</a> | <a href="#summary_method">Method</a> | <a href="#summary_constr">Constr</a>'."\n";
$output .= 'Detail: <a href="#detail_field">Field</a> | <a href="#detail_method">Method</a> | <a href="#summary_constr">Constr</a>'."\n";
$output .= "</div>\n";
} elseif ($thisClass == 'functionwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_function">Function</a>'."\n";
$output .= 'Detail: <a href="#detail_function">Function</a>'."\n";
$output .= "</div>\n";
} elseif ($thisClass == 'globalwriter') {
$output .= '<div class="small_links">'."\n";
$output .= 'Summary: <a href="#summary_global">Global</a>'."\n";
$output .= 'Detail: <a href="#detail_global">Global</a>'."\n";
$output .= "</div>\n";
}
return $output;
}
|
[
"public",
"function",
"_nav",
"(",
"$",
"path",
")",
"{",
"$",
"output",
"=",
"'<div class=\"header\">'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'<h1>'",
".",
"$",
"this",
"->",
"_doclet",
"->",
"getHeader",
"(",
")",
".",
"\"</h1>\\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"_sections",
")",
"{",
"$",
"output",
".=",
"\"<ul>\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"_sections",
"as",
"$",
"section",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"section",
"[",
"'selected'",
"]",
")",
"&&",
"$",
"section",
"[",
"'selected'",
"]",
")",
"{",
"$",
"output",
".=",
"'<li class=\"active\">'",
".",
"$",
"section",
"[",
"'title'",
"]",
".",
"\"</li>\\n\"",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"section",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"output",
".=",
"'<li><a href=\"'",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"this",
"->",
"_depth",
")",
".",
"$",
"section",
"[",
"'url'",
"]",
".",
"'\">'",
".",
"$",
"section",
"[",
"'title'",
"]",
".",
"\"</a></li>\\n\"",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"'<li>'",
".",
"$",
"section",
"[",
"'title'",
"]",
".",
"'</li>'",
";",
"}",
"}",
"}",
"$",
"output",
".=",
"\"</ul>\\n\"",
";",
"}",
"$",
"output",
".=",
"\"</div>\\n\\n\"",
";",
"$",
"output",
".=",
"'<div class=\"small_links\">'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'<a href=\"'",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"this",
"->",
"_depth",
")",
".",
"'index.html\" target=\"_top\">Frames</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'<a href=\"'",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"this",
"->",
"_depth",
")",
".",
"$",
"path",
".",
"'\" target=\"_top\">No frames</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"</div>\\n\"",
";",
"$",
"thisClass",
"=",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"if",
"(",
"$",
"thisClass",
"==",
"'classwriter'",
")",
"{",
"$",
"output",
".=",
"'<div class=\"small_links\">'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Summary: <a href=\"#summary_field\">Field</a> | <a href=\"#summary_method\">Method</a> | <a href=\"#summary_constr\">Constr</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Detail: <a href=\"#detail_field\">Field</a> | <a href=\"#detail_method\">Method</a> | <a href=\"#summary_constr\">Constr</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"</div>\\n\"",
";",
"}",
"elseif",
"(",
"$",
"thisClass",
"==",
"'functionwriter'",
")",
"{",
"$",
"output",
".=",
"'<div class=\"small_links\">'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Summary: <a href=\"#summary_function\">Function</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Detail: <a href=\"#detail_function\">Function</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"</div>\\n\"",
";",
"}",
"elseif",
"(",
"$",
"thisClass",
"==",
"'globalwriter'",
")",
"{",
"$",
"output",
".=",
"'<div class=\"small_links\">'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Summary: <a href=\"#summary_global\">Global</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'Detail: <a href=\"#detail_global\">Global</a>'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"</div>\\n\"",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Build the navigation bar
@return str
|
[
"Build",
"the",
"navigation",
"bar"
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/htmlWriter.php#L148-L192
|
222,259
|
peej/phpdoctor
|
doclets/standard/htmlWriter.php
|
htmlWriter._write
|
public function _write($path, $title, $shell)
{
$phpdoctor =& $this->_doclet->phpdoctor();
// make directory separators suitable to this platform
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
// make directories if they don't exist
$dirs = explode(DIRECTORY_SEPARATOR, $path);
array_pop($dirs);
$testPath = $this->_doclet->destinationPath();
foreach ($dirs as $dir) {
$testPath .= $dir.DIRECTORY_SEPARATOR;
if (!is_dir($testPath)) {
if (!@mkdir($testPath)) {
$phpdoctor->error(sprintf('Could not create directory "%s"', $testPath));
exit;
}
}
}
// write file
$fp = fopen($this->_doclet->destinationPath().$path, 'w');
if ($fp) {
$phpdoctor->message('Writing "'.$path.'"');
fwrite($fp, $this->_htmlHeader($title));
if ($shell) fwrite($fp, $this->_shellHeader($path));
fwrite($fp, $this->_output);
if ($shell) fwrite($fp, $this->_shellFooter($path));
fwrite($fp, $this->_htmlFooter());
fclose($fp);
} else {
$phpdoctor->error('Could not write "'.$this->_doclet->destinationPath().$path.'"');
exit;
}
}
|
php
|
public function _write($path, $title, $shell)
{
$phpdoctor =& $this->_doclet->phpdoctor();
// make directory separators suitable to this platform
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
// make directories if they don't exist
$dirs = explode(DIRECTORY_SEPARATOR, $path);
array_pop($dirs);
$testPath = $this->_doclet->destinationPath();
foreach ($dirs as $dir) {
$testPath .= $dir.DIRECTORY_SEPARATOR;
if (!is_dir($testPath)) {
if (!@mkdir($testPath)) {
$phpdoctor->error(sprintf('Could not create directory "%s"', $testPath));
exit;
}
}
}
// write file
$fp = fopen($this->_doclet->destinationPath().$path, 'w');
if ($fp) {
$phpdoctor->message('Writing "'.$path.'"');
fwrite($fp, $this->_htmlHeader($title));
if ($shell) fwrite($fp, $this->_shellHeader($path));
fwrite($fp, $this->_output);
if ($shell) fwrite($fp, $this->_shellFooter($path));
fwrite($fp, $this->_htmlFooter());
fclose($fp);
} else {
$phpdoctor->error('Could not write "'.$this->_doclet->destinationPath().$path.'"');
exit;
}
}
|
[
"public",
"function",
"_write",
"(",
"$",
"path",
",",
"$",
"title",
",",
"$",
"shell",
")",
"{",
"$",
"phpdoctor",
"=",
"&",
"$",
"this",
"->",
"_doclet",
"->",
"phpdoctor",
"(",
")",
";",
"// make directory separators suitable to this platform",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"// make directories if they don't exist",
"$",
"dirs",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"array_pop",
"(",
"$",
"dirs",
")",
";",
"$",
"testPath",
"=",
"$",
"this",
"->",
"_doclet",
"->",
"destinationPath",
"(",
")",
";",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"$",
"testPath",
".=",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"testPath",
")",
")",
"{",
"if",
"(",
"!",
"@",
"mkdir",
"(",
"$",
"testPath",
")",
")",
"{",
"$",
"phpdoctor",
"->",
"error",
"(",
"sprintf",
"(",
"'Could not create directory \"%s\"'",
",",
"$",
"testPath",
")",
")",
";",
"exit",
";",
"}",
"}",
"}",
"// write file",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"_doclet",
"->",
"destinationPath",
"(",
")",
".",
"$",
"path",
",",
"'w'",
")",
";",
"if",
"(",
"$",
"fp",
")",
"{",
"$",
"phpdoctor",
"->",
"message",
"(",
"'Writing \"'",
".",
"$",
"path",
".",
"'\"'",
")",
";",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"this",
"->",
"_htmlHeader",
"(",
"$",
"title",
")",
")",
";",
"if",
"(",
"$",
"shell",
")",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"this",
"->",
"_shellHeader",
"(",
"$",
"path",
")",
")",
";",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"this",
"->",
"_output",
")",
";",
"if",
"(",
"$",
"shell",
")",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"this",
"->",
"_shellFooter",
"(",
"$",
"path",
")",
")",
";",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"this",
"->",
"_htmlFooter",
"(",
")",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"}",
"else",
"{",
"$",
"phpdoctor",
"->",
"error",
"(",
"'Could not write \"'",
".",
"$",
"this",
"->",
"_doclet",
"->",
"destinationPath",
"(",
")",
".",
"$",
"path",
".",
"'\"'",
")",
";",
"exit",
";",
"}",
"}"
] |
Write the HTML page to disk using the given path.
@param str path The path to write the file to
@param str title The title for this page
@param bool shell Include the page shell in the output
|
[
"Write",
"the",
"HTML",
"page",
"to",
"disk",
"using",
"the",
"given",
"path",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/htmlWriter.php#L210-L245
|
222,260
|
peej/phpdoctor
|
doclets/standard/htmlWriter.php
|
htmlWriter._processTags
|
public function _processTags(&$tags)
{
$tagString = '';
foreach ($tags as $key => $tag) {
if ($key != '@text') {
if (is_array($tag)) {
$hasText = FALSE;
foreach ($tag as $key => $tagFromGroup) {
if ($tagFromGroup->text($this->_doclet) != '') {
$hasText = TRUE;
}
}
if ($hasText) {
$tagString .= '<dt>'.$tag[0]->displayName().":</dt>\n";
foreach ($tag as $tagFromGroup) {
$tagString .= '<dd>'.$tagFromGroup->text($this->_doclet)."</dd>\n";
}
}
} else {
$text = $tag->text($this->_doclet);
if ($text != '') {
$tagString .= '<dt>'.$tag->displayName().":</dt>\n";
$tagString .= '<dd>'.$text."</dd>\n";
} elseif ($tag->displayEmpty()) {
$tagString .= '<dt>'.$tag->displayName().".</dt>\n";
}
}
}
}
if ($tagString) {
echo "<dl>\n", $tagString, "</dl>\n";
}
}
|
php
|
public function _processTags(&$tags)
{
$tagString = '';
foreach ($tags as $key => $tag) {
if ($key != '@text') {
if (is_array($tag)) {
$hasText = FALSE;
foreach ($tag as $key => $tagFromGroup) {
if ($tagFromGroup->text($this->_doclet) != '') {
$hasText = TRUE;
}
}
if ($hasText) {
$tagString .= '<dt>'.$tag[0]->displayName().":</dt>\n";
foreach ($tag as $tagFromGroup) {
$tagString .= '<dd>'.$tagFromGroup->text($this->_doclet)."</dd>\n";
}
}
} else {
$text = $tag->text($this->_doclet);
if ($text != '') {
$tagString .= '<dt>'.$tag->displayName().":</dt>\n";
$tagString .= '<dd>'.$text."</dd>\n";
} elseif ($tag->displayEmpty()) {
$tagString .= '<dt>'.$tag->displayName().".</dt>\n";
}
}
}
}
if ($tagString) {
echo "<dl>\n", $tagString, "</dl>\n";
}
}
|
[
"public",
"function",
"_processTags",
"(",
"&",
"$",
"tags",
")",
"{",
"$",
"tagString",
"=",
"''",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"key",
"=>",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"key",
"!=",
"'@text'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tag",
")",
")",
"{",
"$",
"hasText",
"=",
"FALSE",
";",
"foreach",
"(",
"$",
"tag",
"as",
"$",
"key",
"=>",
"$",
"tagFromGroup",
")",
"{",
"if",
"(",
"$",
"tagFromGroup",
"->",
"text",
"(",
"$",
"this",
"->",
"_doclet",
")",
"!=",
"''",
")",
"{",
"$",
"hasText",
"=",
"TRUE",
";",
"}",
"}",
"if",
"(",
"$",
"hasText",
")",
"{",
"$",
"tagString",
".=",
"'<dt>'",
".",
"$",
"tag",
"[",
"0",
"]",
"->",
"displayName",
"(",
")",
".",
"\":</dt>\\n\"",
";",
"foreach",
"(",
"$",
"tag",
"as",
"$",
"tagFromGroup",
")",
"{",
"$",
"tagString",
".=",
"'<dd>'",
".",
"$",
"tagFromGroup",
"->",
"text",
"(",
"$",
"this",
"->",
"_doclet",
")",
".",
"\"</dd>\\n\"",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"tag",
"->",
"text",
"(",
"$",
"this",
"->",
"_doclet",
")",
";",
"if",
"(",
"$",
"text",
"!=",
"''",
")",
"{",
"$",
"tagString",
".=",
"'<dt>'",
".",
"$",
"tag",
"->",
"displayName",
"(",
")",
".",
"\":</dt>\\n\"",
";",
"$",
"tagString",
".=",
"'<dd>'",
".",
"$",
"text",
".",
"\"</dd>\\n\"",
";",
"}",
"elseif",
"(",
"$",
"tag",
"->",
"displayEmpty",
"(",
")",
")",
"{",
"$",
"tagString",
".=",
"'<dt>'",
".",
"$",
"tag",
"->",
"displayName",
"(",
")",
".",
"\".</dt>\\n\"",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"tagString",
")",
"{",
"echo",
"\"<dl>\\n\"",
",",
"$",
"tagString",
",",
"\"</dl>\\n\"",
";",
"}",
"}"
] |
Format tags for output.
@param Tag[] tags
@return str The string representation of the elements doc tags
|
[
"Format",
"tags",
"for",
"output",
"."
] |
3eb646e3b93d411ba8faccd8e9691d6190a11379
|
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/htmlWriter.php#L252-L284
|
222,261
|
yii2mod/yii2-cron-log
|
models/CronScheduleModel.php
|
CronScheduleModel.startCronSchedule
|
public function startCronSchedule($jobCode, $status = CronScheduleStatus::RUN, $messages = null)
{
$this->jobCode = $jobCode;
$this->status = $status;
$this->messages = $messages;
$this->dateCreated = Yii::$app->formatter->asDatetime(time(), 'php: Y-m-d H:i:s');
return $this->save();
}
|
php
|
public function startCronSchedule($jobCode, $status = CronScheduleStatus::RUN, $messages = null)
{
$this->jobCode = $jobCode;
$this->status = $status;
$this->messages = $messages;
$this->dateCreated = Yii::$app->formatter->asDatetime(time(), 'php: Y-m-d H:i:s');
return $this->save();
}
|
[
"public",
"function",
"startCronSchedule",
"(",
"$",
"jobCode",
",",
"$",
"status",
"=",
"CronScheduleStatus",
"::",
"RUN",
",",
"$",
"messages",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"jobCode",
"=",
"$",
"jobCode",
";",
"$",
"this",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"this",
"->",
"messages",
"=",
"$",
"messages",
";",
"$",
"this",
"->",
"dateCreated",
"=",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asDatetime",
"(",
"time",
"(",
")",
",",
"'php: Y-m-d H:i:s'",
")",
";",
"return",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Start cron schedule
@param string $jobCode
@param int $status
@param null $messages
@return bool
|
[
"Start",
"cron",
"schedule"
] |
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
|
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/models/CronScheduleModel.php#L66-L74
|
222,262
|
yii2mod/yii2-cron-log
|
models/CronScheduleModel.php
|
CronScheduleModel.endCronSchedule
|
public function endCronSchedule($status, $messages = null)
{
if ($this->id) {
$this->dateFinished = Yii::$app->formatter->asDatetime(time(), 'php: Y-m-d H:i:s');
$this->status = $status;
$this->messages = $messages;
return $this->save();
}
return false;
}
|
php
|
public function endCronSchedule($status, $messages = null)
{
if ($this->id) {
$this->dateFinished = Yii::$app->formatter->asDatetime(time(), 'php: Y-m-d H:i:s');
$this->status = $status;
$this->messages = $messages;
return $this->save();
}
return false;
}
|
[
"public",
"function",
"endCronSchedule",
"(",
"$",
"status",
",",
"$",
"messages",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"this",
"->",
"dateFinished",
"=",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asDatetime",
"(",
"time",
"(",
")",
",",
"'php: Y-m-d H:i:s'",
")",
";",
"$",
"this",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"this",
"->",
"messages",
"=",
"$",
"messages",
";",
"return",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
End cron schedule
@param string $status
@param null $messages
@return bool
|
[
"End",
"cron",
"schedule"
] |
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
|
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/models/CronScheduleModel.php#L84-L95
|
222,263
|
thedevsaddam/laravel-schema
|
src/Console/Commands/ShowSchema.php
|
ShowSchema.showSchemaInTable
|
public function showSchemaInTable()
{
//change connection if provide
if ($this->option('c')) {
$this->schema->setConnection($this->option('c'));
$this->schema->switchWrapper();
}
$tables = $this->schema->databaseWrapper->getTables();
$headers = $this->schema->headers;
if (!count($tables)) {
$this->warn('Database does not contain any table');
}
$tableName = $this->option('t');
if ($tableName) {
if ($this->isNamespaceModel($tableName)) {
$tableName = $this->tableNameFromModel($tableName);
}
if (!in_array($tableName, $tables)) {
$this->warn('Table name is not correct!');
return false;
}
$body = $this->schema->databaseWrapper->getColumns($tableName);
$rowsCount = $this->schema->getTableRowCount($tableName);
$this->info($tableName . ' (rows: ' . $rowsCount . ')');
$this->table($headers, $body);
return true;
}
foreach ($this->schema->databaseWrapper->getSchema() as $key => $value) {
$this->info($key . ' (rows: ' . $value['rowsCount'] . ')');
$this->table($headers, $value['attributes']);
$this->line('');
}
}
|
php
|
public function showSchemaInTable()
{
//change connection if provide
if ($this->option('c')) {
$this->schema->setConnection($this->option('c'));
$this->schema->switchWrapper();
}
$tables = $this->schema->databaseWrapper->getTables();
$headers = $this->schema->headers;
if (!count($tables)) {
$this->warn('Database does not contain any table');
}
$tableName = $this->option('t');
if ($tableName) {
if ($this->isNamespaceModel($tableName)) {
$tableName = $this->tableNameFromModel($tableName);
}
if (!in_array($tableName, $tables)) {
$this->warn('Table name is not correct!');
return false;
}
$body = $this->schema->databaseWrapper->getColumns($tableName);
$rowsCount = $this->schema->getTableRowCount($tableName);
$this->info($tableName . ' (rows: ' . $rowsCount . ')');
$this->table($headers, $body);
return true;
}
foreach ($this->schema->databaseWrapper->getSchema() as $key => $value) {
$this->info($key . ' (rows: ' . $value['rowsCount'] . ')');
$this->table($headers, $value['attributes']);
$this->line('');
}
}
|
[
"public",
"function",
"showSchemaInTable",
"(",
")",
"{",
"//change connection if provide",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'c'",
")",
")",
"{",
"$",
"this",
"->",
"schema",
"->",
"setConnection",
"(",
"$",
"this",
"->",
"option",
"(",
"'c'",
")",
")",
";",
"$",
"this",
"->",
"schema",
"->",
"switchWrapper",
"(",
")",
";",
"}",
"$",
"tables",
"=",
"$",
"this",
"->",
"schema",
"->",
"databaseWrapper",
"->",
"getTables",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"schema",
"->",
"headers",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"tables",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"'Database does not contain any table'",
")",
";",
"}",
"$",
"tableName",
"=",
"$",
"this",
"->",
"option",
"(",
"'t'",
")",
";",
"if",
"(",
"$",
"tableName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNamespaceModel",
"(",
"$",
"tableName",
")",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"tableNameFromModel",
"(",
"$",
"tableName",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"tableName",
",",
"$",
"tables",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"'Table name is not correct!'",
")",
";",
"return",
"false",
";",
"}",
"$",
"body",
"=",
"$",
"this",
"->",
"schema",
"->",
"databaseWrapper",
"->",
"getColumns",
"(",
"$",
"tableName",
")",
";",
"$",
"rowsCount",
"=",
"$",
"this",
"->",
"schema",
"->",
"getTableRowCount",
"(",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"info",
"(",
"$",
"tableName",
".",
"' (rows: '",
".",
"$",
"rowsCount",
".",
"')'",
")",
";",
"$",
"this",
"->",
"table",
"(",
"$",
"headers",
",",
"$",
"body",
")",
";",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"->",
"databaseWrapper",
"->",
"getSchema",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"$",
"key",
".",
"' (rows: '",
".",
"$",
"value",
"[",
"'rowsCount'",
"]",
".",
"')'",
")",
";",
"$",
"this",
"->",
"table",
"(",
"$",
"headers",
",",
"$",
"value",
"[",
"'attributes'",
"]",
")",
";",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"}",
"}"
] |
Display schema information in tabular form
@return bool
|
[
"Display",
"schema",
"information",
"in",
"tabular",
"form"
] |
ce787b3b5d6f558cd5fb615f373beabb1939e724
|
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/ShowSchema.php#L50-L87
|
222,264
|
Rabbit-Converter/Rabbit-PHP
|
src/Rabbit.php
|
Rabbit.parseline
|
private static function parseline($string){
$string = str_replace(chr(10), "\\n", $string);
$string = str_replace(chr(13), "\\n", $string);
$string = str_replace("\f", "\\f", $string);
return $string;
}
|
php
|
private static function parseline($string){
$string = str_replace(chr(10), "\\n", $string);
$string = str_replace(chr(13), "\\n", $string);
$string = str_replace("\f", "\\f", $string);
return $string;
}
|
[
"private",
"static",
"function",
"parseline",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"chr",
"(",
"10",
")",
",",
"\"\\\\n\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"chr",
"(",
"13",
")",
",",
"\"\\\\n\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"\"\\f\"",
",",
"\"\\\\f\"",
",",
"$",
"string",
")",
";",
"return",
"$",
"string",
";",
"}"
] |
Replace the line break to character to parse the data correctly
@param string $string
@return string
|
[
"Replace",
"the",
"line",
"break",
"to",
"character",
"to",
"parse",
"the",
"data",
"correctly"
] |
420e7889054cdf821553c27a082116513666bc5e
|
https://github.com/Rabbit-Converter/Rabbit-PHP/blob/420e7889054cdf821553c27a082116513666bc5e/src/Rabbit.php#L49-L54
|
222,265
|
Rabbit-Converter/Rabbit-PHP
|
src/Rabbit.php
|
Rabbit.replaceWithRule
|
protected static function replaceWithRule($rule, $output)
{
foreach ($rule as $data) {
$from_json = $data["from"];
//search line break.
//if line break include , need to fix the line
if (strpos($from_json, chr(13)) !== false) {
$from_json = self::parseline($from_json);
}
$from = "~".json_decode('"'.$from_json.'"')."~u";
$to = json_decode('"'.$data["to"].'"');
$output = preg_replace($from, $to, $output);
}
return $output;
}
|
php
|
protected static function replaceWithRule($rule, $output)
{
foreach ($rule as $data) {
$from_json = $data["from"];
//search line break.
//if line break include , need to fix the line
if (strpos($from_json, chr(13)) !== false) {
$from_json = self::parseline($from_json);
}
$from = "~".json_decode('"'.$from_json.'"')."~u";
$to = json_decode('"'.$data["to"].'"');
$output = preg_replace($from, $to, $output);
}
return $output;
}
|
[
"protected",
"static",
"function",
"replaceWithRule",
"(",
"$",
"rule",
",",
"$",
"output",
")",
"{",
"foreach",
"(",
"$",
"rule",
"as",
"$",
"data",
")",
"{",
"$",
"from_json",
"=",
"$",
"data",
"[",
"\"from\"",
"]",
";",
"//search line break.",
"//if line break include , need to fix the line",
"if",
"(",
"strpos",
"(",
"$",
"from_json",
",",
"chr",
"(",
"13",
")",
")",
"!==",
"false",
")",
"{",
"$",
"from_json",
"=",
"self",
"::",
"parseline",
"(",
"$",
"from_json",
")",
";",
"}",
"$",
"from",
"=",
"\"~\"",
".",
"json_decode",
"(",
"'\"'",
".",
"$",
"from_json",
".",
"'\"'",
")",
".",
"\"~u\"",
";",
"$",
"to",
"=",
"json_decode",
"(",
"'\"'",
".",
"$",
"data",
"[",
"\"to\"",
"]",
".",
"'\"'",
")",
";",
"$",
"output",
"=",
"preg_replace",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"output",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Replace the string with rules.
@param array $rule
@param string $output
@return string
|
[
"Replace",
"the",
"string",
"with",
"rules",
"."
] |
420e7889054cdf821553c27a082116513666bc5e
|
https://github.com/Rabbit-Converter/Rabbit-PHP/blob/420e7889054cdf821553c27a082116513666bc5e/src/Rabbit.php#L63-L81
|
222,266
|
nabbar/SwaggerValidator-PHP
|
src/Object/HeaderItem.php
|
HeaderItem.__storeData
|
protected function __storeData($key, $value = null)
{
if (property_exists($this, $key)) {
$this->$key = $value;
}
else {
parent::__storeData($key, $value);
}
}
|
php
|
protected function __storeData($key, $value = null)
{
if (property_exists($this, $key)) {
$this->$key = $value;
}
else {
parent::__storeData($key, $value);
}
}
|
[
"protected",
"function",
"__storeData",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"parent",
"::",
"__storeData",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Var Export Method
|
[
"Var",
"Export",
"Method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/HeaderItem.php#L40-L48
|
222,267
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.jsonUnSerialize
|
public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $jsonData)
{
if (!is_object($jsonData)) {
$context->throwException('Mismatching type of JSON Data received', __METHOD__, __LINE__);
}
if (!($jsonData instanceof \stdClass)) {
$context->throwException('Mismatching type of JSON Data received', __METHOD__, __LINE__);
}
foreach (get_object_vars($jsonData) as $key => $value) {
if ($key == \SwaggerValidator\Common\FactorySwagger::KEY_DEFINITIONS) {
continue;
}
$value = $this->extractNonRecursiveReference($context, $value);
$this->$key = \SwaggerValidator\Common\FactorySwagger::getInstance()->jsonUnSerialize($context->setDataPath($key), $this->getCleanClass(__CLASS__), $key, $value);
}
\SwaggerValidator\Common\CollectionReference::getInstance()->unserializeReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->unserializeReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->cleanReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->jsonUnSerialize($context);
$context->logDecode(get_class($this), __METHOD__, __LINE__);
}
|
php
|
public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $jsonData)
{
if (!is_object($jsonData)) {
$context->throwException('Mismatching type of JSON Data received', __METHOD__, __LINE__);
}
if (!($jsonData instanceof \stdClass)) {
$context->throwException('Mismatching type of JSON Data received', __METHOD__, __LINE__);
}
foreach (get_object_vars($jsonData) as $key => $value) {
if ($key == \SwaggerValidator\Common\FactorySwagger::KEY_DEFINITIONS) {
continue;
}
$value = $this->extractNonRecursiveReference($context, $value);
$this->$key = \SwaggerValidator\Common\FactorySwagger::getInstance()->jsonUnSerialize($context->setDataPath($key), $this->getCleanClass(__CLASS__), $key, $value);
}
\SwaggerValidator\Common\CollectionReference::getInstance()->unserializeReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->unserializeReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->cleanReferenceDefinitions($context);
\SwaggerValidator\Common\CollectionReference::getInstance()->jsonUnSerialize($context);
$context->logDecode(get_class($this), __METHOD__, __LINE__);
}
|
[
"public",
"function",
"jsonUnSerialize",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
",",
"$",
"jsonData",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"jsonData",
")",
")",
"{",
"$",
"context",
"->",
"throwException",
"(",
"'Mismatching type of JSON Data received'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"jsonData",
"instanceof",
"\\",
"stdClass",
")",
")",
"{",
"$",
"context",
"->",
"throwException",
"(",
"'Mismatching type of JSON Data received'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"jsonData",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"KEY_DEFINITIONS",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"extractNonRecursiveReference",
"(",
"$",
"context",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"$",
"key",
"=",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"getInstance",
"(",
")",
"->",
"jsonUnSerialize",
"(",
"$",
"context",
"->",
"setDataPath",
"(",
"$",
"key",
")",
",",
"$",
"this",
"->",
"getCleanClass",
"(",
"__CLASS__",
")",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"CollectionReference",
"::",
"getInstance",
"(",
")",
"->",
"unserializeReferenceDefinitions",
"(",
"$",
"context",
")",
";",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"CollectionReference",
"::",
"getInstance",
"(",
")",
"->",
"unserializeReferenceDefinitions",
"(",
"$",
"context",
")",
";",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"CollectionReference",
"::",
"getInstance",
"(",
")",
"->",
"cleanReferenceDefinitions",
"(",
"$",
"context",
")",
";",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"CollectionReference",
"::",
"getInstance",
"(",
")",
"->",
"jsonUnSerialize",
"(",
"$",
"context",
")",
";",
"$",
"context",
"->",
"logDecode",
"(",
"get_class",
"(",
"$",
"this",
")",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}"
] |
Unserialize the JSON mixed data to this swagger object type
@param \SwaggerValidator\Common\Context $context
@param \stdClass $jsonData
|
[
"Unserialize",
"the",
"JSON",
"mixed",
"data",
"to",
"this",
"swagger",
"object",
"type"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L66-L92
|
222,268
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.jsonSerialize
|
public function jsonSerialize()
{
$keyDefinition = \SwaggerValidator\Common\FactorySwagger::KEY_DEFINITIONS;
$doc = json_decode(\SwaggerValidator\Common\Collection::jsonEncode(parent::jsonSerialize()));
$doc->$keyDefinition = json_decode(\SwaggerValidator\Common\Collection::jsonEncode(\SwaggerValidator\Common\CollectionReference::getInstance()));
if (count(get_object_vars($doc->$keyDefinition)) < 1) {
unset($doc->$keyDefinition);
}
return $doc;
}
|
php
|
public function jsonSerialize()
{
$keyDefinition = \SwaggerValidator\Common\FactorySwagger::KEY_DEFINITIONS;
$doc = json_decode(\SwaggerValidator\Common\Collection::jsonEncode(parent::jsonSerialize()));
$doc->$keyDefinition = json_decode(\SwaggerValidator\Common\Collection::jsonEncode(\SwaggerValidator\Common\CollectionReference::getInstance()));
if (count(get_object_vars($doc->$keyDefinition)) < 1) {
unset($doc->$keyDefinition);
}
return $doc;
}
|
[
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"$",
"keyDefinition",
"=",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"KEY_DEFINITIONS",
";",
"$",
"doc",
"=",
"json_decode",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Collection",
"::",
"jsonEncode",
"(",
"parent",
"::",
"jsonSerialize",
"(",
")",
")",
")",
";",
"$",
"doc",
"->",
"$",
"keyDefinition",
"=",
"json_decode",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Collection",
"::",
"jsonEncode",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"CollectionReference",
"::",
"getInstance",
"(",
")",
")",
")",
";",
"if",
"(",
"count",
"(",
"get_object_vars",
"(",
"$",
"doc",
"->",
"$",
"keyDefinition",
")",
")",
"<",
"1",
")",
"{",
"unset",
"(",
"$",
"doc",
"->",
"$",
"keyDefinition",
")",
";",
"}",
"return",
"$",
"doc",
";",
"}"
] |
Method call when a json_encode of an instance of this object is used
@return \stdClass
|
[
"Method",
"call",
"when",
"a",
"json_encode",
"of",
"an",
"instance",
"of",
"this",
"object",
"is",
"used"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L98-L110
|
222,269
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.validate
|
public function validate(\SwaggerValidator\Common\Context $context)
{
if (!$this->validateBaseSwagger($context)) {
return false;
}
$keyPath = \SwaggerValidator\Common\FactorySwagger::KEY_PATHS;
$context->logValidate(get_class($this), __METHOD__, __LINE__);
$result = $this->$keyPath->validate($context->setDataPath($keyPath));
if (!$result) {
return false;
}
if ($context->getMode() === \SwaggerValidator\Common\Context::MODE_PASS) {
$context->cleanParams();
$context->setDataPath('CheckTooMany')->logValidate(get_class($this), __METHOD__, __LINE__);
return true;
}
return $this->validateTooMany($context);
}
|
php
|
public function validate(\SwaggerValidator\Common\Context $context)
{
if (!$this->validateBaseSwagger($context)) {
return false;
}
$keyPath = \SwaggerValidator\Common\FactorySwagger::KEY_PATHS;
$context->logValidate(get_class($this), __METHOD__, __LINE__);
$result = $this->$keyPath->validate($context->setDataPath($keyPath));
if (!$result) {
return false;
}
if ($context->getMode() === \SwaggerValidator\Common\Context::MODE_PASS) {
$context->cleanParams();
$context->setDataPath('CheckTooMany')->logValidate(get_class($this), __METHOD__, __LINE__);
return true;
}
return $this->validateTooMany($context);
}
|
[
"public",
"function",
"validate",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateBaseSwagger",
"(",
"$",
"context",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"keyPath",
"=",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"KEY_PATHS",
";",
"$",
"context",
"->",
"logValidate",
"(",
"get_class",
"(",
"$",
"this",
")",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"$",
"keyPath",
"->",
"validate",
"(",
"$",
"context",
"->",
"setDataPath",
"(",
"$",
"keyPath",
")",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"context",
"->",
"getMode",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"::",
"MODE_PASS",
")",
"{",
"$",
"context",
"->",
"cleanParams",
"(",
")",
";",
"$",
"context",
"->",
"setDataPath",
"(",
"'CheckTooMany'",
")",
"->",
"logValidate",
"(",
"get_class",
"(",
"$",
"this",
")",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"validateTooMany",
"(",
"$",
"context",
")",
";",
"}"
] |
Validate the Request or Response
@param \SwaggerValidator\Common\Context $context
@return boolean
|
[
"Validate",
"the",
"Request",
"or",
"Response"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L117-L139
|
222,270
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.checkSwaggerVersion
|
protected function checkSwaggerVersion(\SwaggerValidator\Common\Context $context)
{
if ($context->getDataValue() != '2.0') {
return $context->setValidationError(\SwaggerValidator\CustomIOHelper::VALIDATION_TYPE_SWAGGER_ERROR, 'Bad swagger version', __METHOD__, __LINE__);
}
return true;
}
|
php
|
protected function checkSwaggerVersion(\SwaggerValidator\Common\Context $context)
{
if ($context->getDataValue() != '2.0') {
return $context->setValidationError(\SwaggerValidator\CustomIOHelper::VALIDATION_TYPE_SWAGGER_ERROR, 'Bad swagger version', __METHOD__, __LINE__);
}
return true;
}
|
[
"protected",
"function",
"checkSwaggerVersion",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
"!=",
"'2.0'",
")",
"{",
"return",
"$",
"context",
"->",
"setValidationError",
"(",
"\\",
"SwaggerValidator",
"\\",
"CustomIOHelper",
"::",
"VALIDATION_TYPE_SWAGGER_ERROR",
",",
"'Bad swagger version'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Check the Swagger Version for validate method
@param \SwaggerValidator\Common\Context $context
@return boolean
|
[
"Check",
"the",
"Swagger",
"Version",
"for",
"validate",
"method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L219-L226
|
222,271
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.checkSchemes
|
protected function checkSchemes(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->schemes)) {
return true;
}
foreach ($this->schemes as $oneScheme) {
if (strtolower($context->getDataValue()) && strtolower($oneScheme)) {
return true;
}
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_DATAVALUE, 'Scheme requested is not allowed', __METHOD__, __LINE__);
}
|
php
|
protected function checkSchemes(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->schemes)) {
return true;
}
foreach ($this->schemes as $oneScheme) {
if (strtolower($context->getDataValue()) && strtolower($oneScheme)) {
return true;
}
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_DATAVALUE, 'Scheme requested is not allowed', __METHOD__, __LINE__);
}
|
[
"protected",
"function",
"checkSchemes",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schemes",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"schemes",
"as",
"$",
"oneScheme",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
")",
"&&",
"strtolower",
"(",
"$",
"oneScheme",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"$",
"context",
"->",
"setValidationError",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"::",
"VALIDATION_TYPE_DATAVALUE",
",",
"'Scheme requested is not allowed'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}"
] |
Check the scheme used in the request URL for validate method
@param \SwaggerValidator\Common\Context $context
@return boolean
|
[
"Check",
"the",
"scheme",
"used",
"in",
"the",
"request",
"URL",
"for",
"validate",
"method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L233-L246
|
222,272
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.checkHost
|
protected function checkHost(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->host)) {
return true;
}
if ($context->getDataValue() === null) {
return true;
}
if (strtolower($context->getDataValue()) && strtolower($this->host)) {
return true;
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_HOSTNAME_ERROR, 'HostName requested is not allowed', __METHOD__, __LINE__);
}
|
php
|
protected function checkHost(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->host)) {
return true;
}
if ($context->getDataValue() === null) {
return true;
}
if (strtolower($context->getDataValue()) && strtolower($this->host)) {
return true;
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_HOSTNAME_ERROR, 'HostName requested is not allowed', __METHOD__, __LINE__);
}
|
[
"protected",
"function",
"checkHost",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"host",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
")",
"&&",
"strtolower",
"(",
"$",
"this",
"->",
"host",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"context",
"->",
"setValidationError",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"::",
"VALIDATION_TYPE_HOSTNAME_ERROR",
",",
"'HostName requested is not allowed'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}"
] |
Check the host used in the request URL for validate method
@param \SwaggerValidator\Common\Context $context
@return boolean
|
[
"Check",
"the",
"host",
"used",
"in",
"the",
"request",
"URL",
"for",
"validate",
"method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L253-L268
|
222,273
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.checkBasePath
|
protected function checkBasePath(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->basePath) || $this->basePath == '/') {
$context->setBasePath(null);
$context->setRequestPath($context->getDataValue());
return $context;
}
if (substr($context->getDataValue(), 0, strlen($this->basePath)) != $this->basePath) {
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_BASEPATH_ERROR, 'BasePath requested is not matching', __METHOD__, __LINE__);
}
$context->setBasePath($this->basePath);
$context->setRequestPath(substr($context->getDataValue(), strlen($this->basePath)));
return $context;
}
|
php
|
protected function checkBasePath(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->basePath) || $this->basePath == '/') {
$context->setBasePath(null);
$context->setRequestPath($context->getDataValue());
return $context;
}
if (substr($context->getDataValue(), 0, strlen($this->basePath)) != $this->basePath) {
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_BASEPATH_ERROR, 'BasePath requested is not matching', __METHOD__, __LINE__);
}
$context->setBasePath($this->basePath);
$context->setRequestPath(substr($context->getDataValue(), strlen($this->basePath)));
return $context;
}
|
[
"protected",
"function",
"checkBasePath",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"basePath",
")",
"||",
"$",
"this",
"->",
"basePath",
"==",
"'/'",
")",
"{",
"$",
"context",
"->",
"setBasePath",
"(",
"null",
")",
";",
"$",
"context",
"->",
"setRequestPath",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
")",
";",
"return",
"$",
"context",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"basePath",
")",
")",
"!=",
"$",
"this",
"->",
"basePath",
")",
"{",
"return",
"$",
"context",
"->",
"setValidationError",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"::",
"VALIDATION_TYPE_BASEPATH_ERROR",
",",
"'BasePath requested is not matching'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}",
"$",
"context",
"->",
"setBasePath",
"(",
"$",
"this",
"->",
"basePath",
")",
";",
"$",
"context",
"->",
"setRequestPath",
"(",
"substr",
"(",
"$",
"context",
"->",
"getDataValue",
"(",
")",
",",
"strlen",
"(",
"$",
"this",
"->",
"basePath",
")",
")",
")",
";",
"return",
"$",
"context",
";",
"}"
] |
Check the basePath used in the request URL for validate method
@param \SwaggerValidator\Common\Context $context
@return \SwaggerValidator\Common\Context
|
[
"Check",
"the",
"basePath",
"used",
"in",
"the",
"request",
"URL",
"for",
"validate",
"method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L275-L291
|
222,274
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.checkConsume
|
protected function checkConsume(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->consume)) {
return true;
}
$headers = $context->getRequestHeader();
$contentType = null;
$contentLength = 0;
if (array_key_exists('Content-Type', $headers)) {
$contentType = explode(';', $headers['Content-Type']);
$contentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($contentType));
}
if (array_key_exists('Content-Length', $headers)) {
$contentLength = (int) $headers['Content-Length'];
}
if (empty($contentType) && $contentLength === 0) {
return true;
}
foreach ($this->consume as $oneContentType) {
$oneContentType = explode(';', $oneContentType);
$oneContentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($oneContentType));
if (strtolower($contentType) == strtolower($oneContentType)) {
return true;
}
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_DATAVALUE, 'Content-Type requested is not allowed', __METHOD__, __LINE__);
}
|
php
|
protected function checkConsume(\SwaggerValidator\Common\Context $context)
{
if (!isset($this->consume)) {
return true;
}
$headers = $context->getRequestHeader();
$contentType = null;
$contentLength = 0;
if (array_key_exists('Content-Type', $headers)) {
$contentType = explode(';', $headers['Content-Type']);
$contentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($contentType));
}
if (array_key_exists('Content-Length', $headers)) {
$contentLength = (int) $headers['Content-Length'];
}
if (empty($contentType) && $contentLength === 0) {
return true;
}
foreach ($this->consume as $oneContentType) {
$oneContentType = explode(';', $oneContentType);
$oneContentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($oneContentType));
if (strtolower($contentType) == strtolower($oneContentType)) {
return true;
}
}
return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_DATAVALUE, 'Content-Type requested is not allowed', __METHOD__, __LINE__);
}
|
[
"protected",
"function",
"checkConsume",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"consume",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"headers",
"=",
"$",
"context",
"->",
"getRequestHeader",
"(",
")",
";",
"$",
"contentType",
"=",
"null",
";",
"$",
"contentLength",
"=",
"0",
";",
"if",
"(",
"array_key_exists",
"(",
"'Content-Type'",
",",
"$",
"headers",
")",
")",
"{",
"$",
"contentType",
"=",
"explode",
"(",
"';'",
",",
"$",
"headers",
"[",
"'Content-Type'",
"]",
")",
";",
"$",
"contentType",
"=",
"str_replace",
"(",
"array",
"(",
"'application/'",
",",
"'text/'",
",",
"'x-'",
")",
",",
"''",
",",
"array_shift",
"(",
"$",
"contentType",
")",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'Content-Length'",
",",
"$",
"headers",
")",
")",
"{",
"$",
"contentLength",
"=",
"(",
"int",
")",
"$",
"headers",
"[",
"'Content-Length'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"contentType",
")",
"&&",
"$",
"contentLength",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"consume",
"as",
"$",
"oneContentType",
")",
"{",
"$",
"oneContentType",
"=",
"explode",
"(",
"';'",
",",
"$",
"oneContentType",
")",
";",
"$",
"oneContentType",
"=",
"str_replace",
"(",
"array",
"(",
"'application/'",
",",
"'text/'",
",",
"'x-'",
")",
",",
"''",
",",
"array_shift",
"(",
"$",
"oneContentType",
")",
")",
";",
"if",
"(",
"strtolower",
"(",
"$",
"contentType",
")",
"==",
"strtolower",
"(",
"$",
"oneContentType",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"$",
"context",
"->",
"setValidationError",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"::",
"VALIDATION_TYPE_DATAVALUE",
",",
"'Content-Type requested is not allowed'",
",",
"__METHOD__",
",",
"__LINE__",
")",
";",
"}"
] |
Check the Content-Type used in the request regarding the consume definition for validate method
@param \SwaggerValidator\Common\Context $context
@return boolean
|
[
"Check",
"the",
"Content",
"-",
"Type",
"used",
"in",
"the",
"request",
"regarding",
"the",
"consume",
"definition",
"for",
"validate",
"method"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L298-L331
|
222,275
|
nabbar/SwaggerValidator-PHP
|
src/Object/Swagger.php
|
Swagger.getModel
|
public function getModel(\SwaggerValidator\Common\Context $context)
{
$generalItems = $this->getMethodGeneric($context, __FUNCTION__);
$paths = \SwaggerValidator\Common\FactorySwagger::KEY_PATHS;
$context->logModel(__METHOD__, __LINE__);
return $this->$paths->getModel($context->setDataPath($paths), $generalItems);
}
|
php
|
public function getModel(\SwaggerValidator\Common\Context $context)
{
$generalItems = $this->getMethodGeneric($context, __FUNCTION__);
$paths = \SwaggerValidator\Common\FactorySwagger::KEY_PATHS;
$context->logModel(__METHOD__, __LINE__);
return $this->$paths->getModel($context->setDataPath($paths), $generalItems);
}
|
[
"public",
"function",
"getModel",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Context",
"$",
"context",
")",
"{",
"$",
"generalItems",
"=",
"$",
"this",
"->",
"getMethodGeneric",
"(",
"$",
"context",
",",
"__FUNCTION__",
")",
";",
"$",
"paths",
"=",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"KEY_PATHS",
";",
"$",
"context",
"->",
"logModel",
"(",
"__METHOD__",
",",
"__LINE__",
")",
";",
"return",
"$",
"this",
"->",
"$",
"paths",
"->",
"getModel",
"(",
"$",
"context",
"->",
"setDataPath",
"(",
"$",
"paths",
")",
",",
"$",
"generalItems",
")",
";",
"}"
] |
Build a model following current definition instancied
@param \SwaggerValidator\Common\Context $context
@return array
|
[
"Build",
"a",
"model",
"following",
"current",
"definition",
"instancied"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Object/Swagger.php#L431-L438
|
222,276
|
adshares/ads-php-client
|
src/Driver/CommandError.php
|
CommandError.getMessageByCode
|
public static function getMessageByCode(int $code): string
{
return (array_key_exists($code, self::MESSAGES)) ? self::MESSAGES[$code] : self::MESSAGES[self::UNKNOWN_ERROR];
}
|
php
|
public static function getMessageByCode(int $code): string
{
return (array_key_exists($code, self::MESSAGES)) ? self::MESSAGES[$code] : self::MESSAGES[self::UNKNOWN_ERROR];
}
|
[
"public",
"static",
"function",
"getMessageByCode",
"(",
"int",
"$",
"code",
")",
":",
"string",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"code",
",",
"self",
"::",
"MESSAGES",
")",
")",
"?",
"self",
"::",
"MESSAGES",
"[",
"$",
"code",
"]",
":",
"self",
"::",
"MESSAGES",
"[",
"self",
"::",
"UNKNOWN_ERROR",
"]",
";",
"}"
] |
Returns error description for given code.
@param int $code error code
@return string error message
|
[
"Returns",
"error",
"description",
"for",
"given",
"code",
"."
] |
b9a897219dfa60a316a29191dbeb836c5e1aa760
|
https://github.com/adshares/ads-php-client/blob/b9a897219dfa60a316a29191dbeb836c5e1aa760/src/Driver/CommandError.php#L193-L196
|
222,277
|
adshares/ads-php-client
|
src/Driver/CommandError.php
|
CommandError.getCodeByMessage
|
public static function getCodeByMessage(string $errorMessage): int
{
$code = array_search($errorMessage, self::MESSAGES);
if ($code === false) {
$code = self::UNKNOWN_ERROR;
}
return (int)$code;
}
|
php
|
public static function getCodeByMessage(string $errorMessage): int
{
$code = array_search($errorMessage, self::MESSAGES);
if ($code === false) {
$code = self::UNKNOWN_ERROR;
}
return (int)$code;
}
|
[
"public",
"static",
"function",
"getCodeByMessage",
"(",
"string",
"$",
"errorMessage",
")",
":",
"int",
"{",
"$",
"code",
"=",
"array_search",
"(",
"$",
"errorMessage",
",",
"self",
"::",
"MESSAGES",
")",
";",
"if",
"(",
"$",
"code",
"===",
"false",
")",
"{",
"$",
"code",
"=",
"self",
"::",
"UNKNOWN_ERROR",
";",
"}",
"return",
"(",
"int",
")",
"$",
"code",
";",
"}"
] |
Returns error code from given error message.
@param string $errorMessage error message
@return int error code
|
[
"Returns",
"error",
"code",
"from",
"given",
"error",
"message",
"."
] |
b9a897219dfa60a316a29191dbeb836c5e1aa760
|
https://github.com/adshares/ads-php-client/blob/b9a897219dfa60a316a29191dbeb836c5e1aa760/src/Driver/CommandError.php#L204-L211
|
222,278
|
adshares/ads-php-client
|
src/Util/AdsValidator.php
|
AdsValidator.isAccountAddressValid
|
public static function isAccountAddressValid(string $address): bool
{
// validate format
if (1 === preg_match('/^[0-9a-fA-F]{4}-[0-9a-fA-F]{8}-([0-9a-fA-F]{4}|XXXX)$/', $address)) {
// validate checksum
$checksum = strtoupper(substr($address, -4));
if ('XXXX' === $checksum) {
// 'XXXX' is allowed as checksum replacement
return true;
}
$nodeId = substr($address, 0, 4);
$userId = substr($address, 5, 8);
$checksumComputed = AdsChecksumGenerator::getAccountChecksum(hexdec($nodeId), hexdec($userId));
return $checksum === $checksumComputed;
}
return false;
}
|
php
|
public static function isAccountAddressValid(string $address): bool
{
// validate format
if (1 === preg_match('/^[0-9a-fA-F]{4}-[0-9a-fA-F]{8}-([0-9a-fA-F]{4}|XXXX)$/', $address)) {
// validate checksum
$checksum = strtoupper(substr($address, -4));
if ('XXXX' === $checksum) {
// 'XXXX' is allowed as checksum replacement
return true;
}
$nodeId = substr($address, 0, 4);
$userId = substr($address, 5, 8);
$checksumComputed = AdsChecksumGenerator::getAccountChecksum(hexdec($nodeId), hexdec($userId));
return $checksum === $checksumComputed;
}
return false;
}
|
[
"public",
"static",
"function",
"isAccountAddressValid",
"(",
"string",
"$",
"address",
")",
":",
"bool",
"{",
"// validate format",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/^[0-9a-fA-F]{4}-[0-9a-fA-F]{8}-([0-9a-fA-F]{4}|XXXX)$/'",
",",
"$",
"address",
")",
")",
"{",
"// validate checksum",
"$",
"checksum",
"=",
"strtoupper",
"(",
"substr",
"(",
"$",
"address",
",",
"-",
"4",
")",
")",
";",
"if",
"(",
"'XXXX'",
"===",
"$",
"checksum",
")",
"{",
"// 'XXXX' is allowed as checksum replacement",
"return",
"true",
";",
"}",
"$",
"nodeId",
"=",
"substr",
"(",
"$",
"address",
",",
"0",
",",
"4",
")",
";",
"$",
"userId",
"=",
"substr",
"(",
"$",
"address",
",",
"5",
",",
"8",
")",
";",
"$",
"checksumComputed",
"=",
"AdsChecksumGenerator",
"::",
"getAccountChecksum",
"(",
"hexdec",
"(",
"$",
"nodeId",
")",
",",
"hexdec",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"checksum",
"===",
"$",
"checksumComputed",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks, if account address is in proper format.
@param string $address account address
@return bool true if address is valid, false otherwise
|
[
"Checks",
"if",
"account",
"address",
"is",
"in",
"proper",
"format",
"."
] |
b9a897219dfa60a316a29191dbeb836c5e1aa760
|
https://github.com/adshares/ads-php-client/blob/b9a897219dfa60a316a29191dbeb836c5e1aa760/src/Util/AdsValidator.php#L36-L52
|
222,279
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.setConfigDropAllDebugLog
|
public static function setConfigDropAllDebugLog()
{
self::setConfig('log', 'loadFile', false);
self::setConfig('log', 'loadRef', false);
self::setConfig('log', 'replaceRef', false);
self::setConfig('log', 'registerRef', false);
self::setConfig('log', 'dropRef', false);
self::setConfig('log', 'reference', false);
self::setConfig('log', 'decode', false);
self::setConfig('log', 'validate', false);
self::setConfig('log', 'model', false);
self::setConfig('log', 'validation', false);
self::setConfig('log', 'exception', false);
self::setConfig('log', 'debug', false);
}
|
php
|
public static function setConfigDropAllDebugLog()
{
self::setConfig('log', 'loadFile', false);
self::setConfig('log', 'loadRef', false);
self::setConfig('log', 'replaceRef', false);
self::setConfig('log', 'registerRef', false);
self::setConfig('log', 'dropRef', false);
self::setConfig('log', 'reference', false);
self::setConfig('log', 'decode', false);
self::setConfig('log', 'validate', false);
self::setConfig('log', 'model', false);
self::setConfig('log', 'validation', false);
self::setConfig('log', 'exception', false);
self::setConfig('log', 'debug', false);
}
|
[
"public",
"static",
"function",
"setConfigDropAllDebugLog",
"(",
")",
"{",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'loadFile'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'loadRef'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'replaceRef'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'registerRef'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'dropRef'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'reference'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'decode'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'validate'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'model'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'validation'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'exception'",
",",
"false",
")",
";",
"self",
"::",
"setConfig",
"(",
"'log'",
",",
"'debug'",
",",
"false",
")",
";",
"}"
] |
Method to disable all debug log
|
[
"Method",
"to",
"disable",
"all",
"debug",
"log"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L143-L157
|
222,280
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.getConfig
|
public static function getConfig($optionGroup, $optionName)
{
if (!array_key_exists($optionGroup, self::$config) || !is_array(self::$config[$optionGroup])) {
return;
}
if (!array_key_exists($optionName, self::$config[$optionGroup])) {
return;
}
return self::$config[$optionGroup][$optionName];
}
|
php
|
public static function getConfig($optionGroup, $optionName)
{
if (!array_key_exists($optionGroup, self::$config) || !is_array(self::$config[$optionGroup])) {
return;
}
if (!array_key_exists($optionName, self::$config[$optionGroup])) {
return;
}
return self::$config[$optionGroup][$optionName];
}
|
[
"public",
"static",
"function",
"getConfig",
"(",
"$",
"optionGroup",
",",
"$",
"optionName",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"optionGroup",
",",
"self",
"::",
"$",
"config",
")",
"||",
"!",
"is_array",
"(",
"self",
"::",
"$",
"config",
"[",
"$",
"optionGroup",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"optionName",
",",
"self",
"::",
"$",
"config",
"[",
"$",
"optionGroup",
"]",
")",
")",
"{",
"return",
";",
"}",
"return",
"self",
"::",
"$",
"config",
"[",
"$",
"optionGroup",
"]",
"[",
"$",
"optionName",
"]",
";",
"}"
] |
Retrieve a config value
@param string $optionGroup
@param string $optionName
@return mixed
|
[
"Retrieve",
"a",
"config",
"value"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L165-L176
|
222,281
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.checkDataIsEmpty
|
public function checkDataIsEmpty()
{
if ($this->isDataExists() === false) {
$this->contextDataEmpty = true;
}
elseif (is_object($this->getDataValue())) {
$this->contextDataEmpty = false;
}
elseif (is_array($this->getDataValue())) {
$this->contextDataEmpty = false;
}
elseif (is_string($this->getDataValue())) {
$this->contextDataEmpty = (bool) (strlen($this->getDataValue()) == 0);
}
elseif (is_numeric($this->getDataValue())) {
$this->contextDataEmpty = false;
}
else {
$this->contextDataEmpty = (bool) $this->checkIsEmpty($this->getDataValue());
}
}
|
php
|
public function checkDataIsEmpty()
{
if ($this->isDataExists() === false) {
$this->contextDataEmpty = true;
}
elseif (is_object($this->getDataValue())) {
$this->contextDataEmpty = false;
}
elseif (is_array($this->getDataValue())) {
$this->contextDataEmpty = false;
}
elseif (is_string($this->getDataValue())) {
$this->contextDataEmpty = (bool) (strlen($this->getDataValue()) == 0);
}
elseif (is_numeric($this->getDataValue())) {
$this->contextDataEmpty = false;
}
else {
$this->contextDataEmpty = (bool) $this->checkIsEmpty($this->getDataValue());
}
}
|
[
"public",
"function",
"checkDataIsEmpty",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDataExists",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"true",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"false",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"false",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"(",
"bool",
")",
"(",
"strlen",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
"==",
"0",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"checkIsEmpty",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"}",
"}"
] |
Check if the loaded data are empty or not
|
[
"Check",
"if",
"the",
"loaded",
"data",
"are",
"empty",
"or",
"not"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L195-L215
|
222,282
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.dataLoad
|
public function dataLoad()
{
$paramName = $this->__get('DataPath');
$paramName = array_pop($paramName);
$this->contextDataExists = false;
$this->contextDataValue = null;
if ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_REQUEST) {
return $this->loadRequestBody();
}
elseif ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_RESPONSE) {
return $this->loadResponseBody();
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
return $this->loadRequestHeader($paramName);
}
elseif ($this->getType() === self::TYPE_RESPONSE && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
return $this->loadResponseHeader($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM) {
return $this->loadRequestFormData($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_PATH) {
return $this->loadRequestPath($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY) {
return $this->loadRequestQuery($paramName);
}
elseif ($this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && !$this->checkIsEmpty($this->getDataValue())) {
if (is_array($this->getDataValue()) && array_key_exists($paramName, $this->getDataValue())) {
$this->contextDataExists = true;
$value = $this->getDataValue();
$this->contextDataValue = $value[$paramName];
}
elseif (is_object($this->getDataValue()) && property_exists($this->getDataValue(), $paramName)) {
$this->contextDataExists = true;
$this->contextDataValue = $this->getDataValue()->$paramName;
}
}
return $this->checkDataIsEmpty();
}
|
php
|
public function dataLoad()
{
$paramName = $this->__get('DataPath');
$paramName = array_pop($paramName);
$this->contextDataExists = false;
$this->contextDataValue = null;
if ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_REQUEST) {
return $this->loadRequestBody();
}
elseif ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_RESPONSE) {
return $this->loadResponseBody();
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
return $this->loadRequestHeader($paramName);
}
elseif ($this->getType() === self::TYPE_RESPONSE && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
return $this->loadResponseHeader($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM) {
return $this->loadRequestFormData($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_PATH) {
return $this->loadRequestPath($paramName);
}
elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY) {
return $this->loadRequestQuery($paramName);
}
elseif ($this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && !$this->checkIsEmpty($this->getDataValue())) {
if (is_array($this->getDataValue()) && array_key_exists($paramName, $this->getDataValue())) {
$this->contextDataExists = true;
$value = $this->getDataValue();
$this->contextDataValue = $value[$paramName];
}
elseif (is_object($this->getDataValue()) && property_exists($this->getDataValue(), $paramName)) {
$this->contextDataExists = true;
$this->contextDataValue = $this->getDataValue()->$paramName;
}
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"dataLoad",
"(",
")",
"{",
"$",
"paramName",
"=",
"$",
"this",
"->",
"__get",
"(",
"'DataPath'",
")",
";",
"$",
"paramName",
"=",
"array_pop",
"(",
"$",
"paramName",
")",
";",
"$",
"this",
"->",
"contextDataExists",
"=",
"false",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"if",
"(",
"$",
"paramName",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_BODY",
"&&",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_REQUEST",
")",
"{",
"return",
"$",
"this",
"->",
"loadRequestBody",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"paramName",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_BODY",
"&&",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_RESPONSE",
")",
"{",
"return",
"$",
"this",
"->",
"loadResponseBody",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_REQUEST",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_HEADER",
")",
"{",
"return",
"$",
"this",
"->",
"loadRequestHeader",
"(",
"$",
"paramName",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_RESPONSE",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_HEADER",
")",
"{",
"return",
"$",
"this",
"->",
"loadResponseHeader",
"(",
"$",
"paramName",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_REQUEST",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_FORM",
")",
"{",
"return",
"$",
"this",
"->",
"loadRequestFormData",
"(",
"$",
"paramName",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_REQUEST",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_PATH",
")",
"{",
"return",
"$",
"this",
"->",
"loadRequestPath",
"(",
"$",
"paramName",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"TYPE_REQUEST",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_QUERY",
")",
"{",
"return",
"$",
"this",
"->",
"loadRequestQuery",
"(",
"$",
"paramName",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getLocation",
"(",
")",
"===",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_BODY",
"&&",
"!",
"$",
"this",
"->",
"checkIsEmpty",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
"&&",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getDataValue",
"(",
")",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"value",
"[",
"$",
"paramName",
"]",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
"&&",
"property_exists",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
",",
"$",
"paramName",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"this",
"->",
"getDataValue",
"(",
")",
"->",
"$",
"paramName",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Load data and check it based on local context definition
@return void
|
[
"Load",
"data",
"and",
"check",
"it",
"based",
"on",
"local",
"context",
"definition"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L238-L280
|
222,283
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadRequestFormData
|
public function loadRequestFormData($paramName)
{
if (array_key_exists($paramName, $_POST)) {
$this->contextDataExists = true;
$this->contextDataValue = $_POST[$paramName];
}
elseif (array_key_exists($paramName, $_FILES)) {
$this->contextDataExists = true;
$this->contextDataValue = $_FILES[$paramName];
}
return $this->checkDataIsEmpty();
}
|
php
|
public function loadRequestFormData($paramName)
{
if (array_key_exists($paramName, $_POST)) {
$this->contextDataExists = true;
$this->contextDataValue = $_POST[$paramName];
}
elseif (array_key_exists($paramName, $_FILES)) {
$this->contextDataExists = true;
$this->contextDataValue = $_FILES[$paramName];
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"loadRequestFormData",
"(",
"$",
"paramName",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"_POST",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"_POST",
"[",
"$",
"paramName",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"_FILES",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"_FILES",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Filtering the request form data and files,
load the data and check it
@param string $paramName
@return void
|
[
"Filtering",
"the",
"request",
"form",
"data",
"and",
"files",
"load",
"the",
"data",
"and",
"check",
"it"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L308-L320
|
222,284
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadRequestPath
|
public function loadRequestPath($paramName)
{
// parse from the end to the top
$path = array_reverse(explode('/', $this->contextRequestPath));
/**
* -1 => current params
* -2 => method
* -3 => route
*/
$datapath = $this->__get('DataPath');
$partDataPath = null;
while (true) {
if (!is_array($datapath) || empty($datapath)) {
$partDataPath = null;
break;
}
$partDataPath = array_pop($datapath);
if (substr($partDataPath, 0, 1) == '/') {
break;
}
}
// parse from the end to the top
$route = array_reverse(explode('/', $partDataPath));
foreach ($route as $key => $partRoute) {
if ($partRoute != '{' . $paramName . '}') {
continue;
}
if (!array_key_exists($key, $path)) {
$this->contextDataExists = false;
$this->contextDataValue = null;
break;
}
$this->contextDataExists = true;
$this->contextDataValue = urldecode($path[$key]);
}
return $this->checkDataIsEmpty();
}
|
php
|
public function loadRequestPath($paramName)
{
// parse from the end to the top
$path = array_reverse(explode('/', $this->contextRequestPath));
/**
* -1 => current params
* -2 => method
* -3 => route
*/
$datapath = $this->__get('DataPath');
$partDataPath = null;
while (true) {
if (!is_array($datapath) || empty($datapath)) {
$partDataPath = null;
break;
}
$partDataPath = array_pop($datapath);
if (substr($partDataPath, 0, 1) == '/') {
break;
}
}
// parse from the end to the top
$route = array_reverse(explode('/', $partDataPath));
foreach ($route as $key => $partRoute) {
if ($partRoute != '{' . $paramName . '}') {
continue;
}
if (!array_key_exists($key, $path)) {
$this->contextDataExists = false;
$this->contextDataValue = null;
break;
}
$this->contextDataExists = true;
$this->contextDataValue = urldecode($path[$key]);
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"loadRequestPath",
"(",
"$",
"paramName",
")",
"{",
"// parse from the end to the top",
"$",
"path",
"=",
"array_reverse",
"(",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"contextRequestPath",
")",
")",
";",
"/**\n * -1 => current params\n * -2 => method\n * -3 => route\n */",
"$",
"datapath",
"=",
"$",
"this",
"->",
"__get",
"(",
"'DataPath'",
")",
";",
"$",
"partDataPath",
"=",
"null",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"datapath",
")",
"||",
"empty",
"(",
"$",
"datapath",
")",
")",
"{",
"$",
"partDataPath",
"=",
"null",
";",
"break",
";",
"}",
"$",
"partDataPath",
"=",
"array_pop",
"(",
"$",
"datapath",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"partDataPath",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"break",
";",
"}",
"}",
"// parse from the end to the top",
"$",
"route",
"=",
"array_reverse",
"(",
"explode",
"(",
"'/'",
",",
"$",
"partDataPath",
")",
")",
";",
"foreach",
"(",
"$",
"route",
"as",
"$",
"key",
"=>",
"$",
"partRoute",
")",
"{",
"if",
"(",
"$",
"partRoute",
"!=",
"'{'",
".",
"$",
"paramName",
".",
"'}'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"false",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"break",
";",
"}",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"urldecode",
"(",
"$",
"path",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Filtering the request path to identify the path parameters,
load the data and check it
@param string $paramName
@return void
|
[
"Filtering",
"the",
"request",
"path",
"to",
"identify",
"the",
"path",
"parameters",
"load",
"the",
"data",
"and",
"check",
"it"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L328-L374
|
222,285
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.getRequestQueryKey
|
public function getRequestQueryKey()
{
$uri = explode('?', $this->getEnv('REQUEST_URI'));
array_shift($uri);
parse_str(implode('?', $uri), $qrs);
return array_keys($qrs);
}
|
php
|
public function getRequestQueryKey()
{
$uri = explode('?', $this->getEnv('REQUEST_URI'));
array_shift($uri);
parse_str(implode('?', $uri), $qrs);
return array_keys($qrs);
}
|
[
"public",
"function",
"getRequestQueryKey",
"(",
")",
"{",
"$",
"uri",
"=",
"explode",
"(",
"'?'",
",",
"$",
"this",
"->",
"getEnv",
"(",
"'REQUEST_URI'",
")",
")",
";",
"array_shift",
"(",
"$",
"uri",
")",
";",
"parse_str",
"(",
"implode",
"(",
"'?'",
",",
"$",
"uri",
")",
",",
"$",
"qrs",
")",
";",
"return",
"array_keys",
"(",
"$",
"qrs",
")",
";",
"}"
] |
return the complete list of all params send in query string
@return array
|
[
"return",
"the",
"complete",
"list",
"of",
"all",
"params",
"send",
"in",
"query",
"string"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L380-L388
|
222,286
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadRequestQuery
|
public function loadRequestQuery($paramName)
{
$uri = explode('?', $this->getEnv('REQUEST_URI'));
array_shift($uri);
$uri = implode('?', $uri);
/**
* Override this method to use parsing query string PHP method
* and not new standard of queryString
*/
$qrs = $this->parseQueryAsMulti($uri);
if (array_key_exists($paramName, $qrs)) {
$this->contextDataExists = true;
$this->contextDataValue = $qrs[$paramName];
}
return $this->checkDataIsEmpty();
}
|
php
|
public function loadRequestQuery($paramName)
{
$uri = explode('?', $this->getEnv('REQUEST_URI'));
array_shift($uri);
$uri = implode('?', $uri);
/**
* Override this method to use parsing query string PHP method
* and not new standard of queryString
*/
$qrs = $this->parseQueryAsMulti($uri);
if (array_key_exists($paramName, $qrs)) {
$this->contextDataExists = true;
$this->contextDataValue = $qrs[$paramName];
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"loadRequestQuery",
"(",
"$",
"paramName",
")",
"{",
"$",
"uri",
"=",
"explode",
"(",
"'?'",
",",
"$",
"this",
"->",
"getEnv",
"(",
"'REQUEST_URI'",
")",
")",
";",
"array_shift",
"(",
"$",
"uri",
")",
";",
"$",
"uri",
"=",
"implode",
"(",
"'?'",
",",
"$",
"uri",
")",
";",
"/**\n * Override this method to use parsing query string PHP method\n * and not new standard of queryString\n */",
"$",
"qrs",
"=",
"$",
"this",
"->",
"parseQueryAsMulti",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"qrs",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"qrs",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Filtering the request querystring, load the data and check it
@param string $paramName
@return void
|
[
"Filtering",
"the",
"request",
"querystring",
"load",
"the",
"data",
"and",
"check",
"it"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L395-L413
|
222,287
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadRequestHeader
|
public function loadRequestHeader($paramName)
{
$headers = $this->getRequestHeader();
if (array_key_exists($paramName, $headers)) {
$this->contextDataExists = true;
$this->contextDataValue = $headers[$paramName];
}
return $this->checkDataIsEmpty();
}
|
php
|
public function loadRequestHeader($paramName)
{
$headers = $this->getRequestHeader();
if (array_key_exists($paramName, $headers)) {
$this->contextDataExists = true;
$this->contextDataValue = $headers[$paramName];
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"loadRequestHeader",
"(",
"$",
"paramName",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getRequestHeader",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"headers",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"headers",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Filtering the request header, load the data and check it
@param string $paramName
@return void
|
[
"Filtering",
"the",
"request",
"header",
"load",
"the",
"data",
"and",
"check",
"it"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L458-L468
|
222,288
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadResponseHeader
|
public function loadResponseHeader($paramName)
{
$headers = $this->getResponseHeader();
if (array_key_exists($paramName, $headers)) {
$this->contextDataExists = true;
$this->contextDataValue = $headers[$paramName];
}
return $this->checkDataIsEmpty();
}
|
php
|
public function loadResponseHeader($paramName)
{
$headers = $this->getResponseHeader();
if (array_key_exists($paramName, $headers)) {
$this->contextDataExists = true;
$this->contextDataValue = $headers[$paramName];
}
return $this->checkDataIsEmpty();
}
|
[
"public",
"function",
"loadResponseHeader",
"(",
"$",
"paramName",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getResponseHeader",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"paramName",
",",
"$",
"headers",
")",
")",
"{",
"$",
"this",
"->",
"contextDataExists",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"$",
"headers",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}"
] |
Filtering the response header, load the data and check it
@param string $paramName
@return void
|
[
"Filtering",
"the",
"response",
"header",
"load",
"the",
"data",
"and",
"check",
"it"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L475-L485
|
222,289
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadRequestBody
|
public function loadRequestBody()
{
if (array_key_exists('php://input', $this->mockedData)) {
$this->loadBodyByContent($this->getRequestHeader(), $this->mockedData['php://input']);
}
else {
$this->loadBodyByContent($this->getRequestHeader(), file_get_contents("php://input"));
}
}
|
php
|
public function loadRequestBody()
{
if (array_key_exists('php://input', $this->mockedData)) {
$this->loadBodyByContent($this->getRequestHeader(), $this->mockedData['php://input']);
}
else {
$this->loadBodyByContent($this->getRequestHeader(), file_get_contents("php://input"));
}
}
|
[
"public",
"function",
"loadRequestBody",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'php://input'",
",",
"$",
"this",
"->",
"mockedData",
")",
")",
"{",
"$",
"this",
"->",
"loadBodyByContent",
"(",
"$",
"this",
"->",
"getRequestHeader",
"(",
")",
",",
"$",
"this",
"->",
"mockedData",
"[",
"'php://input'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loadBodyByContent",
"(",
"$",
"this",
"->",
"getRequestHeader",
"(",
")",
",",
"file_get_contents",
"(",
"\"php://input\"",
")",
")",
";",
"}",
"}"
] |
Method to load Request body identify by his content type header
And only if a content length is defined and > 0
@return void
|
[
"Method",
"to",
"load",
"Request",
"body",
"identify",
"by",
"his",
"content",
"type",
"header",
"And",
"only",
"if",
"a",
"content",
"length",
"is",
"defined",
"and",
">",
"0"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L492-L500
|
222,290
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.loadResponseBody
|
public function loadResponseBody()
{
if (array_key_exists('php://output', $this->mockedData)) {
$this->loadBodyByContent($this->getResponseHeader(), $this->mockedData['php://output']);
}
else {
$this->loadBodyByContent($this->getResponseHeader(), file_get_contents("php://output"));
}
}
|
php
|
public function loadResponseBody()
{
if (array_key_exists('php://output', $this->mockedData)) {
$this->loadBodyByContent($this->getResponseHeader(), $this->mockedData['php://output']);
}
else {
$this->loadBodyByContent($this->getResponseHeader(), file_get_contents("php://output"));
}
}
|
[
"public",
"function",
"loadResponseBody",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'php://output'",
",",
"$",
"this",
"->",
"mockedData",
")",
")",
"{",
"$",
"this",
"->",
"loadBodyByContent",
"(",
"$",
"this",
"->",
"getResponseHeader",
"(",
")",
",",
"$",
"this",
"->",
"mockedData",
"[",
"'php://output'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loadBodyByContent",
"(",
"$",
"this",
"->",
"getResponseHeader",
"(",
")",
",",
"file_get_contents",
"(",
"\"php://output\"",
")",
")",
";",
"}",
"}"
] |
Method to load Response body identify by his content type header
And only if a content length is defined and > 0
|
[
"Method",
"to",
"load",
"Response",
"body",
"identify",
"by",
"his",
"content",
"type",
"header",
"And",
"only",
"if",
"a",
"content",
"length",
"is",
"defined",
"and",
">",
"0"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L506-L514
|
222,291
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.buildBodyJson
|
public function buildBodyJson($contents)
{
$this->contextDataType = self::CONTENT_TYPE_JSON;
$this->contextDataExists = (bool) (strlen($contents) > 0);
$this->contextDataValue = json_decode($contents, false);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError = array(array('code' => json_last_error(), 'message' => json_last_error_msg()));
}
else {
$this->contextDecodeError = array(array('code' => json_last_error(), 'message' => null));
}
}
else {
$this->checkDataIsEmpty();
}
}
|
php
|
public function buildBodyJson($contents)
{
$this->contextDataType = self::CONTENT_TYPE_JSON;
$this->contextDataExists = (bool) (strlen($contents) > 0);
$this->contextDataValue = json_decode($contents, false);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError = array(array('code' => json_last_error(), 'message' => json_last_error_msg()));
}
else {
$this->contextDecodeError = array(array('code' => json_last_error(), 'message' => null));
}
}
else {
$this->checkDataIsEmpty();
}
}
|
[
"public",
"function",
"buildBodyJson",
"(",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"contextDataType",
"=",
"self",
"::",
"CONTENT_TYPE_JSON",
";",
"$",
"this",
"->",
"contextDataExists",
"=",
"(",
"bool",
")",
"(",
"strlen",
"(",
"$",
"contents",
")",
">",
"0",
")",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"json_decode",
"(",
"$",
"contents",
",",
"false",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"if",
"(",
"function_exists",
"(",
"'json_last_error_msg'",
")",
")",
"{",
"$",
"this",
"->",
"contextDecodeError",
"=",
"array",
"(",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"json_last_error_msg",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDecodeError",
"=",
"array",
"(",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"null",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}",
"}"
] |
Method to build the body mixed data from a JSON Raw Body
@param string $contents
|
[
"Method",
"to",
"build",
"the",
"body",
"mixed",
"data",
"from",
"a",
"JSON",
"Raw",
"Body"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L559-L578
|
222,292
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.buildBodyXml
|
public function buildBodyXml($contents)
{
$this->contextDataType = self::CONTENT_TYPE_XML;
$this->contextDataExists = (bool) (strlen($contents) > 0);
$this->contextDataValue = simplexml_load_string($contents);
if ($this->contextDataValue === false) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
$this->contextDecodeError = array();
foreach (libxml_get_errors() as $error) {
$this->contextDecodeError[] = array('code' => $error->$code, 'message' => $error->message);
}
}
else {
$this->contextDataValue = \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
}
else {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
}
}
else {
$this->contextDataValue = json_decode($this->getDataValue(), false);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
}
else {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
}
}
else {
$this->checkDataIsEmpty();
}
}
}
}
|
php
|
public function buildBodyXml($contents)
{
$this->contextDataType = self::CONTENT_TYPE_XML;
$this->contextDataExists = (bool) (strlen($contents) > 0);
$this->contextDataValue = simplexml_load_string($contents);
if ($this->contextDataValue === false) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
$this->contextDecodeError = array();
foreach (libxml_get_errors() as $error) {
$this->contextDecodeError[] = array('code' => $error->$code, 'message' => $error->message);
}
}
else {
$this->contextDataValue = \SwaggerValidator\Common\Collection::jsonEncode($this->getDataValue());
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
}
else {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
}
}
else {
$this->contextDataValue = json_decode($this->getDataValue(), false);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->contextDataEmpty = true;
$this->contextDataValue = null;
if (function_exists('json_last_error_msg')) {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => json_last_error_msg());
}
else {
$this->contextDecodeError[] = array('code' => json_last_error(), 'message' => null);
}
}
else {
$this->checkDataIsEmpty();
}
}
}
}
|
[
"public",
"function",
"buildBodyXml",
"(",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"contextDataType",
"=",
"self",
"::",
"CONTENT_TYPE_XML",
";",
"$",
"this",
"->",
"contextDataExists",
"=",
"(",
"bool",
")",
"(",
"strlen",
"(",
"$",
"contents",
")",
">",
"0",
")",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"simplexml_load_string",
"(",
"$",
"contents",
")",
";",
"if",
"(",
"$",
"this",
"->",
"contextDataValue",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"$",
"this",
"->",
"contextDecodeError",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"contextDecodeError",
"[",
"]",
"=",
"array",
"(",
"'code'",
"=>",
"$",
"error",
"->",
"$",
"code",
",",
"'message'",
"=>",
"$",
"error",
"->",
"message",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDataValue",
"=",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Collection",
"::",
"jsonEncode",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"if",
"(",
"function_exists",
"(",
"'json_last_error_msg'",
")",
")",
"{",
"$",
"this",
"->",
"contextDecodeError",
"[",
"]",
"=",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"json_last_error_msg",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDecodeError",
"[",
"]",
"=",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"null",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDataValue",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"$",
"this",
"->",
"contextDataEmpty",
"=",
"true",
";",
"$",
"this",
"->",
"contextDataValue",
"=",
"null",
";",
"if",
"(",
"function_exists",
"(",
"'json_last_error_msg'",
")",
")",
"{",
"$",
"this",
"->",
"contextDecodeError",
"[",
"]",
"=",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"json_last_error_msg",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contextDecodeError",
"[",
"]",
"=",
"array",
"(",
"'code'",
"=>",
"json_last_error",
"(",
")",
",",
"'message'",
"=>",
"null",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"checkDataIsEmpty",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Method to build the body mixed data from a XML Raw Body
@param string $contents
|
[
"Method",
"to",
"build",
"the",
"body",
"mixed",
"data",
"from",
"a",
"XML",
"Raw",
"Body"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L584-L630
|
222,293
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.setSandBox
|
public function setSandBox()
{
if ($this->getType() !== self::TYPE_REQUEST) {
return $this;
}
$last = $this->getLastDataPath();
$last = array_pop($last);
switch ($this->getLocation()) {
case \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY:
\SwaggerValidator\Common\Sandbox::getInstance()->setBody($this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM:
\SwaggerValidator\Common\Sandbox::getInstance()->setForm($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER:
\SwaggerValidator\Common\Sandbox::getInstance()->setHeader($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_PATH:
\SwaggerValidator\Common\Sandbox::getInstance()->setPath($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY:
\SwaggerValidator\Common\Sandbox::getInstance()->setQueryString($last, $this->getDataValue());
break;
}
return $this;
}
|
php
|
public function setSandBox()
{
if ($this->getType() !== self::TYPE_REQUEST) {
return $this;
}
$last = $this->getLastDataPath();
$last = array_pop($last);
switch ($this->getLocation()) {
case \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY:
\SwaggerValidator\Common\Sandbox::getInstance()->setBody($this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM:
\SwaggerValidator\Common\Sandbox::getInstance()->setForm($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER:
\SwaggerValidator\Common\Sandbox::getInstance()->setHeader($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_PATH:
\SwaggerValidator\Common\Sandbox::getInstance()->setPath($last, $this->getDataValue());
break;
case \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY:
\SwaggerValidator\Common\Sandbox::getInstance()->setQueryString($last, $this->getDataValue());
break;
}
return $this;
}
|
[
"public",
"function",
"setSandBox",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"!==",
"self",
"::",
"TYPE_REQUEST",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"last",
"=",
"$",
"this",
"->",
"getLastDataPath",
"(",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"last",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
"{",
"case",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_BODY",
":",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Sandbox",
"::",
"getInstance",
"(",
")",
"->",
"setBody",
"(",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"break",
";",
"case",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_FORM",
":",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Sandbox",
"::",
"getInstance",
"(",
")",
"->",
"setForm",
"(",
"$",
"last",
",",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"break",
";",
"case",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_HEADER",
":",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Sandbox",
"::",
"getInstance",
"(",
")",
"->",
"setHeader",
"(",
"$",
"last",
",",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"break",
";",
"case",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_PATH",
":",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Sandbox",
"::",
"getInstance",
"(",
")",
"->",
"setPath",
"(",
"$",
"last",
",",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"break",
";",
"case",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_QUERY",
":",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"Sandbox",
"::",
"getInstance",
"(",
")",
"->",
"setQueryString",
"(",
"$",
"last",
",",
"$",
"this",
"->",
"getDataValue",
"(",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adding validated params to check
This method improve the TOOMANY errors at the end
of the validation process
@return \SwaggerValidator\Common\Context
|
[
"Adding",
"validated",
"params",
"to",
"check",
"This",
"method",
"improve",
"the",
"TOOMANY",
"errors",
"at",
"the",
"end",
"of",
"the",
"validation",
"process"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L656-L688
|
222,294
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.getRequestDataKeys
|
public function getRequestDataKeys()
{
if ($this->getType() !== self::TYPE_REQUEST) {
return array();
}
if (array_key_exists('php://input', $this->mockedData)) {
$data = $this->mockedData['php://input'];
}
else {
$data = file_get_contents("php://input");
}
return array(
\SwaggerValidator\Common\FactorySwagger::LOCATION_BODY => (bool) (strlen($data) > 0),
\SwaggerValidator\Common\FactorySwagger::LOCATION_FORM => $this->getRequestFormDataKey(),
\SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY => $this->getRequestQueryKey(),
);
}
|
php
|
public function getRequestDataKeys()
{
if ($this->getType() !== self::TYPE_REQUEST) {
return array();
}
if (array_key_exists('php://input', $this->mockedData)) {
$data = $this->mockedData['php://input'];
}
else {
$data = file_get_contents("php://input");
}
return array(
\SwaggerValidator\Common\FactorySwagger::LOCATION_BODY => (bool) (strlen($data) > 0),
\SwaggerValidator\Common\FactorySwagger::LOCATION_FORM => $this->getRequestFormDataKey(),
\SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY => $this->getRequestQueryKey(),
);
}
|
[
"public",
"function",
"getRequestDataKeys",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"!==",
"self",
"::",
"TYPE_REQUEST",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'php://input'",
",",
"$",
"this",
"->",
"mockedData",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"mockedData",
"[",
"'php://input'",
"]",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"file_get_contents",
"(",
"\"php://input\"",
")",
";",
"}",
"return",
"array",
"(",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_BODY",
"=>",
"(",
"bool",
")",
"(",
"strlen",
"(",
"$",
"data",
")",
">",
"0",
")",
",",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_FORM",
"=>",
"$",
"this",
"->",
"getRequestFormDataKey",
"(",
")",
",",
"\\",
"SwaggerValidator",
"\\",
"Common",
"\\",
"FactorySwagger",
"::",
"LOCATION_QUERY",
"=>",
"$",
"this",
"->",
"getRequestQueryKey",
"(",
")",
",",
")",
";",
"}"
] |
Method to list all received params name by location
@return array
|
[
"Method",
"to",
"list",
"all",
"received",
"params",
"name",
"by",
"location"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L694-L712
|
222,295
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.getEnv
|
public function getEnv($name)
{
if (array_key_exists($name, $this->mockedData)) {
return $this->mockedData[$name];
}
return getenv($name);
}
|
php
|
public function getEnv($name)
{
if (array_key_exists($name, $this->mockedData)) {
return $this->mockedData[$name];
}
return getenv($name);
}
|
[
"public",
"function",
"getEnv",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"mockedData",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mockedData",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"getenv",
"(",
"$",
"name",
")",
";",
"}"
] |
Method to add capability of override the getenv function of PHP
for example to get env data in a sandbox
@param string $name
@return mixed
|
[
"Method",
"to",
"add",
"capability",
"of",
"override",
"the",
"getenv",
"function",
"of",
"PHP",
"for",
"example",
"to",
"get",
"env",
"data",
"in",
"a",
"sandbox"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L730-L737
|
222,296
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.mock
|
public function mock($options = array())
{
$this->mockedData = $options;
if (empty($this->mockedData) || !is_array($this->mockedData)) {
$this->mockedData = array();
}
}
|
php
|
public function mock($options = array())
{
$this->mockedData = $options;
if (empty($this->mockedData) || !is_array($this->mockedData)) {
$this->mockedData = array();
}
}
|
[
"public",
"function",
"mock",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"mockedData",
"=",
"$",
"options",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mockedData",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"mockedData",
")",
")",
"{",
"$",
"this",
"->",
"mockedData",
"=",
"array",
"(",
")",
";",
"}",
"}"
] |
Method to define a batch of data to be used to
simulate the playback of external data
@param array $options
|
[
"Method",
"to",
"define",
"a",
"batch",
"of",
"data",
"to",
"be",
"used",
"to",
"simulate",
"the",
"playback",
"of",
"external",
"data"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L772-L779
|
222,297
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.cleanParams
|
public function cleanParams()
{
$_GET = array();
$_POST = array();
$_FILES = array();
$_COOKIE = array();
foreach ($this->getRequestHeader() as $key) {
if (array_key_exists($key, $_SERVER)) {
unset($_SERVER[$key]);
}
}
}
|
php
|
public function cleanParams()
{
$_GET = array();
$_POST = array();
$_FILES = array();
$_COOKIE = array();
foreach ($this->getRequestHeader() as $key) {
if (array_key_exists($key, $_SERVER)) {
unset($_SERVER[$key]);
}
}
}
|
[
"public",
"function",
"cleanParams",
"(",
")",
"{",
"$",
"_GET",
"=",
"array",
"(",
")",
";",
"$",
"_POST",
"=",
"array",
"(",
")",
";",
"$",
"_FILES",
"=",
"array",
"(",
")",
";",
"$",
"_COOKIE",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRequestHeader",
"(",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"_SERVER",
")",
")",
"{",
"unset",
"(",
"$",
"_SERVER",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] |
Used to clean params if validation error occured for mode PASS
|
[
"Used",
"to",
"clean",
"params",
"if",
"validation",
"error",
"occured",
"for",
"mode",
"PASS"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L784-L796
|
222,298
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.logLoadFile
|
public function logLoadFile($file, $method = null, $line = null)
{
if (self::getConfig('log', 'loadFile')) {
$this->logMessage('LOAD FILE', 'Loading File : "' . $file . '"', $method, $line);
}
}
|
php
|
public function logLoadFile($file, $method = null, $line = null)
{
if (self::getConfig('log', 'loadFile')) {
$this->logMessage('LOAD FILE', 'Loading File : "' . $file . '"', $method, $line);
}
}
|
[
"public",
"function",
"logLoadFile",
"(",
"$",
"file",
",",
"$",
"method",
"=",
"null",
",",
"$",
"line",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"getConfig",
"(",
"'log'",
",",
"'loadFile'",
")",
")",
"{",
"$",
"this",
"->",
"logMessage",
"(",
"'LOAD FILE'",
",",
"'Loading File : \"'",
".",
"$",
"file",
".",
"'\"'",
",",
"$",
"method",
",",
"$",
"line",
")",
";",
"}",
"}"
] |
Log loading file
@param string $file
@param string $method
@param int $line
|
[
"Log",
"loading",
"file"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L804-L809
|
222,299
|
nabbar/SwaggerValidator-PHP
|
src/Common/Context.php
|
Context.logDecode
|
public function logDecode($className, $method = null, $line = null)
{
if (self::getConfig('log', 'decode')) {
$this->logMessage('DECODE', 'Decoding Path "' . $this->getDataPath() . '" As "' . $className . '"', $method, $line);
}
}
|
php
|
public function logDecode($className, $method = null, $line = null)
{
if (self::getConfig('log', 'decode')) {
$this->logMessage('DECODE', 'Decoding Path "' . $this->getDataPath() . '" As "' . $className . '"', $method, $line);
}
}
|
[
"public",
"function",
"logDecode",
"(",
"$",
"className",
",",
"$",
"method",
"=",
"null",
",",
"$",
"line",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"getConfig",
"(",
"'log'",
",",
"'decode'",
")",
")",
"{",
"$",
"this",
"->",
"logMessage",
"(",
"'DECODE'",
",",
"'Decoding Path \"'",
".",
"$",
"this",
"->",
"getDataPath",
"(",
")",
".",
"'\" As \"'",
".",
"$",
"className",
".",
"'\"'",
",",
"$",
"method",
",",
"$",
"line",
")",
";",
"}",
"}"
] |
Log a decoding json mixed data as SwaggerValidator PHP object
@param string $decodePath
@param string $decodeType
@param string $method
@param int $line
|
[
"Log",
"a",
"decoding",
"json",
"mixed",
"data",
"as",
"SwaggerValidator",
"PHP",
"object"
] |
c3518c53beed71b653a98ea7d56bd12a580d5aa8
|
https://github.com/nabbar/SwaggerValidator-PHP/blob/c3518c53beed71b653a98ea7d56bd12a580d5aa8/src/Common/Context.php#L818-L823
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.