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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,100 | canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getEpisodesSummary | public function getEpisodesSummary(int $id): SeriesStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/episodes/summary');
return DataParser::parseData($json, SeriesStatistics::class);
} | php | public function getEpisodesSummary(int $id): SeriesStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/episodes/summary');
return DataParser::parseData($json, SeriesStatistics::class);
} | [
"public",
"function",
"getEpisodesSummary",
"(",
"int",
"$",
"id",
")",
":",
"SeriesStatistics",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/episodes/summary'",
")",
";",
"return",
"DataParser",
"::",
"parseData",
"(",
"$",
"json",
",",
"SeriesStatistics",
"::",
"class",
")",
";",
"}"
] | Returns statistics about how many seasons & episodes were aired.
@param int $id The series id.
@return SeriesStatistics Statistics on the given series. | [
"Returns",
"statistics",
"about",
"how",
"many",
"seasons",
"&",
"episodes",
"were",
"aired",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L172-L177 |
33,101 | canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getWithFilter | public function getWithFilter(int $id, array $keys): array
{
return $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$id.'/filter',
[
'query' => ['keys' => join(',', $keys)]
]
);
} | php | public function getWithFilter(int $id, array $keys): array
{
return $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$id.'/filter',
[
'query' => ['keys' => join(',', $keys)]
]
);
} | [
"public",
"function",
"getWithFilter",
"(",
"int",
"$",
"id",
",",
"array",
"$",
"keys",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/filter'",
",",
"[",
"'query'",
"=>",
"[",
"'keys'",
"=>",
"join",
"(",
"','",
",",
"$",
"keys",
")",
"]",
"]",
")",
";",
"}"
] | Fetches the data for a series, but only with the attributes that are provided.
@param int $id The series id.
@param array $keys The keys that should be returned.
@return array A key -> value list with the retrieved data. | [
"Fetches",
"the",
"data",
"for",
"a",
"series",
"but",
"only",
"with",
"the",
"attributes",
"that",
"are",
"provided",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L199-L208 |
33,102 | canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getImages | public function getImages(int $id): ImageStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/images');
return DataParser::parseData($json, ImageStatistics::class);
} | php | public function getImages(int $id): ImageStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/images');
return DataParser::parseData($json, ImageStatistics::class);
} | [
"public",
"function",
"getImages",
"(",
"int",
"$",
"id",
")",
":",
"ImageStatistics",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/images'",
")",
";",
"return",
"DataParser",
"::",
"parseData",
"(",
"$",
"json",
",",
"ImageStatistics",
"::",
"class",
")",
";",
"}"
] | Fetches statistics on the submitted images.
@param int $id The id of the series.
@return ImageStatistics An instance with series statistics. | [
"Fetches",
"statistics",
"on",
"the",
"submitted",
"images",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L217-L222 |
33,103 | orchestral/support | src/Support/Concerns/QueryFilter.php | QueryFilter.buildWildcardQueryFilters | protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
{
foreach ($fields as $field) {
$this->buildWildcardForField($query, $field, $keyword);
}
return $query;
} | php | protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
{
foreach ($fields as $field) {
$this->buildWildcardForField($query, $field, $keyword);
}
return $query;
} | [
"protected",
"function",
"buildWildcardQueryFilters",
"(",
"$",
"query",
",",
"array",
"$",
"fields",
",",
"array",
"$",
"keyword",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"buildWildcardForField",
"(",
"$",
"query",
",",
"$",
"field",
",",
"$",
"keyword",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Build wildcard query filters.
@param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
@param array $fields
@param array $keyword
@param string $group
@return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder | [
"Build",
"wildcard",
"query",
"filters",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Concerns/QueryFilter.php#L119-L126 |
33,104 | orchestral/support | src/Providers/Concerns/PackageProvider.php | PackageProvider.addLanguageComponent | public function addLanguageComponent(string $package, string $namespace, string $path): void
{
$this->app->make('translator')->addNamespace($namespace, $path);
} | php | public function addLanguageComponent(string $package, string $namespace, string $path): void
{
$this->app->make('translator')->addNamespace($namespace, $path);
} | [
"public",
"function",
"addLanguageComponent",
"(",
"string",
"$",
"package",
",",
"string",
"$",
"namespace",
",",
"string",
"$",
"path",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'translator'",
")",
"->",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}"
] | Register the package's language component namespaces.
@param string $package
@param string $namespace
@param string $path
@return void | [
"Register",
"the",
"package",
"s",
"language",
"component",
"namespaces",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Providers/Concerns/PackageProvider.php#L35-L38 |
33,105 | orchestral/support | src/Providers/Concerns/PackageProvider.php | PackageProvider.getAppViewPaths | protected function getAppViewPaths(string $package): array
{
return \array_map(function ($path) use ($package) {
return "{$path}/packages/{$package}";
}, $this->app->make('config')->get('view.paths', []));
} | php | protected function getAppViewPaths(string $package): array
{
return \array_map(function ($path) use ($package) {
return "{$path}/packages/{$package}";
}, $this->app->make('config')->get('view.paths', []));
} | [
"protected",
"function",
"getAppViewPaths",
"(",
"string",
"$",
"package",
")",
":",
"array",
"{",
"return",
"\\",
"array_map",
"(",
"function",
"(",
"$",
"path",
")",
"use",
"(",
"$",
"package",
")",
"{",
"return",
"\"{$path}/packages/{$package}\"",
";",
"}",
",",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"'view.paths'",
",",
"[",
"]",
")",
")",
";",
"}"
] | Get the application package view paths.
@param string $package
@return array | [
"Get",
"the",
"application",
"package",
"view",
"paths",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Providers/Concerns/PackageProvider.php#L143-L148 |
33,106 | nails/module-invoice | src/Api/Controller/Customer.php | Customer.getSearch | public function getSearch()
{
if (!userHasPermission('admin:invoice:customer:manage')) {
throw new ApiException('You are not authorised to search customers.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
if (strlen($sKeywords) < 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oCustomerModel->search($sKeywords);
$aOut = [];
foreach ($oResult->data as $oCustomer) {
$aOut[] = $this->formatCustomer($oCustomer);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | php | public function getSearch()
{
if (!userHasPermission('admin:invoice:customer:manage')) {
throw new ApiException('You are not authorised to search customers.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
if (strlen($sKeywords) < 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oCustomerModel->search($sKeywords);
$aOut = [];
foreach ($oResult->data as $oCustomer) {
$aOut[] = $this->formatCustomer($oCustomer);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | [
"public",
"function",
"getSearch",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:invoice:customer:manage'",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'You are not authorised to search customers.'",
",",
"401",
")",
";",
"}",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"sKeywords",
"=",
"$",
"oInput",
"->",
"get",
"(",
"'keywords'",
")",
";",
"$",
"oCustomerModel",
"=",
"Factory",
"::",
"model",
"(",
"'Customer'",
",",
"'nails/module-invoice'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"sKeywords",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Search term must be 3 characters or longer.'",
",",
"400",
")",
";",
"}",
"$",
"oResult",
"=",
"$",
"oCustomerModel",
"->",
"search",
"(",
"$",
"sKeywords",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"oResult",
"->",
"data",
"as",
"$",
"oCustomer",
")",
"{",
"$",
"aOut",
"[",
"]",
"=",
"$",
"this",
"->",
"formatCustomer",
"(",
"$",
"oCustomer",
")",
";",
"}",
"return",
"Factory",
"::",
"factory",
"(",
"'ApiResponse'",
",",
"'nails/module-api'",
")",
"->",
"setData",
"(",
"$",
"aOut",
")",
";",
"}"
] | Search for a customer | [
"Search",
"for",
"a",
"customer"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Customer.php#L24-L47 |
33,107 | nails/module-invoice | src/Api/Controller/Customer.php | Customer.getId | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Customer ID', 404);
}
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
$oCustomer = $oCustomerModel->getById($iId);
if (empty($oCustomer)) {
throw new ApiException('Invalid Customer ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatCustomer($oCustomer));
} | php | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Customer ID', 404);
}
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
$oCustomer = $oCustomerModel->getById($iId);
if (empty($oCustomer)) {
throw new ApiException('Invalid Customer ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatCustomer($oCustomer));
} | [
"public",
"function",
"getId",
"(",
"$",
"iId",
"=",
"null",
")",
"{",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"iId",
"=",
"(",
"int",
")",
"$",
"iId",
"?",
":",
"(",
"int",
")",
"$",
"oInput",
"->",
"get",
"(",
"'id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"iId",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Invalid Customer ID'",
",",
"404",
")",
";",
"}",
"$",
"oCustomerModel",
"=",
"Factory",
"::",
"model",
"(",
"'Customer'",
",",
"'nails/module-invoice'",
")",
";",
"$",
"oCustomer",
"=",
"$",
"oCustomerModel",
"->",
"getById",
"(",
"$",
"iId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"oCustomer",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Invalid Customer ID'",
",",
"404",
")",
";",
"}",
"return",
"Factory",
"::",
"factory",
"(",
"'ApiResponse'",
",",
"'nails/module-api'",
")",
"->",
"setData",
"(",
"$",
"this",
"->",
"formatCustomer",
"(",
"$",
"oCustomer",
")",
")",
";",
"}"
] | Returns a customer by their ID
@param string $iId The customer's ID
@return array | [
"Returns",
"a",
"customer",
"by",
"their",
"ID"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Customer.php#L58-L76 |
33,108 | emgiezet/errbitPHP | src/Errbit/Handlers/ErrorHandlers.php | ErrorHandlers.onShutdown | public function onShutdown()
{
if (($error = error_get_last()) && $error['type'] & error_reporting()) {
$this->errbit->notify(new Fatal($error['message'], $error['file'], $error['line']));
}
} | php | public function onShutdown()
{
if (($error = error_get_last()) && $error['type'] & error_reporting()) {
$this->errbit->notify(new Fatal($error['message'], $error['file'], $error['line']));
}
} | [
"public",
"function",
"onShutdown",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"error",
"=",
"error_get_last",
"(",
")",
")",
"&&",
"$",
"error",
"[",
"'type'",
"]",
"&",
"error_reporting",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errbit",
"->",
"notify",
"(",
"new",
"Fatal",
"(",
"$",
"error",
"[",
"'message'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
")",
";",
"}",
"}"
] | On shut down | [
"On",
"shut",
"down"
] | cc634f8d6b0d2cd4a29648662119310afc73fa7b | https://github.com/emgiezet/errbitPHP/blob/cc634f8d6b0d2cd4a29648662119310afc73fa7b/src/Errbit/Handlers/ErrorHandlers.php#L96-L101 |
33,109 | nails/module-invoice | src/Api/Controller/Invoice.php | Invoice.getSearch | public function getSearch()
{
if (!userHasPermission('admin:invoice:invoice:manage')) {
throw new ApiException('You are not authorised to search invoices.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
if (strlen($sKeywords) >= 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oInvoiceModel->search($sKeywords, null, null, ['expand' => ['customer']]);
$aOut = [];
foreach ($oResult->data as $oInvoice) {
$aOut[] = $this->formatInvoice($oInvoice);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | php | public function getSearch()
{
if (!userHasPermission('admin:invoice:invoice:manage')) {
throw new ApiException('You are not authorised to search invoices.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
if (strlen($sKeywords) >= 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oInvoiceModel->search($sKeywords, null, null, ['expand' => ['customer']]);
$aOut = [];
foreach ($oResult->data as $oInvoice) {
$aOut[] = $this->formatInvoice($oInvoice);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | [
"public",
"function",
"getSearch",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:invoice:invoice:manage'",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'You are not authorised to search invoices.'",
",",
"401",
")",
";",
"}",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"sKeywords",
"=",
"$",
"oInput",
"->",
"get",
"(",
"'keywords'",
")",
";",
"$",
"oInvoiceModel",
"=",
"Factory",
"::",
"model",
"(",
"'Invoice'",
",",
"'nails/module-invoice'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"sKeywords",
")",
">=",
"3",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Search term must be 3 characters or longer.'",
",",
"400",
")",
";",
"}",
"$",
"oResult",
"=",
"$",
"oInvoiceModel",
"->",
"search",
"(",
"$",
"sKeywords",
",",
"null",
",",
"null",
",",
"[",
"'expand'",
"=>",
"[",
"'customer'",
"]",
"]",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"oResult",
"->",
"data",
"as",
"$",
"oInvoice",
")",
"{",
"$",
"aOut",
"[",
"]",
"=",
"$",
"this",
"->",
"formatInvoice",
"(",
"$",
"oInvoice",
")",
";",
"}",
"return",
"Factory",
"::",
"factory",
"(",
"'ApiResponse'",
",",
"'nails/module-api'",
")",
"->",
"setData",
"(",
"$",
"aOut",
")",
";",
"}"
] | Search for an invoice | [
"Search",
"for",
"an",
"invoice"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Invoice.php#L24-L47 |
33,110 | nails/module-invoice | src/Api/Controller/Invoice.php | Invoice.getId | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Invoice ID', 404);
}
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
$oInvoice = $oInvoiceModel->getById($iId, ['expand' => ['customer']]);
if (empty($oInvoice)) {
throw new ApiException('Invalid Invoice ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatInvoice($oInvoice));
} | php | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Invoice ID', 404);
}
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
$oInvoice = $oInvoiceModel->getById($iId, ['expand' => ['customer']]);
if (empty($oInvoice)) {
throw new ApiException('Invalid Invoice ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatInvoice($oInvoice));
} | [
"public",
"function",
"getId",
"(",
"$",
"iId",
"=",
"null",
")",
"{",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"iId",
"=",
"(",
"int",
")",
"$",
"iId",
"?",
":",
"(",
"int",
")",
"$",
"oInput",
"->",
"get",
"(",
"'id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"iId",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Invalid Invoice ID'",
",",
"404",
")",
";",
"}",
"$",
"oInvoiceModel",
"=",
"Factory",
"::",
"model",
"(",
"'Invoice'",
",",
"'nails/module-invoice'",
")",
";",
"$",
"oInvoice",
"=",
"$",
"oInvoiceModel",
"->",
"getById",
"(",
"$",
"iId",
",",
"[",
"'expand'",
"=>",
"[",
"'customer'",
"]",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"oInvoice",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'Invalid Invoice ID'",
",",
"404",
")",
";",
"}",
"return",
"Factory",
"::",
"factory",
"(",
"'ApiResponse'",
",",
"'nails/module-api'",
")",
"->",
"setData",
"(",
"$",
"this",
"->",
"formatInvoice",
"(",
"$",
"oInvoice",
")",
")",
";",
"}"
] | Returns an invoice by its ID
@param string $iId The invoice's ID
@return array | [
"Returns",
"an",
"invoice",
"by",
"its",
"ID"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Invoice.php#L58-L76 |
33,111 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeAliasSendInstance | public static function makeAliasSendInstance(string $alias, float $value, string $message = ''): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SEND);
$transaction->setDestinationAddress($alias);
$transaction->setValue($value);
$transaction->setMessage($message);
return $transaction;
} | php | public static function makeAliasSendInstance(string $alias, float $value, string $message = ''): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SEND);
$transaction->setDestinationAddress($alias);
$transaction->setValue($value);
$transaction->setMessage($message);
return $transaction;
} | [
"public",
"static",
"function",
"makeAliasSendInstance",
"(",
"string",
"$",
"alias",
",",
"float",
"$",
"value",
",",
"string",
"$",
"message",
"=",
"''",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"ALIAS_SEND",
")",
";",
"$",
"transaction",
"->",
"setDestinationAddress",
"(",
"$",
"alias",
")",
";",
"$",
"transaction",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"transaction",
"->",
"setMessage",
"(",
"$",
"message",
")",
";",
"return",
"$",
"transaction",
";",
"}"
] | Retrieve a pre-populated Transaction instance for sending to an alias.
@param string $alias
@param float $value
@param string $message
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"sending",
"to",
"an",
"alias",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L132-L142 |
33,112 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeAliasSetInstance | public static function makeAliasSetInstance(string $address, string $alias): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SET);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_ALIAS_SET);
$transaction->setFee(self::FEE_ALIAS_SET);
$transaction->setMessage($alias);
return $transaction;
} | php | public static function makeAliasSetInstance(string $address, string $alias): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SET);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_ALIAS_SET);
$transaction->setFee(self::FEE_ALIAS_SET);
$transaction->setMessage($alias);
return $transaction;
} | [
"public",
"static",
"function",
"makeAliasSetInstance",
"(",
"string",
"$",
"address",
",",
"string",
"$",
"alias",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"ALIAS_SET",
")",
";",
"$",
"transaction",
"->",
"setDestinationAddress",
"(",
"$",
"address",
")",
";",
"$",
"transaction",
"->",
"setValue",
"(",
"self",
"::",
"VALUE_ALIAS_SET",
")",
";",
"$",
"transaction",
"->",
"setFee",
"(",
"self",
"::",
"FEE_ALIAS_SET",
")",
";",
"$",
"transaction",
"->",
"setMessage",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"transaction",
";",
"}"
] | Retrieve a pre-populated Transaction instance for setting an alias.
@param string $address
@param string $alias
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"setting",
"an",
"alias",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L152-L163 |
33,113 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeCreateInstance | public static function makeMasternodeCreateInstance(string $ipAddress, string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_CREATE);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_CREATE);
$transaction->setFee(self::FEE_MASTERNODE_CREATE);
$transaction->setMessage($ipAddress);
return $transaction;
} | php | public static function makeMasternodeCreateInstance(string $ipAddress, string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_CREATE);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_CREATE);
$transaction->setFee(self::FEE_MASTERNODE_CREATE);
$transaction->setMessage($ipAddress);
return $transaction;
} | [
"public",
"static",
"function",
"makeMasternodeCreateInstance",
"(",
"string",
"$",
"ipAddress",
",",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_CREATE",
")",
";",
"$",
"transaction",
"->",
"setDestinationAddress",
"(",
"$",
"address",
")",
";",
"$",
"transaction",
"->",
"setValue",
"(",
"self",
"::",
"VALUE_MASTERNODE_CREATE",
")",
";",
"$",
"transaction",
"->",
"setFee",
"(",
"self",
"::",
"FEE_MASTERNODE_CREATE",
")",
";",
"$",
"transaction",
"->",
"setMessage",
"(",
"$",
"ipAddress",
")",
";",
"return",
"$",
"transaction",
";",
"}"
] | Retrieve a pre-populated Transaction instance for creating a masternode.
@param string $ipAddress
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"creating",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L173-L184 |
33,114 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodePauseInstance | public static function makeMasternodePauseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_PAUSE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodePauseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_PAUSE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodePauseInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_PAUSE",
")",
";",
"return",
"self",
"::",
"setMasternodeCommandDefaults",
"(",
"$",
"address",
",",
"$",
"transaction",
")",
";",
"}"
] | Retrieve a pre-populated Transaction instance for pausing a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"pausing",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L193-L199 |
33,115 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeResumeInstance | public static function makeMasternodeResumeInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RESUME);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodeResumeInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RESUME);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodeResumeInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_RESUME",
")",
";",
"return",
"self",
"::",
"setMasternodeCommandDefaults",
"(",
"$",
"address",
",",
"$",
"transaction",
")",
";",
"}"
] | Retrieve a pre-populated Transaction instance for resuming a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"resuming",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L208-L214 |
33,116 | pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeReleaseInstance | public static function makeMasternodeReleaseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RELEASE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodeReleaseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RELEASE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodeReleaseInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_RELEASE",
")",
";",
"return",
"self",
"::",
"setMasternodeCommandDefaults",
"(",
"$",
"address",
",",
"$",
"transaction",
")",
";",
"}"
] | Retrieve a pre-populated Transaction instance for releasing a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"releasing",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L223-L229 |
33,117 | pxgamer/arionum-php | src/Transaction.php | Transaction.setMasternodeCommandDefaults | private static function setMasternodeCommandDefaults(string $address, Transaction $transaction): self
{
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_COMMAND);
$transaction->setFee(self::FEE_MASTERNODE_COMMAND);
return $transaction;
} | php | private static function setMasternodeCommandDefaults(string $address, Transaction $transaction): self
{
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_COMMAND);
$transaction->setFee(self::FEE_MASTERNODE_COMMAND);
return $transaction;
} | [
"private",
"static",
"function",
"setMasternodeCommandDefaults",
"(",
"string",
"$",
"address",
",",
"Transaction",
"$",
"transaction",
")",
":",
"self",
"{",
"$",
"transaction",
"->",
"setDestinationAddress",
"(",
"$",
"address",
")",
";",
"$",
"transaction",
"->",
"setValue",
"(",
"self",
"::",
"VALUE_MASTERNODE_COMMAND",
")",
";",
"$",
"transaction",
"->",
"setFee",
"(",
"self",
"::",
"FEE_MASTERNODE_COMMAND",
")",
";",
"return",
"$",
"transaction",
";",
"}"
] | Set the default fee and value for masternode commands.
@param string $address
@param self $transaction
@return self
@internal | [
"Set",
"the",
"default",
"fee",
"and",
"value",
"for",
"masternode",
"commands",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L338-L345 |
33,118 | byjg/restserver | src/ServerRequestHandler.php | ServerRequestHandler.mimeContentType | public function mimeContentType($filename)
{
$mimeTypes = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
if (!file_exists($filename)) {
throw new Error404Exception();
}
$ext = substr(strrchr($filename, "."), 1);
if (array_key_exists($ext, $mimeTypes)) {
return $mimeTypes[$ext];
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
} else {
return 'application/octet-stream';
}
} | php | public function mimeContentType($filename)
{
$mimeTypes = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
if (!file_exists($filename)) {
throw new Error404Exception();
}
$ext = substr(strrchr($filename, "."), 1);
if (array_key_exists($ext, $mimeTypes)) {
return $mimeTypes[$ext];
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
} else {
return 'application/octet-stream';
}
} | [
"public",
"function",
"mimeContentType",
"(",
"$",
"filename",
")",
"{",
"$",
"mimeTypes",
"=",
"array",
"(",
"'txt'",
"=>",
"'text/plain'",
",",
"'htm'",
"=>",
"'text/html'",
",",
"'html'",
"=>",
"'text/html'",
",",
"'php'",
"=>",
"'text/html'",
",",
"'css'",
"=>",
"'text/css'",
",",
"'js'",
"=>",
"'application/javascript'",
",",
"'json'",
"=>",
"'application/json'",
",",
"'xml'",
"=>",
"'application/xml'",
",",
"'swf'",
"=>",
"'application/x-shockwave-flash'",
",",
"'flv'",
"=>",
"'video/x-flv'",
",",
"// images",
"'png'",
"=>",
"'image/png'",
",",
"'jpe'",
"=>",
"'image/jpeg'",
",",
"'jpeg'",
"=>",
"'image/jpeg'",
",",
"'jpg'",
"=>",
"'image/jpeg'",
",",
"'gif'",
"=>",
"'image/gif'",
",",
"'bmp'",
"=>",
"'image/bmp'",
",",
"'ico'",
"=>",
"'image/vnd.microsoft.icon'",
",",
"'tiff'",
"=>",
"'image/tiff'",
",",
"'tif'",
"=>",
"'image/tiff'",
",",
"'svg'",
"=>",
"'image/svg+xml'",
",",
"'svgz'",
"=>",
"'image/svg+xml'",
",",
"// archives",
"'zip'",
"=>",
"'application/zip'",
",",
"'rar'",
"=>",
"'application/x-rar-compressed'",
",",
"'exe'",
"=>",
"'application/x-msdownload'",
",",
"'msi'",
"=>",
"'application/x-msdownload'",
",",
"'cab'",
"=>",
"'application/vnd.ms-cab-compressed'",
",",
"// audio/video",
"'mp3'",
"=>",
"'audio/mpeg'",
",",
"'qt'",
"=>",
"'video/quicktime'",
",",
"'mov'",
"=>",
"'video/quicktime'",
",",
"// adobe",
"'pdf'",
"=>",
"'application/pdf'",
",",
"'psd'",
"=>",
"'image/vnd.adobe.photoshop'",
",",
"'ai'",
"=>",
"'application/postscript'",
",",
"'eps'",
"=>",
"'application/postscript'",
",",
"'ps'",
"=>",
"'application/postscript'",
",",
"// ms office",
"'doc'",
"=>",
"'application/msword'",
",",
"'rtf'",
"=>",
"'application/rtf'",
",",
"'xls'",
"=>",
"'application/vnd.ms-excel'",
",",
"'ppt'",
"=>",
"'application/vnd.ms-powerpoint'",
",",
"// open office",
"'odt'",
"=>",
"'application/vnd.oasis.opendocument.text'",
",",
"'ods'",
"=>",
"'application/vnd.oasis.opendocument.spreadsheet'",
",",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Error404Exception",
"(",
")",
";",
"}",
"$",
"ext",
"=",
"substr",
"(",
"strrchr",
"(",
"$",
"filename",
",",
"\".\"",
")",
",",
"1",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"ext",
",",
"$",
"mimeTypes",
")",
")",
"{",
"return",
"$",
"mimeTypes",
"[",
"$",
"ext",
"]",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'finfo_open'",
")",
")",
"{",
"$",
"finfo",
"=",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mimetype",
"=",
"finfo_file",
"(",
"$",
"finfo",
",",
"$",
"filename",
")",
";",
"finfo_close",
"(",
"$",
"finfo",
")",
";",
"return",
"$",
"mimetype",
";",
"}",
"else",
"{",
"return",
"'application/octet-stream'",
";",
"}",
"}"
] | Get the Mime Type based on the filename
@param string $filename
@return string
@throws Error404Exception | [
"Get",
"the",
"Mime",
"Type",
"based",
"on",
"the",
"filename"
] | 1fdbd58f414f5d9958de0873d67eea961dc52fda | https://github.com/byjg/restserver/blob/1fdbd58f414f5d9958de0873d67eea961dc52fda/src/ServerRequestHandler.php#L261-L328 |
33,119 | QoboLtd/qobo-robo | src/Command/Mysql/DbCreate.php | DbCreate.mysqlDbCreate | public function mysqlDbCreate(
$db,
$user = 'root',
$pass = null,
$host = null,
$port = null,
$opts = ['format' => 'table', 'fields' => '']
) {
$result = $this->taskMysqlDbCreate()
->db($db)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function mysqlDbCreate(
$db,
$user = 'root',
$pass = null,
$host = null,
$port = null,
$opts = ['format' => 'table', 'fields' => '']
) {
$result = $this->taskMysqlDbCreate()
->db($db)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"mysqlDbCreate",
"(",
"$",
"db",
",",
"$",
"user",
"=",
"'root'",
",",
"$",
"pass",
"=",
"null",
",",
"$",
"host",
"=",
"null",
",",
"$",
"port",
"=",
"null",
",",
"$",
"opts",
"=",
"[",
"'format'",
"=>",
"'table'",
",",
"'fields'",
"=>",
"''",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"taskMysqlDbCreate",
"(",
")",
"->",
"db",
"(",
"$",
"db",
")",
"->",
"user",
"(",
"$",
"user",
")",
"->",
"pass",
"(",
"$",
"pass",
")",
"->",
"host",
"(",
"$",
"host",
")",
"->",
"port",
"(",
"$",
"port",
")",
"->",
"hide",
"(",
"$",
"pass",
")",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"wasSuccessful",
"(",
")",
")",
"{",
"$",
"this",
"->",
"exitError",
"(",
"\"Failed to run command\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Create mysql database
@param string $db Database name
@param string $user MySQL user to bind with
@param string $pass (Optional) MySQL user password
@param string $host (Optional) MySQL server host
@param string $port (Optional) MySQL server port
@option string $format Output format (table, list, csv, json, xml)
@option string $fields Limit output to given fields, comma-separated
@return bool | [
"Create",
"mysql",
"database"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Mysql/DbCreate.php#L32-L54 |
33,120 | orchestral/support | src/Support/Manager.php | Manager.checkNameIsNotBlacklisted | protected function checkNameIsNotBlacklisted(string $name): void
{
if (Str::contains($name, $this->blacklisted)) {
throw new InvalidArgumentException("Invalid character in driver name [{$name}].");
}
} | php | protected function checkNameIsNotBlacklisted(string $name): void
{
if (Str::contains($name, $this->blacklisted)) {
throw new InvalidArgumentException("Invalid character in driver name [{$name}].");
}
} | [
"protected",
"function",
"checkNameIsNotBlacklisted",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"blacklisted",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid character in driver name [{$name}].\"",
")",
";",
"}",
"}"
] | Check if name is not blacklisted.
@param string $name
@throws \InvalidArgumentException
@return void | [
"Check",
"if",
"name",
"is",
"not",
"blacklisted",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Manager.php#L98-L103 |
33,121 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.startTransaction | public function startTransaction(): bool {
if ($this->transactionExists) {
return false;
}
$started = $this->pdo->beginTransaction();
$this->transactionExists = $started;
return $started;
} | php | public function startTransaction(): bool {
if ($this->transactionExists) {
return false;
}
$started = $this->pdo->beginTransaction();
$this->transactionExists = $started;
return $started;
} | [
"public",
"function",
"startTransaction",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"return",
"false",
";",
"}",
"$",
"started",
"=",
"$",
"this",
"->",
"pdo",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"this",
"->",
"transactionExists",
"=",
"$",
"started",
";",
"return",
"$",
"started",
";",
"}"
] | starts a database transaction
@return bool | [
"starts",
"a",
"database",
"transaction"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L68-L75 |
33,122 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.commit | public function commit(): bool {
if ($this->transactionExists) {
$commited = $this->pdo->commit();
$this->transactionExists = !$commited;
return $commited;
}
return false;
} | php | public function commit(): bool {
if ($this->transactionExists) {
$commited = $this->pdo->commit();
$this->transactionExists = !$commited;
return $commited;
}
return false;
} | [
"public",
"function",
"commit",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"$",
"commited",
"=",
"$",
"this",
"->",
"pdo",
"->",
"commit",
"(",
")",
";",
"$",
"this",
"->",
"transactionExists",
"=",
"!",
"$",
"commited",
";",
"return",
"$",
"commited",
";",
"}",
"return",
"false",
";",
"}"
] | commits a started database transaction
@return bool | [
"commits",
"a",
"started",
"database",
"transaction"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L81-L88 |
33,123 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.rollback | public function rollback(): bool {
if ($this->transactionExists) {
$rolledBack = $this->pdo->rollBack();
$this->transactionExists = !$rolledBack;
return $rolledBack;
}
return false;
} | php | public function rollback(): bool {
if ($this->transactionExists) {
$rolledBack = $this->pdo->rollBack();
$this->transactionExists = !$rolledBack;
return $rolledBack;
}
return false;
} | [
"public",
"function",
"rollback",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"$",
"rolledBack",
"=",
"$",
"this",
"->",
"pdo",
"->",
"rollBack",
"(",
")",
";",
"$",
"this",
"->",
"transactionExists",
"=",
"!",
"$",
"rolledBack",
";",
"return",
"$",
"rolledBack",
";",
"}",
"return",
"false",
";",
"}"
] | rolls a started transaction back
@return bool | [
"rolls",
"a",
"started",
"transaction",
"back"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L94-L101 |
33,124 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.connect | public function connect(): bool {
if (!$this->hasMinimumCredentials()) {
throw new InvalidCredentialsException();
}
$host = $this->credentials["servername"];
$db = $this->credentials["dbname"];
$dsn = "mysql:host=$host;dbname=$db;charset=utf8";
$this->pdo = new \PDO($dsn,
$this->credentials["username"],
$this->credentials["password"]
);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $this->pdo !== null;
} | php | public function connect(): bool {
if (!$this->hasMinimumCredentials()) {
throw new InvalidCredentialsException();
}
$host = $this->credentials["servername"];
$db = $this->credentials["dbname"];
$dsn = "mysql:host=$host;dbname=$db;charset=utf8";
$this->pdo = new \PDO($dsn,
$this->credentials["username"],
$this->credentials["password"]
);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $this->pdo !== null;
} | [
"public",
"function",
"connect",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMinimumCredentials",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidCredentialsException",
"(",
")",
";",
"}",
"$",
"host",
"=",
"$",
"this",
"->",
"credentials",
"[",
"\"servername\"",
"]",
";",
"$",
"db",
"=",
"$",
"this",
"->",
"credentials",
"[",
"\"dbname\"",
"]",
";",
"$",
"dsn",
"=",
"\"mysql:host=$host;dbname=$db;charset=utf8\"",
";",
"$",
"this",
"->",
"pdo",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"dsn",
",",
"$",
"this",
"->",
"credentials",
"[",
"\"username\"",
"]",
",",
"$",
"this",
"->",
"credentials",
"[",
"\"password\"",
"]",
")",
";",
"$",
"this",
"->",
"pdo",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"\\",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"return",
"$",
"this",
"->",
"pdo",
"!==",
"null",
";",
"}"
] | connects to the database
@return bool
@throws InvalidCredentialsException | [
"connects",
"to",
"the",
"database"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L109-L122 |
33,125 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.hasMinimumCredentials | private function hasMinimumCredentials(): bool {
if (!isset($this->credentials["servername"])) {
return false;
}
if (!isset($this->credentials["username"])) {
return false;
}
if (!isset($this->credentials["password"])) {
return false;
}
if (!isset($this->credentials["dbname"])) {
return false;
}
return true;
} | php | private function hasMinimumCredentials(): bool {
if (!isset($this->credentials["servername"])) {
return false;
}
if (!isset($this->credentials["username"])) {
return false;
}
if (!isset($this->credentials["password"])) {
return false;
}
if (!isset($this->credentials["dbname"])) {
return false;
}
return true;
} | [
"private",
"function",
"hasMinimumCredentials",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"\"servername\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"\"username\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"\"password\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"\"dbname\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | checks for the minimum required credentials
@return bool | [
"checks",
"for",
"the",
"minimum",
"required",
"credentials"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L129-L143 |
33,126 | doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.prepare | public function prepare(string $sql): ?\PDOStatement {
$statement = $this->getConnection()->prepare($sql);
if ($statement === false) {
return null;
}
$this->statement = $statement;
return $statement;
} | php | public function prepare(string $sql): ?\PDOStatement {
$statement = $this->getConnection()->prepare($sql);
if ($statement === false) {
return null;
}
$this->statement = $statement;
return $statement;
} | [
"public",
"function",
"prepare",
"(",
"string",
"$",
"sql",
")",
":",
"?",
"\\",
"PDOStatement",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"statement",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"statement",
"=",
"$",
"statement",
";",
"return",
"$",
"statement",
";",
"}"
] | prepares a SQL statement
@param string $sql
@return null|\PDOStatement | [
"prepares",
"a",
"SQL",
"statement"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L151-L158 |
33,127 | nails/module-invoice | src/Model/Customer.php | Customer.update | public function update($iCustomerId, array $aData = []): bool
{
try {
$sKeyExistsLabel = array_key_exists('label', $aData);
$sKeyExistsOrg = array_key_exists('organisation', $aData);
$sKeyExistsFirst = array_key_exists('first_name', $aData);
$sKeyExistsLast = array_key_exists('last_name', $aData);
if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
}
}
// Only compile the label if the label isn't defined and any of the other fields are present
if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
$aData['label'] = $this->compileLabel($aData);
}
return parent::update($iCustomerId, $aData);
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
} | php | public function update($iCustomerId, array $aData = []): bool
{
try {
$sKeyExistsLabel = array_key_exists('label', $aData);
$sKeyExistsOrg = array_key_exists('organisation', $aData);
$sKeyExistsFirst = array_key_exists('first_name', $aData);
$sKeyExistsLast = array_key_exists('last_name', $aData);
if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
}
}
// Only compile the label if the label isn't defined and any of the other fields are present
if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
$aData['label'] = $this->compileLabel($aData);
}
return parent::update($iCustomerId, $aData);
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
} | [
"public",
"function",
"update",
"(",
"$",
"iCustomerId",
",",
"array",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"sKeyExistsLabel",
"=",
"array_key_exists",
"(",
"'label'",
",",
"$",
"aData",
")",
";",
"$",
"sKeyExistsOrg",
"=",
"array_key_exists",
"(",
"'organisation'",
",",
"$",
"aData",
")",
";",
"$",
"sKeyExistsFirst",
"=",
"array_key_exists",
"(",
"'first_name'",
",",
"$",
"aData",
")",
";",
"$",
"sKeyExistsLast",
"=",
"array_key_exists",
"(",
"'last_name'",
",",
"$",
"aData",
")",
";",
"if",
"(",
"$",
"sKeyExistsOrg",
"&&",
"$",
"sKeyExistsFirst",
"&&",
"$",
"sKeyExistsLast",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"aData",
"[",
"'organisation'",
"]",
")",
"&&",
"empty",
"(",
"$",
"aData",
"[",
"'first_name'",
"]",
")",
"&&",
"empty",
"(",
"$",
"aData",
"[",
"'last_name'",
"]",
")",
")",
"{",
"throw",
"new",
"InvoiceException",
"(",
"'\"organisation\", \"first_name\" and \"last_name\" cannot all be empty.'",
",",
"1",
")",
";",
"}",
"}",
"// Only compile the label if the label isn't defined and any of the other fields are present",
"if",
"(",
"!",
"$",
"sKeyExistsLabel",
"&&",
"(",
"$",
"sKeyExistsOrg",
"||",
"$",
"sKeyExistsFirst",
"||",
"$",
"sKeyExistsLast",
")",
")",
"{",
"$",
"aData",
"[",
"'label'",
"]",
"=",
"$",
"this",
"->",
"compileLabel",
"(",
"$",
"aData",
")",
";",
"}",
"return",
"parent",
"::",
"update",
"(",
"$",
"iCustomerId",
",",
"$",
"aData",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Update an existing customer
@param integer $iCustomerId The ID of the customer to update
@param array $aData The data to update the customer with
@return mixed | [
"Update",
"an",
"existing",
"customer"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Customer.php#L123-L149 |
33,128 | nails/module-invoice | src/Model/Customer.php | Customer.compileLabel | protected function compileLabel($aData)
{
if (!empty($aData['organisation'])) {
return trim($aData['organisation']);
} else {
return implode(
' ',
array_filter([
!empty($aData['first_name']) ? trim($aData['first_name']) : '',
!empty($aData['last_name']) ? trim($aData['last_name']) : '',
])
);
}
} | php | protected function compileLabel($aData)
{
if (!empty($aData['organisation'])) {
return trim($aData['organisation']);
} else {
return implode(
' ',
array_filter([
!empty($aData['first_name']) ? trim($aData['first_name']) : '',
!empty($aData['last_name']) ? trim($aData['last_name']) : '',
])
);
}
} | [
"protected",
"function",
"compileLabel",
"(",
"$",
"aData",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"aData",
"[",
"'organisation'",
"]",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"aData",
"[",
"'organisation'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"implode",
"(",
"' '",
",",
"array_filter",
"(",
"[",
"!",
"empty",
"(",
"$",
"aData",
"[",
"'first_name'",
"]",
")",
"?",
"trim",
"(",
"$",
"aData",
"[",
"'first_name'",
"]",
")",
":",
"''",
",",
"!",
"empty",
"(",
"$",
"aData",
"[",
"'last_name'",
"]",
")",
"?",
"trim",
"(",
"$",
"aData",
"[",
"'last_name'",
"]",
")",
":",
"''",
",",
"]",
")",
")",
";",
"}",
"}"
] | Compile the customer label
@param array $aData The data passed to create() or update()
@return string | [
"Compile",
"the",
"customer",
"label"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Customer.php#L160-L173 |
33,129 | doganoo/PHPUtil | src/Datatype/PasswordClass.php | PasswordClass.verify | public function verify($password): bool {
if ($password instanceof StringClass || $password instanceof PasswordClass) {
return password_verify($password->getValue(), $this->getValue());
}
return password_verify($password, $this->getValue());
} | php | public function verify($password): bool {
if ($password instanceof StringClass || $password instanceof PasswordClass) {
return password_verify($password->getValue(), $this->getValue());
}
return password_verify($password, $this->getValue());
} | [
"public",
"function",
"verify",
"(",
"$",
"password",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"password",
"instanceof",
"StringClass",
"||",
"$",
"password",
"instanceof",
"PasswordClass",
")",
"{",
"return",
"password_verify",
"(",
"$",
"password",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"password_verify",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
";",
"}"
] | verifies the password
@param $password
@return bool | [
"verifies",
"the",
"password"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/PasswordClass.php#L60-L65 |
33,130 | QoboLtd/qobo-robo | src/Command/Project/DotenvDelete.php | DotenvDelete.projectDotenvDelete | public function projectDotenvDelete($envPath = '.env', $opts = ['force' => false])
{
if (!$opts['force']) {
$this->say(static::MSG_NO_DELETE);
return false;
}
if (!file_exists($envPath)) {
return true;
}
$result = $this->taskFilesystemStack()
->remove($envPath)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function projectDotenvDelete($envPath = '.env', $opts = ['force' => false])
{
if (!$opts['force']) {
$this->say(static::MSG_NO_DELETE);
return false;
}
if (!file_exists($envPath)) {
return true;
}
$result = $this->taskFilesystemStack()
->remove($envPath)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"projectDotenvDelete",
"(",
"$",
"envPath",
"=",
"'.env'",
",",
"$",
"opts",
"=",
"[",
"'force'",
"=>",
"false",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"opts",
"[",
"'force'",
"]",
")",
"{",
"$",
"this",
"->",
"say",
"(",
"static",
"::",
"MSG_NO_DELETE",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"envPath",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"taskFilesystemStack",
"(",
")",
"->",
"remove",
"(",
"$",
"envPath",
")",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"wasSuccessful",
"(",
")",
")",
"{",
"$",
"this",
"->",
"exitError",
"(",
"\"Failed to run command\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Delete dotenv file
@param string $envPath Path to dotenv file
@option $force Force deletion
@return bool true on success or false on failure | [
"Delete",
"dotenv",
"file"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Project/DotenvDelete.php#L26-L45 |
33,131 | QoboLtd/qobo-robo | src/Utility/Dotenv.php | Dotenv.parse | public static function parse($dotenv, $data = [], $flags = self::FLAG_STRICT)
{
if (!is_array($dotenv)) {
$dotenv = explode("\n", $dotenv);
}
$result = (!empty($data)) ? $data : [];
// nothing to do with empty dotenv
if (empty($dotenv)) {
return $result;
}
// FLAG_REPLACE_DUPLICATES and FLAG_STRICT are mutually exclusive
if (($flags & static::FLAG_REPLACE_DUPLICATES) && ($flags & static::FLAG_STRICT)) {
throw new InvalidArgumentException("Can't use FLAG_REPLACE_DUPLICATES and FLAG_STRICT together");
}
foreach ($dotenv as $line) {
$line = trim($line);
// Disregard comments
if (strpos($line, '#') === 0) {
continue;
}
// Only use nont-empty lines that look like setters
if (!preg_match('#^\s*(.+?)=(.*)?$#', $line, $matches)) {
continue;
}
$name = static::normalizeName($matches[1]);
$value = static::normalizeValue(trim($matches[2]));
$value = static::resolveNested($value, $result);
if ($value === "" && ($flags & static::FLAG_SKIP_EMPTY)) {
continue;
}
if (!isset($result[$name]) || ($flags & static::FLAG_REPLACE_DUPLICATES)) {
$result[$name] = $value;
continue;
}
if ($flags & static::FLAG_STRICT) {
throw new RuntimeException("Duplicate value found for variable '$name'");
}
}
return $result;
} | php | public static function parse($dotenv, $data = [], $flags = self::FLAG_STRICT)
{
if (!is_array($dotenv)) {
$dotenv = explode("\n", $dotenv);
}
$result = (!empty($data)) ? $data : [];
// nothing to do with empty dotenv
if (empty($dotenv)) {
return $result;
}
// FLAG_REPLACE_DUPLICATES and FLAG_STRICT are mutually exclusive
if (($flags & static::FLAG_REPLACE_DUPLICATES) && ($flags & static::FLAG_STRICT)) {
throw new InvalidArgumentException("Can't use FLAG_REPLACE_DUPLICATES and FLAG_STRICT together");
}
foreach ($dotenv as $line) {
$line = trim($line);
// Disregard comments
if (strpos($line, '#') === 0) {
continue;
}
// Only use nont-empty lines that look like setters
if (!preg_match('#^\s*(.+?)=(.*)?$#', $line, $matches)) {
continue;
}
$name = static::normalizeName($matches[1]);
$value = static::normalizeValue(trim($matches[2]));
$value = static::resolveNested($value, $result);
if ($value === "" && ($flags & static::FLAG_SKIP_EMPTY)) {
continue;
}
if (!isset($result[$name]) || ($flags & static::FLAG_REPLACE_DUPLICATES)) {
$result[$name] = $value;
continue;
}
if ($flags & static::FLAG_STRICT) {
throw new RuntimeException("Duplicate value found for variable '$name'");
}
}
return $result;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"dotenv",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"flags",
"=",
"self",
"::",
"FLAG_STRICT",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"dotenv",
")",
")",
"{",
"$",
"dotenv",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"dotenv",
")",
";",
"}",
"$",
"result",
"=",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"?",
"$",
"data",
":",
"[",
"]",
";",
"// nothing to do with empty dotenv",
"if",
"(",
"empty",
"(",
"$",
"dotenv",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"// FLAG_REPLACE_DUPLICATES and FLAG_STRICT are mutually exclusive",
"if",
"(",
"(",
"$",
"flags",
"&",
"static",
"::",
"FLAG_REPLACE_DUPLICATES",
")",
"&&",
"(",
"$",
"flags",
"&",
"static",
"::",
"FLAG_STRICT",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Can't use FLAG_REPLACE_DUPLICATES and FLAG_STRICT together\"",
")",
";",
"}",
"foreach",
"(",
"$",
"dotenv",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"// Disregard comments",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'#'",
")",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"// Only use nont-empty lines that look like setters",
"if",
"(",
"!",
"preg_match",
"(",
"'#^\\s*(.+?)=(.*)?$#'",
",",
"$",
"line",
",",
"$",
"matches",
")",
")",
"{",
"continue",
";",
"}",
"$",
"name",
"=",
"static",
"::",
"normalizeName",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"value",
"=",
"static",
"::",
"normalizeValue",
"(",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
")",
";",
"$",
"value",
"=",
"static",
"::",
"resolveNested",
"(",
"$",
"value",
",",
"$",
"result",
")",
";",
"if",
"(",
"$",
"value",
"===",
"\"\"",
"&&",
"(",
"$",
"flags",
"&",
"static",
"::",
"FLAG_SKIP_EMPTY",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"name",
"]",
")",
"||",
"(",
"$",
"flags",
"&",
"static",
"::",
"FLAG_REPLACE_DUPLICATES",
")",
")",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"flags",
"&",
"static",
"::",
"FLAG_STRICT",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Duplicate value found for variable '$name'\"",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Parse dotenv content
@param string|array string $dotenv Dotenv content
@param array $data Any preset env variables
@param int $flags Additianal flags for parsing
@return array List of dotenv variables with their values | [
"Parse",
"dotenv",
"content"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Utility/Dotenv.php#L50-L100 |
33,132 | doganoo/PHPUtil | src/Util/AppContainer.php | AppContainer.getInstance | private static function getInstance(): HashMap {
if (null === self::$map) {
self::$map = new HashMap();
}
return self::$map;
} | php | private static function getInstance(): HashMap {
if (null === self::$map) {
self::$map = new HashMap();
}
return self::$map;
} | [
"private",
"static",
"function",
"getInstance",
"(",
")",
":",
"HashMap",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"map",
")",
"{",
"self",
"::",
"$",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"map",
";",
"}"
] | returning the Map instance.
@return HashMap | [
"returning",
"the",
"Map",
"instance",
"."
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Util/AppContainer.php#L74-L79 |
33,133 | hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setStatusString | public function setStatusString($status)
{
$status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);
if ($status > 0) {
$this->setStatus($status);
}
return $this;
} | php | public function setStatusString($status)
{
$status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);
if ($status > 0) {
$this->setStatus($status);
}
return $this;
} | [
"public",
"function",
"setStatusString",
"(",
"$",
"status",
")",
"{",
"$",
"status",
"=",
"\\",
"array_search",
"(",
"\\",
"strtolower",
"(",
"$",
"status",
")",
",",
"TicketMessageInterface",
"::",
"STATUSES",
")",
";",
"if",
"(",
"$",
"status",
">",
"0",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set status string.
@param string $status
@return $this | [
"Set",
"status",
"string",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L91-L100 |
33,134 | hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setPriorityString | public function setPriorityString($priority)
{
$priority = \array_search(\strtolower($priority), TicketMessageInterface::PRIORITIES);
if ($priority > 0) {
$this->setPriority($priority);
}
return $this;
} | php | public function setPriorityString($priority)
{
$priority = \array_search(\strtolower($priority), TicketMessageInterface::PRIORITIES);
if ($priority > 0) {
$this->setPriority($priority);
}
return $this;
} | [
"public",
"function",
"setPriorityString",
"(",
"$",
"priority",
")",
"{",
"$",
"priority",
"=",
"\\",
"array_search",
"(",
"\\",
"strtolower",
"(",
"$",
"priority",
")",
",",
"TicketMessageInterface",
"::",
"PRIORITIES",
")",
";",
"if",
"(",
"$",
"priority",
">",
"0",
")",
"{",
"$",
"this",
"->",
"setPriority",
"(",
"$",
"priority",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set priority string.
@param string $priority
@return $this | [
"Set",
"priority",
"string",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L147-L156 |
33,135 | hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setUserCreated | public function setUserCreated($userCreated)
{
if (\is_object($userCreated)) {
$this->userCreatedObject = $userCreated;
$this->userCreated = $userCreated->getId();
} else {
$this->userCreatedObject = null;
$this->userCreated = $userCreated;
}
return $this;
} | php | public function setUserCreated($userCreated)
{
if (\is_object($userCreated)) {
$this->userCreatedObject = $userCreated;
$this->userCreated = $userCreated->getId();
} else {
$this->userCreatedObject = null;
$this->userCreated = $userCreated;
}
return $this;
} | [
"public",
"function",
"setUserCreated",
"(",
"$",
"userCreated",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"userCreated",
")",
")",
"{",
"$",
"this",
"->",
"userCreatedObject",
"=",
"$",
"userCreated",
";",
"$",
"this",
"->",
"userCreated",
"=",
"$",
"userCreated",
"->",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"userCreatedObject",
"=",
"null",
";",
"$",
"this",
"->",
"userCreated",
"=",
"$",
"userCreated",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set userCreated.
@param int|object $userCreated
@return $this | [
"Set",
"userCreated",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L189-L200 |
33,136 | hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setLastUser | public function setLastUser($lastUser)
{
if (\is_object($lastUser)) {
$this->lastUserObject = $lastUser;
$this->lastUser = $lastUser->getId();
} else {
$this->lastUserObject = null;
$this->lastUser = $lastUser;
}
return $this;
} | php | public function setLastUser($lastUser)
{
if (\is_object($lastUser)) {
$this->lastUserObject = $lastUser;
$this->lastUser = $lastUser->getId();
} else {
$this->lastUserObject = null;
$this->lastUser = $lastUser;
}
return $this;
} | [
"public",
"function",
"setLastUser",
"(",
"$",
"lastUser",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"lastUser",
")",
")",
"{",
"$",
"this",
"->",
"lastUserObject",
"=",
"$",
"lastUser",
";",
"$",
"this",
"->",
"lastUser",
"=",
"$",
"lastUser",
"->",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"lastUserObject",
"=",
"null",
";",
"$",
"this",
"->",
"lastUser",
"=",
"$",
"lastUser",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set lastUser.
@param int|object $lastUser
@return $this | [
"Set",
"lastUser",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L229-L240 |
33,137 | hackzilla/TicketBundle | Controller/TicketAttachmentController.php | TicketAttachmentController.downloadAction | public function downloadAction($ticketMessageId)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketMessage = $ticketManager->getMessageById($ticketMessageId);
if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
// check permissions
$userManager = $this->get('hackzilla_ticket.user_manager');
$userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());
$downloadHandler = $this->get('vich_uploader.download_handler');
return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
} | php | public function downloadAction($ticketMessageId)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketMessage = $ticketManager->getMessageById($ticketMessageId);
if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
// check permissions
$userManager = $this->get('hackzilla_ticket.user_manager');
$userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());
$downloadHandler = $this->get('vich_uploader.download_handler');
return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
} | [
"public",
"function",
"downloadAction",
"(",
"$",
"ticketMessageId",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticketMessage",
"=",
"$",
"ticketManager",
"->",
"getMessageById",
"(",
"$",
"ticketMessageId",
")",
";",
"if",
"(",
"!",
"$",
"ticketMessage",
"||",
"!",
"$",
"ticketMessage",
"instanceof",
"TicketMessageWithAttachment",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'ERROR_FIND_TICKET_ENTITY'",
",",
"[",
"]",
",",
"'HackzillaTicketBundle'",
")",
")",
";",
"}",
"// check permissions",
"$",
"userManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.user_manager'",
")",
";",
"$",
"userManager",
"->",
"hasPermission",
"(",
"$",
"userManager",
"->",
"getCurrentUser",
"(",
")",
",",
"$",
"ticketMessage",
"->",
"getTicket",
"(",
")",
")",
";",
"$",
"downloadHandler",
"=",
"$",
"this",
"->",
"get",
"(",
"'vich_uploader.download_handler'",
")",
";",
"return",
"$",
"downloadHandler",
"->",
"downloadObject",
"(",
"$",
"ticketMessage",
",",
"'attachmentFile'",
")",
";",
"}"
] | Download attachment on message.
@param int $ticketMessageId
@return \Symfony\Component\HttpFoundation\Response | [
"Download",
"attachment",
"on",
"message",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketAttachmentController.php#L22-L38 |
33,138 | hackzilla/TicketBundle | Controller/TicketController.php | TicketController.indexAction | public function indexAction(Request $request)
{
$userManager = $this->getUserManager();
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], 'HackzillaTicketBundle'));
$ticketPriority = $request->get('priority', null);
$query = $ticketManager->getTicketListQuery(
$userManager,
$ticketManager->getTicketStatus($ticketState),
$ticketManager->getTicketPriority($ticketPriority)
);
$pagination = $this->get('knp_paginator')->paginate(
$query->getQuery(),
$request->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['index'],
[
'pagination' => $pagination,
'ticketState' => $ticketState,
'ticketPriority' => $ticketPriority,
]
);
} | php | public function indexAction(Request $request)
{
$userManager = $this->getUserManager();
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], 'HackzillaTicketBundle'));
$ticketPriority = $request->get('priority', null);
$query = $ticketManager->getTicketListQuery(
$userManager,
$ticketManager->getTicketStatus($ticketState),
$ticketManager->getTicketPriority($ticketPriority)
);
$pagination = $this->get('knp_paginator')->paginate(
$query->getQuery(),
$request->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['index'],
[
'pagination' => $pagination,
'ticketState' => $ticketState,
'ticketPriority' => $ticketPriority,
]
);
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"userManager",
"=",
"$",
"this",
"->",
"getUserManager",
"(",
")",
";",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticketState",
"=",
"$",
"request",
"->",
"get",
"(",
"'state'",
",",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'STATUS_OPEN'",
",",
"[",
"]",
",",
"'HackzillaTicketBundle'",
")",
")",
";",
"$",
"ticketPriority",
"=",
"$",
"request",
"->",
"get",
"(",
"'priority'",
",",
"null",
")",
";",
"$",
"query",
"=",
"$",
"ticketManager",
"->",
"getTicketListQuery",
"(",
"$",
"userManager",
",",
"$",
"ticketManager",
"->",
"getTicketStatus",
"(",
"$",
"ticketState",
")",
",",
"$",
"ticketManager",
"->",
"getTicketPriority",
"(",
"$",
"ticketPriority",
")",
")",
";",
"$",
"pagination",
"=",
"$",
"this",
"->",
"get",
"(",
"'knp_paginator'",
")",
"->",
"paginate",
"(",
"$",
"query",
"->",
"getQuery",
"(",
")",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
"/*page number*/",
",",
"10",
"/*limit per page*/",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'hackzilla_ticket.templates'",
")",
"[",
"'index'",
"]",
",",
"[",
"'pagination'",
"=>",
"$",
"pagination",
",",
"'ticketState'",
"=>",
"$",
"ticketState",
",",
"'ticketPriority'",
"=>",
"$",
"ticketPriority",
",",
"]",
")",
";",
"}"
] | Lists all Ticket entities.
@param Request $request
@return \Symfony\Component\HttpFoundation\Response | [
"Lists",
"all",
"Ticket",
"entities",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L28-L56 |
33,139 | hackzilla/TicketBundle | Controller/TicketController.php | TicketController.createAction | public function createAction(Request $request)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $ticket);
$form->handleRequest($request);
if ($form->isValid()) {
$message = $ticket->getMessages()->current();
$message->setStatus(TicketMessageInterface::STATUS_OPEN)
->setUser($this->getUserManager()->getCurrentUser());
$ticketManager->updateTicket($ticket, $message);
$this->dispatchTicketEvent(TicketEvents::TICKET_CREATE, $ticket);
return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()]));
}
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $ticket,
'form' => $form->createView(),
]
);
} | php | public function createAction(Request $request)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $ticket);
$form->handleRequest($request);
if ($form->isValid()) {
$message = $ticket->getMessages()->current();
$message->setStatus(TicketMessageInterface::STATUS_OPEN)
->setUser($this->getUserManager()->getCurrentUser());
$ticketManager->updateTicket($ticket, $message);
$this->dispatchTicketEvent(TicketEvents::TICKET_CREATE, $ticket);
return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()]));
}
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $ticket,
'form' => $form->createView(),
]
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticket",
"=",
"$",
"ticketManager",
"->",
"createTicket",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"TicketType",
"::",
"class",
",",
"$",
"ticket",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"message",
"=",
"$",
"ticket",
"->",
"getMessages",
"(",
")",
"->",
"current",
"(",
")",
";",
"$",
"message",
"->",
"setStatus",
"(",
"TicketMessageInterface",
"::",
"STATUS_OPEN",
")",
"->",
"setUser",
"(",
"$",
"this",
"->",
"getUserManager",
"(",
")",
"->",
"getCurrentUser",
"(",
")",
")",
";",
"$",
"ticketManager",
"->",
"updateTicket",
"(",
"$",
"ticket",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"dispatchTicketEvent",
"(",
"TicketEvents",
"::",
"TICKET_CREATE",
",",
"$",
"ticket",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'hackzilla_ticket_show'",
",",
"[",
"'ticketId'",
"=>",
"$",
"ticket",
"->",
"getId",
"(",
")",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'hackzilla_ticket.templates'",
")",
"[",
"'new'",
"]",
",",
"[",
"'entity'",
"=>",
"$",
"ticket",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}"
] | Creates a new Ticket entity.
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response | [
"Creates",
"a",
"new",
"Ticket",
"entity",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L65-L91 |
33,140 | hackzilla/TicketBundle | Controller/TicketController.php | TicketController.newAction | public function newAction()
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$entity = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $entity);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $entity,
'form' => $form->createView(),
]
);
} | php | public function newAction()
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$entity = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $entity);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $entity,
'form' => $form->createView(),
]
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"entity",
"=",
"$",
"ticketManager",
"->",
"createTicket",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"TicketType",
"::",
"class",
",",
"$",
"entity",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'hackzilla_ticket.templates'",
")",
"[",
"'new'",
"]",
",",
"[",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}"
] | Displays a form to create a new Ticket entity. | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Ticket",
"entity",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L96-L110 |
33,141 | hackzilla/TicketBundle | Controller/TicketController.php | TicketController.deleteAction | public function deleteAction(Request $request, $ticketId)
{
$userManager = $this->getUserManager();
$user = $userManager->getCurrentUser();
if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
}
$form = $this->createDeleteForm($ticketId);
if ($request->isMethod('DELETE')) {
$form->submit($request->request->get($form->getName()));
if ($form->isValid()) {
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->getTicketById($ticketId);
if (!$ticket) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
$ticketManager->deleteTicket($ticket);
$this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket);
}
}
return $this->redirect($this->generateUrl('hackzilla_ticket'));
} | php | public function deleteAction(Request $request, $ticketId)
{
$userManager = $this->getUserManager();
$user = $userManager->getCurrentUser();
if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
}
$form = $this->createDeleteForm($ticketId);
if ($request->isMethod('DELETE')) {
$form->submit($request->request->get($form->getName()));
if ($form->isValid()) {
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->getTicketById($ticketId);
if (!$ticket) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
$ticketManager->deleteTicket($ticket);
$this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket);
}
}
return $this->redirect($this->generateUrl('hackzilla_ticket'));
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"ticketId",
")",
"{",
"$",
"userManager",
"=",
"$",
"this",
"->",
"getUserManager",
"(",
")",
";",
"$",
"user",
"=",
"$",
"userManager",
"->",
"getCurrentUser",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"is_object",
"(",
"$",
"user",
")",
"||",
"!",
"$",
"userManager",
"->",
"hasRole",
"(",
"$",
"user",
",",
"TicketRole",
"::",
"ADMIN",
")",
")",
"{",
"throw",
"new",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpKernel",
"\\",
"Exception",
"\\",
"HttpException",
"(",
"403",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"ticketId",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isMethod",
"(",
"'DELETE'",
")",
")",
"{",
"$",
"form",
"->",
"submit",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"$",
"form",
"->",
"getName",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticket",
"=",
"$",
"ticketManager",
"->",
"getTicketById",
"(",
"$",
"ticketId",
")",
";",
"if",
"(",
"!",
"$",
"ticket",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'ERROR_FIND_TICKET_ENTITY'",
",",
"[",
"]",
",",
"'HackzillaTicketBundle'",
")",
")",
";",
"}",
"$",
"ticketManager",
"->",
"deleteTicket",
"(",
"$",
"ticket",
")",
";",
"$",
"this",
"->",
"dispatchTicketEvent",
"(",
"TicketEvents",
"::",
"TICKET_DELETE",
",",
"$",
"ticket",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'hackzilla_ticket'",
")",
")",
";",
"}"
] | Deletes a Ticket entity.
@param Request $request
@param int $ticketId
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Deletes",
"a",
"Ticket",
"entity",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L196-L224 |
33,142 | hackzilla/TicketBundle | Manager/TicketManager.php | TicketManager.createTicket | public function createTicket()
{
/* @var TicketInterface $ticket */
$ticket = new $this->ticketClass();
$ticket->setPriority(TicketMessageInterface::PRIORITY_MEDIUM);
$ticket->setStatus(TicketMessageInterface::STATUS_OPEN);
return $ticket;
} | php | public function createTicket()
{
/* @var TicketInterface $ticket */
$ticket = new $this->ticketClass();
$ticket->setPriority(TicketMessageInterface::PRIORITY_MEDIUM);
$ticket->setStatus(TicketMessageInterface::STATUS_OPEN);
return $ticket;
} | [
"public",
"function",
"createTicket",
"(",
")",
"{",
"/* @var TicketInterface $ticket */",
"$",
"ticket",
"=",
"new",
"$",
"this",
"->",
"ticketClass",
"(",
")",
";",
"$",
"ticket",
"->",
"setPriority",
"(",
"TicketMessageInterface",
"::",
"PRIORITY_MEDIUM",
")",
";",
"$",
"ticket",
"->",
"setStatus",
"(",
"TicketMessageInterface",
"::",
"STATUS_OPEN",
")",
";",
"return",
"$",
"ticket",
";",
"}"
] | Create a new instance of Ticket entity.
@return TicketInterface | [
"Create",
"a",
"new",
"instance",
"of",
"Ticket",
"entity",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Manager/TicketManager.php#L69-L77 |
33,143 | hackzilla/TicketBundle | Entity/Traits/TicketMessageTrait.php | TicketMessageTrait.setTicket | public function setTicket(TicketInterface $ticket = null)
{
$this->ticket = $ticket;
if (\is_null($this->getUserObject())) {
$user = $this->getUser();
} else {
$user = $this->getUserObject();
}
// if null, then new ticket
if (\is_null($ticket->getUserCreated())) {
$ticket->setUserCreated($user);
}
$ticket->setLastUser($user);
$ticket->setLastMessage($this->getCreatedAt());
$ticket->setPriority($this->getPriority());
// if ticket not closed, then it'll be set to null
if (\is_null($this->getStatus())) {
$this->setStatus($ticket->getStatus());
} else {
$ticket->setStatus($this->getStatus());
}
return $this;
} | php | public function setTicket(TicketInterface $ticket = null)
{
$this->ticket = $ticket;
if (\is_null($this->getUserObject())) {
$user = $this->getUser();
} else {
$user = $this->getUserObject();
}
// if null, then new ticket
if (\is_null($ticket->getUserCreated())) {
$ticket->setUserCreated($user);
}
$ticket->setLastUser($user);
$ticket->setLastMessage($this->getCreatedAt());
$ticket->setPriority($this->getPriority());
// if ticket not closed, then it'll be set to null
if (\is_null($this->getStatus())) {
$this->setStatus($ticket->getStatus());
} else {
$ticket->setStatus($this->getStatus());
}
return $this;
} | [
"public",
"function",
"setTicket",
"(",
"TicketInterface",
"$",
"ticket",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"ticket",
"=",
"$",
"ticket",
";",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"this",
"->",
"getUserObject",
"(",
")",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUserObject",
"(",
")",
";",
"}",
"// if null, then new ticket",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"ticket",
"->",
"getUserCreated",
"(",
")",
")",
")",
"{",
"$",
"ticket",
"->",
"setUserCreated",
"(",
"$",
"user",
")",
";",
"}",
"$",
"ticket",
"->",
"setLastUser",
"(",
"$",
"user",
")",
";",
"$",
"ticket",
"->",
"setLastMessage",
"(",
"$",
"this",
"->",
"getCreatedAt",
"(",
")",
")",
";",
"$",
"ticket",
"->",
"setPriority",
"(",
"$",
"this",
"->",
"getPriority",
"(",
")",
")",
";",
"// if ticket not closed, then it'll be set to null",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"$",
"ticket",
"->",
"getStatus",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"ticket",
"->",
"setStatus",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set ticket.
@param TicketInterface $ticket
@return $this | [
"Set",
"ticket",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketMessageTrait.php#L258-L285 |
33,144 | goaop/parser-reflection | src/ReflectionFile.php | ReflectionFile.getFileNamespaces | public function getFileNamespaces()
{
if (!isset($this->fileNamespaces)) {
$this->fileNamespaces = $this->findFileNamespaces();
}
return $this->fileNamespaces;
} | php | public function getFileNamespaces()
{
if (!isset($this->fileNamespaces)) {
$this->fileNamespaces = $this->findFileNamespaces();
}
return $this->fileNamespaces;
} | [
"public",
"function",
"getFileNamespaces",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileNamespaces",
")",
")",
"{",
"$",
"this",
"->",
"fileNamespaces",
"=",
"$",
"this",
"->",
"findFileNamespaces",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileNamespaces",
";",
"}"
] | Gets the list of namespaces in the file
@return array|ReflectionFileNamespace[] | [
"Gets",
"the",
"list",
"of",
"namespaces",
"in",
"the",
"file"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L87-L94 |
33,145 | goaop/parser-reflection | src/ReflectionFile.php | ReflectionFile.isStrictMode | public function isStrictMode()
{
// declare statement for the strict_types can be only top-level node
$topLevelNode = reset($this->topLevelNodes);
if (!$topLevelNode instanceof Node\Stmt\Declare_) {
return false;
}
$declareStatement = reset($topLevelNode->declares);
$isStrictTypeKey = $declareStatement->key->toString() === 'strict_types';
$isScalarValue = $declareStatement->value instanceof Node\Scalar\LNumber;
$isStrictMode = $isStrictTypeKey && $isScalarValue && $declareStatement->value->value === 1;
return $isStrictMode;
} | php | public function isStrictMode()
{
// declare statement for the strict_types can be only top-level node
$topLevelNode = reset($this->topLevelNodes);
if (!$topLevelNode instanceof Node\Stmt\Declare_) {
return false;
}
$declareStatement = reset($topLevelNode->declares);
$isStrictTypeKey = $declareStatement->key->toString() === 'strict_types';
$isScalarValue = $declareStatement->value instanceof Node\Scalar\LNumber;
$isStrictMode = $isStrictTypeKey && $isScalarValue && $declareStatement->value->value === 1;
return $isStrictMode;
} | [
"public",
"function",
"isStrictMode",
"(",
")",
"{",
"// declare statement for the strict_types can be only top-level node",
"$",
"topLevelNode",
"=",
"reset",
"(",
"$",
"this",
"->",
"topLevelNodes",
")",
";",
"if",
"(",
"!",
"$",
"topLevelNode",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"Declare_",
")",
"{",
"return",
"false",
";",
"}",
"$",
"declareStatement",
"=",
"reset",
"(",
"$",
"topLevelNode",
"->",
"declares",
")",
";",
"$",
"isStrictTypeKey",
"=",
"$",
"declareStatement",
"->",
"key",
"->",
"toString",
"(",
")",
"===",
"'strict_types'",
";",
"$",
"isScalarValue",
"=",
"$",
"declareStatement",
"->",
"value",
"instanceof",
"Node",
"\\",
"Scalar",
"\\",
"LNumber",
";",
"$",
"isStrictMode",
"=",
"$",
"isStrictTypeKey",
"&&",
"$",
"isScalarValue",
"&&",
"$",
"declareStatement",
"->",
"value",
"->",
"value",
"===",
"1",
";",
"return",
"$",
"isStrictMode",
";",
"}"
] | Checks if the current file is in strict mode
@return bool | [
"Checks",
"if",
"the",
"current",
"file",
"is",
"in",
"strict",
"mode"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L135-L149 |
33,146 | goaop/parser-reflection | src/ReflectionFile.php | ReflectionFile.findFileNamespaces | private function findFileNamespaces()
{
$namespaces = array();
// namespaces can be only top-level nodes, so we can scan them directly
foreach ($this->topLevelNodes as $topLevelNode) {
if ($topLevelNode instanceof Namespace_) {
$namespaceName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
$namespaces[$namespaceName] = new ReflectionFileNamespace(
$this->fileName,
$namespaceName,
$topLevelNode
);
}
}
return $namespaces;
} | php | private function findFileNamespaces()
{
$namespaces = array();
// namespaces can be only top-level nodes, so we can scan them directly
foreach ($this->topLevelNodes as $topLevelNode) {
if ($topLevelNode instanceof Namespace_) {
$namespaceName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
$namespaces[$namespaceName] = new ReflectionFileNamespace(
$this->fileName,
$namespaceName,
$topLevelNode
);
}
}
return $namespaces;
} | [
"private",
"function",
"findFileNamespaces",
"(",
")",
"{",
"$",
"namespaces",
"=",
"array",
"(",
")",
";",
"// namespaces can be only top-level nodes, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"topLevelNodes",
"as",
"$",
"topLevelNode",
")",
"{",
"if",
"(",
"$",
"topLevelNode",
"instanceof",
"Namespace_",
")",
"{",
"$",
"namespaceName",
"=",
"$",
"topLevelNode",
"->",
"name",
"?",
"$",
"topLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
":",
"''",
";",
"$",
"namespaces",
"[",
"$",
"namespaceName",
"]",
"=",
"new",
"ReflectionFileNamespace",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"namespaceName",
",",
"$",
"topLevelNode",
")",
";",
"}",
"}",
"return",
"$",
"namespaces",
";",
"}"
] | Searches for file namespaces in the given AST
@return array|ReflectionFileNamespace[] | [
"Searches",
"for",
"file",
"namespaces",
"in",
"the",
"given",
"AST"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFile.php#L156-L174 |
33,147 | majkel89/dbase | benchmarks/TransactionalUpdateBenchmark.php | TransactionalUpdateBenchmark.setUp | public function setUp() {
$this->sourceTable->next();
$this->currentIndex = $this->sourceTable->key();
$this->currentField = $this->sourceTable->current();
} | php | public function setUp() {
$this->sourceTable->next();
$this->currentIndex = $this->sourceTable->key();
$this->currentField = $this->sourceTable->current();
} | [
"public",
"function",
"setUp",
"(",
")",
"{",
"$",
"this",
"->",
"sourceTable",
"->",
"next",
"(",
")",
";",
"$",
"this",
"->",
"currentIndex",
"=",
"$",
"this",
"->",
"sourceTable",
"->",
"key",
"(",
")",
";",
"$",
"this",
"->",
"currentField",
"=",
"$",
"this",
"->",
"sourceTable",
"->",
"current",
"(",
")",
";",
"}"
] | Fetch new record | [
"Fetch",
"new",
"record"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/benchmarks/TransactionalUpdateBenchmark.php#L56-L60 |
33,148 | majkel89/dbase | src/FormatFactory.php | FormatFactory.getFormat | public function getFormat($name, $filePath, $mode) {
$formats = $this->getFormats();
if (!isset($formats[$name])) {
throw new Exception("Format `$name` is not registered");
}
if (!is_callable($formats[$name])) {
throw new Exception("Cannot generate format `$name`");
}
$format = call_user_func($formats[$name], $filePath, $mode);
if (!$format instanceof Format) {
throw new Exception("Cannot generate format `$name`");
}
return $format;
} | php | public function getFormat($name, $filePath, $mode) {
$formats = $this->getFormats();
if (!isset($formats[$name])) {
throw new Exception("Format `$name` is not registered");
}
if (!is_callable($formats[$name])) {
throw new Exception("Cannot generate format `$name`");
}
$format = call_user_func($formats[$name], $filePath, $mode);
if (!$format instanceof Format) {
throw new Exception("Cannot generate format `$name`");
}
return $format;
} | [
"public",
"function",
"getFormat",
"(",
"$",
"name",
",",
"$",
"filePath",
",",
"$",
"mode",
")",
"{",
"$",
"formats",
"=",
"$",
"this",
"->",
"getFormats",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"formats",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Format `$name` is not registered\"",
")",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"formats",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot generate format `$name`\"",
")",
";",
"}",
"$",
"format",
"=",
"call_user_func",
"(",
"$",
"formats",
"[",
"$",
"name",
"]",
",",
"$",
"filePath",
",",
"$",
"mode",
")",
";",
"if",
"(",
"!",
"$",
"format",
"instanceof",
"Format",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot generate format `$name`\"",
")",
";",
"}",
"return",
"$",
"format",
";",
"}"
] | Returns new format object
@param string $name
@param string $filePath
@param integer $mode
@return \org\majkel\dbase\Format
@throws Exception | [
"Returns",
"new",
"format",
"object"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/FormatFactory.php#L35-L48 |
33,149 | goaop/parser-reflection | src/ReflectionParameter.php | ReflectionParameter.haveSiblingsDefalutValues | protected function haveSiblingsDefalutValues()
{
$function = $this->getDeclaringFunction();
if (null === $function) {
throw new ReflectionException('Could not get the declaring function reflection.');
}
/** @var \ReflectionParameter[] $remainingParameters */
$remainingParameters = array_slice($function->getParameters(), $this->parameterIndex + 1);
foreach ($remainingParameters as $reflectionParameter) {
if (!$reflectionParameter->isDefaultValueAvailable()) {
return false;
}
}
return true;
} | php | protected function haveSiblingsDefalutValues()
{
$function = $this->getDeclaringFunction();
if (null === $function) {
throw new ReflectionException('Could not get the declaring function reflection.');
}
/** @var \ReflectionParameter[] $remainingParameters */
$remainingParameters = array_slice($function->getParameters(), $this->parameterIndex + 1);
foreach ($remainingParameters as $reflectionParameter) {
if (!$reflectionParameter->isDefaultValueAvailable()) {
return false;
}
}
return true;
} | [
"protected",
"function",
"haveSiblingsDefalutValues",
"(",
")",
"{",
"$",
"function",
"=",
"$",
"this",
"->",
"getDeclaringFunction",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"function",
")",
"{",
"throw",
"new",
"ReflectionException",
"(",
"'Could not get the declaring function reflection.'",
")",
";",
"}",
"/** @var \\ReflectionParameter[] $remainingParameters */",
"$",
"remainingParameters",
"=",
"array_slice",
"(",
"$",
"function",
"->",
"getParameters",
"(",
")",
",",
"$",
"this",
"->",
"parameterIndex",
"+",
"1",
")",
";",
"foreach",
"(",
"$",
"remainingParameters",
"as",
"$",
"reflectionParameter",
")",
"{",
"if",
"(",
"!",
"$",
"reflectionParameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns if all following parameters have a default value definition.
@return bool
@throws ReflectionException If could not fetch declaring function reflection | [
"Returns",
"if",
"all",
"following",
"parameters",
"have",
"a",
"default",
"value",
"definition",
"."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionParameter.php#L381-L397 |
33,150 | goaop/parser-reflection | src/ReflectionProperty.php | ReflectionProperty.collectFromClassNode | public static function collectFromClassNode(ClassLike $classLikeNode, $fullClassName)
{
$properties = [];
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof Property) {
foreach ($classLevelNode->props as $classPropertyNode) {
$propertyName = $classPropertyNode->name->toString();
$properties[$propertyName] = new static(
$fullClassName,
$propertyName,
$classLevelNode,
$classPropertyNode
);
}
}
}
return $properties;
} | php | public static function collectFromClassNode(ClassLike $classLikeNode, $fullClassName)
{
$properties = [];
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof Property) {
foreach ($classLevelNode->props as $classPropertyNode) {
$propertyName = $classPropertyNode->name->toString();
$properties[$propertyName] = new static(
$fullClassName,
$propertyName,
$classLevelNode,
$classPropertyNode
);
}
}
}
return $properties;
} | [
"public",
"static",
"function",
"collectFromClassNode",
"(",
"ClassLike",
"$",
"classLikeNode",
",",
"$",
"fullClassName",
")",
"{",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classLikeNode",
"->",
"stmts",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"Property",
")",
"{",
"foreach",
"(",
"$",
"classLevelNode",
"->",
"props",
"as",
"$",
"classPropertyNode",
")",
"{",
"$",
"propertyName",
"=",
"$",
"classPropertyNode",
"->",
"name",
"->",
"toString",
"(",
")",
";",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
"=",
"new",
"static",
"(",
"$",
"fullClassName",
",",
"$",
"propertyName",
",",
"$",
"classLevelNode",
",",
"$",
"classPropertyNode",
")",
";",
"}",
"}",
"}",
"return",
"$",
"properties",
";",
"}"
] | Parses properties from the concrete class node
@param ClassLike $classLikeNode Class-like node
@param string $fullClassName FQN of the class
@return array|ReflectionProperty[] | [
"Parses",
"properties",
"from",
"the",
"concrete",
"class",
"node"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionProperty.php#L259-L278 |
33,151 | majkel89/dbase | src/Record.php | Record.getMemoEntryId | public function getMemoEntryId($name) {
return isset($this->memoEntries[$name]) ? $this->memoEntries[$name] : null;
} | php | public function getMemoEntryId($name) {
return isset($this->memoEntries[$name]) ? $this->memoEntries[$name] : null;
} | [
"public",
"function",
"getMemoEntryId",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"memoEntries",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"memoEntries",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Retrieves entity id for memo value
@param string $name memo field name
@return integer|null entity id
@internal | [
"Retrieves",
"entity",
"id",
"for",
"memo",
"value"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Record.php#L80-L82 |
33,152 | majkel89/dbase | src/Table.php | Table.update | public function update($index, $data) {
if (!$data instanceof Record) {
$data = new Record(Utils::toArray($data));
}
$this->getFormat()->update($index, $data);
// update buffer to reflect current changes
if (isset($this->buffer[$index])) {
$this->buffer[$index] = $data;
}
} | php | public function update($index, $data) {
if (!$data instanceof Record) {
$data = new Record(Utils::toArray($data));
}
$this->getFormat()->update($index, $data);
// update buffer to reflect current changes
if (isset($this->buffer[$index])) {
$this->buffer[$index] = $data;
}
} | [
"public",
"function",
"update",
"(",
"$",
"index",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"instanceof",
"Record",
")",
"{",
"$",
"data",
"=",
"new",
"Record",
"(",
"Utils",
"::",
"toArray",
"(",
"$",
"data",
")",
")",
";",
"}",
"$",
"this",
"->",
"getFormat",
"(",
")",
"->",
"update",
"(",
"$",
"index",
",",
"$",
"data",
")",
";",
"// update buffer to reflect current changes",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"this",
"->",
"buffer",
"[",
"$",
"index",
"]",
"=",
"$",
"data",
";",
"}",
"}"
] | Stores record in database
@param integer $index
@param \org\majkel\dbase\Record|\Traversable|array $data
@return void
@throws Exception | [
"Stores",
"record",
"in",
"database"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L113-L122 |
33,153 | majkel89/dbase | src/Table.php | Table.insert | public function insert($data) {
if ($data instanceof Record) {
$data = clone $data;
} else {
$data = new Record(Utils::toArray($data));
}
return $this->getFormat()->insert($data);
} | php | public function insert($data) {
if ($data instanceof Record) {
$data = clone $data;
} else {
$data = new Record(Utils::toArray($data));
}
return $this->getFormat()->insert($data);
} | [
"public",
"function",
"insert",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Record",
")",
"{",
"$",
"data",
"=",
"clone",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"new",
"Record",
"(",
"Utils",
"::",
"toArray",
"(",
"$",
"data",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getFormat",
"(",
")",
"->",
"insert",
"(",
"$",
"data",
")",
";",
"}"
] | Adds new record to database
@param \org\majkel\dbase\Record|\Traversable|array $data
@return integer index of new record
@throws Exception | [
"Adds",
"new",
"record",
"to",
"database"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L130-L137 |
33,154 | majkel89/dbase | src/Table.php | Table.getRecord | public function getRecord($index) {
if (!$this->isValid()) {
throw new Exception('File is not opened', Exception::FILE_NOT_OPENED);
}
if (!$this->offsetExists($index)) {
throw new Exception('Offset '.strval($index).' does not exists', Exception::INVALID_OFFSET);
}
if (isset($this->buffer[$index])) {
return $this->buffer[$index];
}
$this->buffer = $this->getFormat()->getRecords($index, $this->getBufferSize());
return $this->buffer[$index];
} | php | public function getRecord($index) {
if (!$this->isValid()) {
throw new Exception('File is not opened', Exception::FILE_NOT_OPENED);
}
if (!$this->offsetExists($index)) {
throw new Exception('Offset '.strval($index).' does not exists', Exception::INVALID_OFFSET);
}
if (isset($this->buffer[$index])) {
return $this->buffer[$index];
}
$this->buffer = $this->getFormat()->getRecords($index, $this->getBufferSize());
return $this->buffer[$index];
} | [
"public",
"function",
"getRecord",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'File is not opened'",
",",
"Exception",
"::",
"FILE_NOT_OPENED",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Offset '",
".",
"strval",
"(",
"$",
"index",
")",
".",
"' does not exists'",
",",
"Exception",
"::",
"INVALID_OFFSET",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"buffer",
"[",
"$",
"index",
"]",
";",
"}",
"$",
"this",
"->",
"buffer",
"=",
"$",
"this",
"->",
"getFormat",
"(",
")",
"->",
"getRecords",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"getBufferSize",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"buffer",
"[",
"$",
"index",
"]",
";",
"}"
] | Reads record from table
@param integer $index
@return \org\majkel\dbase\Record
@throws \org\majkel\dbase\Exception | [
"Reads",
"record",
"from",
"table"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Table.php#L193-L205 |
33,155 | goaop/parser-reflection | src/ReflectionType.php | ReflectionType.convertToDisplayType | public static function convertToDisplayType(\ReflectionType $type)
{
static $typeMap = [
'int' => 'integer',
'bool' => 'boolean'
];
$displayType = (string)$type;
if (isset($typeMap[$displayType])) {
$displayType = $typeMap[$displayType];
}
$displayType = ltrim($displayType, '\\');
if ($type->allowsNull()) {
$displayType .= ' or NULL';
}
return $displayType;
} | php | public static function convertToDisplayType(\ReflectionType $type)
{
static $typeMap = [
'int' => 'integer',
'bool' => 'boolean'
];
$displayType = (string)$type;
if (isset($typeMap[$displayType])) {
$displayType = $typeMap[$displayType];
}
$displayType = ltrim($displayType, '\\');
if ($type->allowsNull()) {
$displayType .= ' or NULL';
}
return $displayType;
} | [
"public",
"static",
"function",
"convertToDisplayType",
"(",
"\\",
"ReflectionType",
"$",
"type",
")",
"{",
"static",
"$",
"typeMap",
"=",
"[",
"'int'",
"=>",
"'integer'",
",",
"'bool'",
"=>",
"'boolean'",
"]",
";",
"$",
"displayType",
"=",
"(",
"string",
")",
"$",
"type",
";",
"if",
"(",
"isset",
"(",
"$",
"typeMap",
"[",
"$",
"displayType",
"]",
")",
")",
"{",
"$",
"displayType",
"=",
"$",
"typeMap",
"[",
"$",
"displayType",
"]",
";",
"}",
"$",
"displayType",
"=",
"ltrim",
"(",
"$",
"displayType",
",",
"'\\\\'",
")",
";",
"if",
"(",
"$",
"type",
"->",
"allowsNull",
"(",
")",
")",
"{",
"$",
"displayType",
".=",
"' or NULL'",
";",
"}",
"return",
"$",
"displayType",
";",
"}"
] | PHP reflection has it's own rules, so 'int' type will be displayed as 'integer', etc...
@see https://3v4l.org/nZFiT
@param ReflectionType $type Type to display
@return string | [
"PHP",
"reflection",
"has",
"it",
"s",
"own",
"rules",
"so",
"int",
"type",
"will",
"be",
"displayed",
"as",
"integer",
"etc",
"..."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionType.php#L82-L100 |
33,156 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getMethods | public function getMethods($filter = null)
{
if (!isset($this->methods)) {
$directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this);
$parentMethods = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) {
$reflectionMethods = [];
foreach ($instance->getMethods() as $reflectionMethod) {
if (!$isParent || !$reflectionMethod->isPrivate()) {
$reflectionMethods[$reflectionMethod->name] = $reflectionMethod;
}
}
$result += $reflectionMethods;
});
$methods = $directMethods + $parentMethods;
$this->methods = $methods;
}
if (!isset($filter)) {
return array_values($this->methods);
}
$methods = [];
foreach ($this->methods as $method) {
if (!($filter & $method->getModifiers())) {
continue;
}
$methods[] = $method;
}
return $methods;
} | php | public function getMethods($filter = null)
{
if (!isset($this->methods)) {
$directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this);
$parentMethods = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) {
$reflectionMethods = [];
foreach ($instance->getMethods() as $reflectionMethod) {
if (!$isParent || !$reflectionMethod->isPrivate()) {
$reflectionMethods[$reflectionMethod->name] = $reflectionMethod;
}
}
$result += $reflectionMethods;
});
$methods = $directMethods + $parentMethods;
$this->methods = $methods;
}
if (!isset($filter)) {
return array_values($this->methods);
}
$methods = [];
foreach ($this->methods as $method) {
if (!($filter & $method->getModifiers())) {
continue;
}
$methods[] = $method;
}
return $methods;
} | [
"public",
"function",
"getMethods",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methods",
")",
")",
"{",
"$",
"directMethods",
"=",
"ReflectionMethod",
"::",
"collectFromClassNode",
"(",
"$",
"this",
"->",
"classLikeNode",
",",
"$",
"this",
")",
";",
"$",
"parentMethods",
"=",
"$",
"this",
"->",
"recursiveCollect",
"(",
"function",
"(",
"array",
"&",
"$",
"result",
",",
"\\",
"ReflectionClass",
"$",
"instance",
",",
"$",
"isParent",
")",
"{",
"$",
"reflectionMethods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"instance",
"->",
"getMethods",
"(",
")",
"as",
"$",
"reflectionMethod",
")",
"{",
"if",
"(",
"!",
"$",
"isParent",
"||",
"!",
"$",
"reflectionMethod",
"->",
"isPrivate",
"(",
")",
")",
"{",
"$",
"reflectionMethods",
"[",
"$",
"reflectionMethod",
"->",
"name",
"]",
"=",
"$",
"reflectionMethod",
";",
"}",
"}",
"$",
"result",
"+=",
"$",
"reflectionMethods",
";",
"}",
")",
";",
"$",
"methods",
"=",
"$",
"directMethods",
"+",
"$",
"parentMethods",
";",
"$",
"this",
"->",
"methods",
"=",
"$",
"methods",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"filter",
")",
")",
"{",
"return",
"array_values",
"(",
"$",
"this",
"->",
"methods",
")",
";",
"}",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"methods",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"filter",
"&",
"$",
"method",
"->",
"getModifiers",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"methods",
"[",
"]",
"=",
"$",
"method",
";",
"}",
"return",
"$",
"methods",
";",
"}"
] | Returns list of reflection methods
@param null|integer $filter Optional filter
@return array|\ReflectionMethod[] | [
"Returns",
"list",
"of",
"reflection",
"methods"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L346-L376 |
33,157 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getModifiers | public function getModifiers()
{
$modifiers = 0;
if ($this->isFinal()) {
$modifiers += \ReflectionClass::IS_FINAL;
}
if (PHP_VERSION_ID < 70000 && $this->isTrait()) {
$modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
}
if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) {
$modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
}
if ($this->isInterface()) {
$abstractMethods = $this->getMethods();
} else {
$abstractMethods = $this->getMethods(\ReflectionMethod::IS_ABSTRACT);
}
if (!empty($abstractMethods)) {
$modifiers += \ReflectionClass::IS_IMPLICIT_ABSTRACT;
}
return $modifiers;
} | php | public function getModifiers()
{
$modifiers = 0;
if ($this->isFinal()) {
$modifiers += \ReflectionClass::IS_FINAL;
}
if (PHP_VERSION_ID < 70000 && $this->isTrait()) {
$modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
}
if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) {
$modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
}
if ($this->isInterface()) {
$abstractMethods = $this->getMethods();
} else {
$abstractMethods = $this->getMethods(\ReflectionMethod::IS_ABSTRACT);
}
if (!empty($abstractMethods)) {
$modifiers += \ReflectionClass::IS_IMPLICIT_ABSTRACT;
}
return $modifiers;
} | [
"public",
"function",
"getModifiers",
"(",
")",
"{",
"$",
"modifiers",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"isFinal",
"(",
")",
")",
"{",
"$",
"modifiers",
"+=",
"\\",
"ReflectionClass",
"::",
"IS_FINAL",
";",
"}",
"if",
"(",
"PHP_VERSION_ID",
"<",
"70000",
"&&",
"$",
"this",
"->",
"isTrait",
"(",
")",
")",
"{",
"$",
"modifiers",
"+=",
"\\",
"ReflectionClass",
"::",
"IS_EXPLICIT_ABSTRACT",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"classLikeNode",
"instanceof",
"Class_",
"&&",
"$",
"this",
"->",
"classLikeNode",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"modifiers",
"+=",
"\\",
"ReflectionClass",
"::",
"IS_EXPLICIT_ABSTRACT",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isInterface",
"(",
")",
")",
"{",
"$",
"abstractMethods",
"=",
"$",
"this",
"->",
"getMethods",
"(",
")",
";",
"}",
"else",
"{",
"$",
"abstractMethods",
"=",
"$",
"this",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_ABSTRACT",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"abstractMethods",
")",
")",
"{",
"$",
"modifiers",
"+=",
"\\",
"ReflectionClass",
"::",
"IS_IMPLICIT_ABSTRACT",
";",
"}",
"return",
"$",
"modifiers",
";",
"}"
] | Returns a bitfield of the access modifiers for this class.
@link http://php.net/manual/en/reflectionclass.getmodifiers.php
NB: this method is not fully compatible with original value because of hidden internal constants
@return int | [
"Returns",
"a",
"bitfield",
"of",
"the",
"access",
"modifiers",
"for",
"this",
"class",
"."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L387-L413 |
33,158 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getProperties | public function getProperties($filter = null)
{
if (!isset($this->properties)) {
$directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName());
$parentProperties = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) {
$reflectionProperties = [];
foreach ($instance->getProperties() as $reflectionProperty) {
if (!$isParent || !$reflectionProperty->isPrivate()) {
$reflectionProperties[$reflectionProperty->name] = $reflectionProperty;
}
}
$result += $reflectionProperties;
});
$properties = $directProperties + $parentProperties;
$this->properties = $properties;
}
// Without filter we can just return the full list
if (!isset($filter)) {
return array_values($this->properties);
}
$properties = [];
foreach ($this->properties as $property) {
if (!($filter & $property->getModifiers())) {
continue;
}
$properties[] = $property;
}
return $properties;
} | php | public function getProperties($filter = null)
{
if (!isset($this->properties)) {
$directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName());
$parentProperties = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) {
$reflectionProperties = [];
foreach ($instance->getProperties() as $reflectionProperty) {
if (!$isParent || !$reflectionProperty->isPrivate()) {
$reflectionProperties[$reflectionProperty->name] = $reflectionProperty;
}
}
$result += $reflectionProperties;
});
$properties = $directProperties + $parentProperties;
$this->properties = $properties;
}
// Without filter we can just return the full list
if (!isset($filter)) {
return array_values($this->properties);
}
$properties = [];
foreach ($this->properties as $property) {
if (!($filter & $property->getModifiers())) {
continue;
}
$properties[] = $property;
}
return $properties;
} | [
"public",
"function",
"getProperties",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"properties",
")",
")",
"{",
"$",
"directProperties",
"=",
"ReflectionProperty",
"::",
"collectFromClassNode",
"(",
"$",
"this",
"->",
"classLikeNode",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"parentProperties",
"=",
"$",
"this",
"->",
"recursiveCollect",
"(",
"function",
"(",
"array",
"&",
"$",
"result",
",",
"\\",
"ReflectionClass",
"$",
"instance",
",",
"$",
"isParent",
")",
"{",
"$",
"reflectionProperties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"instance",
"->",
"getProperties",
"(",
")",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"!",
"$",
"isParent",
"||",
"!",
"$",
"reflectionProperty",
"->",
"isPrivate",
"(",
")",
")",
"{",
"$",
"reflectionProperties",
"[",
"$",
"reflectionProperty",
"->",
"name",
"]",
"=",
"$",
"reflectionProperty",
";",
"}",
"}",
"$",
"result",
"+=",
"$",
"reflectionProperties",
";",
"}",
")",
";",
"$",
"properties",
"=",
"$",
"directProperties",
"+",
"$",
"parentProperties",
";",
"$",
"this",
"->",
"properties",
"=",
"$",
"properties",
";",
"}",
"// Without filter we can just return the full list",
"if",
"(",
"!",
"isset",
"(",
"$",
"filter",
")",
")",
"{",
"return",
"array_values",
"(",
"$",
"this",
"->",
"properties",
")",
";",
"}",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"filter",
"&",
"$",
"property",
"->",
"getModifiers",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"properties",
"[",
"]",
"=",
"$",
"property",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | Retrieves reflected properties.
@param int $filter The optional filter, for filtering desired property types.
It's configured using the ReflectionProperty constants, and defaults to all property types.
@return array|\Go\ParserReflection\ReflectionProperty[] | [
"Retrieves",
"reflected",
"properties",
"."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L462-L494 |
33,159 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getTraitAliases | public function getTraitAliases()
{
$aliases = [];
$traits = $this->getTraits();
foreach ($this->traitAdaptations as $adaptation) {
if ($adaptation instanceof TraitUseAdaptation\Alias) {
$methodName = $adaptation->method;
$traitName = null;
foreach ($traits as $trait) {
if ($trait->hasMethod($methodName)) {
$traitName = $trait->getName();
break;
}
}
$aliases[$adaptation->newName] = $traitName . '::'. $methodName;
}
}
return $aliases;
} | php | public function getTraitAliases()
{
$aliases = [];
$traits = $this->getTraits();
foreach ($this->traitAdaptations as $adaptation) {
if ($adaptation instanceof TraitUseAdaptation\Alias) {
$methodName = $adaptation->method;
$traitName = null;
foreach ($traits as $trait) {
if ($trait->hasMethod($methodName)) {
$traitName = $trait->getName();
break;
}
}
$aliases[$adaptation->newName] = $traitName . '::'. $methodName;
}
}
return $aliases;
} | [
"public",
"function",
"getTraitAliases",
"(",
")",
"{",
"$",
"aliases",
"=",
"[",
"]",
";",
"$",
"traits",
"=",
"$",
"this",
"->",
"getTraits",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"traitAdaptations",
"as",
"$",
"adaptation",
")",
"{",
"if",
"(",
"$",
"adaptation",
"instanceof",
"TraitUseAdaptation",
"\\",
"Alias",
")",
"{",
"$",
"methodName",
"=",
"$",
"adaptation",
"->",
"method",
";",
"$",
"traitName",
"=",
"null",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"if",
"(",
"$",
"trait",
"->",
"hasMethod",
"(",
"$",
"methodName",
")",
")",
"{",
"$",
"traitName",
"=",
"$",
"trait",
"->",
"getName",
"(",
")",
";",
"break",
";",
"}",
"}",
"$",
"aliases",
"[",
"$",
"adaptation",
"->",
"newName",
"]",
"=",
"$",
"traitName",
".",
"'::'",
".",
"$",
"methodName",
";",
"}",
"}",
"return",
"$",
"aliases",
";",
"}"
] | Returns an array of trait aliases
@link http://php.net/manual/en/reflectionclass.gettraitaliases.php
@return array|null an array with new method names in keys and original names (in the format "TraitName::original") in
values. | [
"Returns",
"an",
"array",
"of",
"trait",
"aliases"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L532-L551 |
33,160 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getTraits | public function getTraits()
{
if (!isset($this->traits)) {
$traitAdaptations = [];
$this->traits = ReflectionClass::collectTraitsFromClassNode($this->classLikeNode, $traitAdaptations);
$this->traitAdaptations = $traitAdaptations;
}
return $this->traits;
} | php | public function getTraits()
{
if (!isset($this->traits)) {
$traitAdaptations = [];
$this->traits = ReflectionClass::collectTraitsFromClassNode($this->classLikeNode, $traitAdaptations);
$this->traitAdaptations = $traitAdaptations;
}
return $this->traits;
} | [
"public",
"function",
"getTraits",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"traits",
")",
")",
"{",
"$",
"traitAdaptations",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"traits",
"=",
"ReflectionClass",
"::",
"collectTraitsFromClassNode",
"(",
"$",
"this",
"->",
"classLikeNode",
",",
"$",
"traitAdaptations",
")",
";",
"$",
"this",
"->",
"traitAdaptations",
"=",
"$",
"traitAdaptations",
";",
"}",
"return",
"$",
"this",
"->",
"traits",
";",
"}"
] | Returns an array of traits used by this class
@link http://php.net/manual/en/reflectionclass.gettraits.php
@return array|\ReflectionClass[] | [
"Returns",
"an",
"array",
"of",
"traits",
"used",
"by",
"this",
"class"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L572-L581 |
33,161 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getStaticProperties | public function getStaticProperties()
{
// In runtime static properties can be changed in any time
if ($this->isInitialized()) {
return parent::getStaticProperties();
}
$properties = [];
$reflectionProperties = $this->getProperties(ReflectionProperty::IS_STATIC);
foreach ($reflectionProperties as $reflectionProperty) {
if (!$reflectionProperty instanceof ReflectionProperty) {
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
}
$properties[$reflectionProperty->getName()] = $reflectionProperty->getValue();
}
return $properties;
} | php | public function getStaticProperties()
{
// In runtime static properties can be changed in any time
if ($this->isInitialized()) {
return parent::getStaticProperties();
}
$properties = [];
$reflectionProperties = $this->getProperties(ReflectionProperty::IS_STATIC);
foreach ($reflectionProperties as $reflectionProperty) {
if (!$reflectionProperty instanceof ReflectionProperty) {
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
}
$properties[$reflectionProperty->getName()] = $reflectionProperty->getValue();
}
return $properties;
} | [
"public",
"function",
"getStaticProperties",
"(",
")",
"{",
"// In runtime static properties can be changed in any time",
"if",
"(",
"$",
"this",
"->",
"isInitialized",
"(",
")",
")",
"{",
"return",
"parent",
"::",
"getStaticProperties",
"(",
")",
";",
"}",
"$",
"properties",
"=",
"[",
"]",
";",
"$",
"reflectionProperties",
"=",
"$",
"this",
"->",
"getProperties",
"(",
"ReflectionProperty",
"::",
"IS_STATIC",
")",
";",
"foreach",
"(",
"$",
"reflectionProperties",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"!",
"$",
"reflectionProperty",
"instanceof",
"ReflectionProperty",
")",
"{",
"if",
"(",
"!",
"$",
"reflectionProperty",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"}",
"}",
"$",
"properties",
"[",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"reflectionProperty",
"->",
"getValue",
"(",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | Gets static properties
@link http://php.net/manual/en/reflectionclass.getstaticproperties.php
@return array | [
"Gets",
"static",
"properties"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L799-L819 |
33,162 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.getStaticPropertyValue | public function getStaticPropertyValue($name, $default = null)
{
$properties = $this->getStaticProperties();
$propertyExists = array_key_exists($name, $properties);
if (!$propertyExists && func_num_args() === 1) {
throw new ReflectionException("Static property does not exist and no default value is given");
}
return $propertyExists ? $properties[$name] : $default;
} | php | public function getStaticPropertyValue($name, $default = null)
{
$properties = $this->getStaticProperties();
$propertyExists = array_key_exists($name, $properties);
if (!$propertyExists && func_num_args() === 1) {
throw new ReflectionException("Static property does not exist and no default value is given");
}
return $propertyExists ? $properties[$name] : $default;
} | [
"public",
"function",
"getStaticPropertyValue",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getStaticProperties",
"(",
")",
";",
"$",
"propertyExists",
"=",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"properties",
")",
";",
"if",
"(",
"!",
"$",
"propertyExists",
"&&",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"throw",
"new",
"ReflectionException",
"(",
"\"Static property does not exist and no default value is given\"",
")",
";",
"}",
"return",
"$",
"propertyExists",
"?",
"$",
"properties",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] | Gets static property value
@param string $name The name of the static property for which to return a value.
@param mixed $default A default value to return in case the class does not declare
a static property with the given name
@return mixed
@throws ReflectionException If there is no such property and no default value was given | [
"Gets",
"static",
"property",
"value"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L831-L841 |
33,163 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.newInstance | public function newInstance($arg = null, ...$args)
{
$args = array_slice(array_merge([$arg], $args), 0, \func_num_args());
$this->initializeInternalReflection();
return parent::newInstance(...$args);
} | php | public function newInstance($arg = null, ...$args)
{
$args = array_slice(array_merge([$arg], $args), 0, \func_num_args());
$this->initializeInternalReflection();
return parent::newInstance(...$args);
} | [
"public",
"function",
"newInstance",
"(",
"$",
"arg",
"=",
"null",
",",
"...",
"$",
"args",
")",
"{",
"$",
"args",
"=",
"array_slice",
"(",
"array_merge",
"(",
"[",
"$",
"arg",
"]",
",",
"$",
"args",
")",
",",
"0",
",",
"\\",
"func_num_args",
"(",
")",
")",
";",
"$",
"this",
"->",
"initializeInternalReflection",
"(",
")",
";",
"return",
"parent",
"::",
"newInstance",
"(",
"...",
"$",
"args",
")",
";",
"}"
] | Creates a new class instance from given arguments.
@link http://php.net/manual/en/reflectionclass.newinstance.php
Signature was hacked to support both 5.6, 7.1.x and 7.2.0 versions
@see https://3v4l.org/hW9O9
@see https://3v4l.org/sWT3j
@see https://3v4l.org/eeVf8
@param mixed $arg First argument
@param mixed $args Accepts a variable number of arguments which are passed to the class constructor
@return object | [
"Creates",
"a",
"new",
"class",
"instance",
"from",
"given",
"arguments",
"."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L859-L865 |
33,164 | goaop/parser-reflection | src/Traits/ReflectionClassLikeTrait.php | ReflectionClassLikeTrait.collectSelfConstants | private function collectSelfConstants()
{
$expressionSolver = new NodeExpressionResolver($this);
$localConstants = [];
// constants can be only top-level nodes in the class, so we can scan them directly
foreach ($this->classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof ClassConst) {
$nodeConstants = $classLevelNode->consts;
if (!empty($nodeConstants)) {
foreach ($nodeConstants as $nodeConstant) {
$expressionSolver->process($nodeConstant->value);
$localConstants[$nodeConstant->name->toString()] = $expressionSolver->getValue();
$this->constants = $localConstants + $this->constants;
}
}
}
}
} | php | private function collectSelfConstants()
{
$expressionSolver = new NodeExpressionResolver($this);
$localConstants = [];
// constants can be only top-level nodes in the class, so we can scan them directly
foreach ($this->classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof ClassConst) {
$nodeConstants = $classLevelNode->consts;
if (!empty($nodeConstants)) {
foreach ($nodeConstants as $nodeConstant) {
$expressionSolver->process($nodeConstant->value);
$localConstants[$nodeConstant->name->toString()] = $expressionSolver->getValue();
$this->constants = $localConstants + $this->constants;
}
}
}
}
} | [
"private",
"function",
"collectSelfConstants",
"(",
")",
"{",
"$",
"expressionSolver",
"=",
"new",
"NodeExpressionResolver",
"(",
"$",
"this",
")",
";",
"$",
"localConstants",
"=",
"[",
"]",
";",
"// constants can be only top-level nodes in the class, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"classLikeNode",
"->",
"stmts",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"ClassConst",
")",
"{",
"$",
"nodeConstants",
"=",
"$",
"classLevelNode",
"->",
"consts",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"nodeConstants",
")",
")",
"{",
"foreach",
"(",
"$",
"nodeConstants",
"as",
"$",
"nodeConstant",
")",
"{",
"$",
"expressionSolver",
"->",
"process",
"(",
"$",
"nodeConstant",
"->",
"value",
")",
";",
"$",
"localConstants",
"[",
"$",
"nodeConstant",
"->",
"name",
"->",
"toString",
"(",
")",
"]",
"=",
"$",
"expressionSolver",
"->",
"getValue",
"(",
")",
";",
"$",
"this",
"->",
"constants",
"=",
"$",
"localConstants",
"+",
"$",
"this",
"->",
"constants",
";",
"}",
"}",
"}",
"}",
"}"
] | Collects list of constants from the class itself | [
"Collects",
"list",
"of",
"constants",
"from",
"the",
"class",
"itself"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionClassLikeTrait.php#L940-L958 |
33,165 | goaop/parser-reflection | src/ReflectionMethod.php | ReflectionMethod.collectFromClassNode | public static function collectFromClassNode(ClassLike $classLikeNode, ReflectionClass $reflectionClass)
{
$methods = [];
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof ClassMethod) {
$classLevelNode->setAttribute('fileName', $classLikeNode->getAttribute('fileName'));
$methodName = $classLevelNode->name->toString();
$methods[$methodName] = new ReflectionMethod(
$reflectionClass->name,
$methodName,
$classLevelNode,
$reflectionClass
);
}
}
return $methods;
} | php | public static function collectFromClassNode(ClassLike $classLikeNode, ReflectionClass $reflectionClass)
{
$methods = [];
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof ClassMethod) {
$classLevelNode->setAttribute('fileName', $classLikeNode->getAttribute('fileName'));
$methodName = $classLevelNode->name->toString();
$methods[$methodName] = new ReflectionMethod(
$reflectionClass->name,
$methodName,
$classLevelNode,
$reflectionClass
);
}
}
return $methods;
} | [
"public",
"static",
"function",
"collectFromClassNode",
"(",
"ClassLike",
"$",
"classLikeNode",
",",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classLikeNode",
"->",
"stmts",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"ClassMethod",
")",
"{",
"$",
"classLevelNode",
"->",
"setAttribute",
"(",
"'fileName'",
",",
"$",
"classLikeNode",
"->",
"getAttribute",
"(",
"'fileName'",
")",
")",
";",
"$",
"methodName",
"=",
"$",
"classLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
";",
"$",
"methods",
"[",
"$",
"methodName",
"]",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"reflectionClass",
"->",
"name",
",",
"$",
"methodName",
",",
"$",
"classLevelNode",
",",
"$",
"reflectionClass",
")",
";",
"}",
"}",
"return",
"$",
"methods",
";",
"}"
] | Parses methods from the concrete class node
@param ClassLike $classLikeNode Class-like node
@param ReflectionClass $reflectionClass Reflection of the class
@return array|ReflectionMethod[] | [
"Parses",
"methods",
"from",
"the",
"concrete",
"class",
"node"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionMethod.php#L304-L323 |
33,166 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getClasses | public function getClasses()
{
if (!isset($this->fileClasses)) {
$this->fileClasses = $this->findClasses();
}
return $this->fileClasses;
} | php | public function getClasses()
{
if (!isset($this->fileClasses)) {
$this->fileClasses = $this->findClasses();
}
return $this->fileClasses;
} | [
"public",
"function",
"getClasses",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileClasses",
")",
")",
"{",
"$",
"this",
"->",
"fileClasses",
"=",
"$",
"this",
"->",
"findClasses",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileClasses",
";",
"}"
] | Gets list of classes in the namespace
@return ReflectionClass[]|array | [
"Gets",
"list",
"of",
"classes",
"in",
"the",
"namespace"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L125-L132 |
33,167 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getConstants | public function getConstants($withDefined = false)
{
if ($withDefined) {
if (!isset($this->fileConstantsWithDefined)) {
$this->fileConstantsWithDefined = $this->findConstants(true);
}
return $this->fileConstantsWithDefined;
}
if (!isset($this->fileConstants)) {
$this->fileConstants = $this->findConstants();
}
return $this->fileConstants;
} | php | public function getConstants($withDefined = false)
{
if ($withDefined) {
if (!isset($this->fileConstantsWithDefined)) {
$this->fileConstantsWithDefined = $this->findConstants(true);
}
return $this->fileConstantsWithDefined;
}
if (!isset($this->fileConstants)) {
$this->fileConstants = $this->findConstants();
}
return $this->fileConstants;
} | [
"public",
"function",
"getConstants",
"(",
"$",
"withDefined",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withDefined",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileConstantsWithDefined",
")",
")",
"{",
"$",
"this",
"->",
"fileConstantsWithDefined",
"=",
"$",
"this",
"->",
"findConstants",
"(",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileConstantsWithDefined",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileConstants",
")",
")",
"{",
"$",
"this",
"->",
"fileConstants",
"=",
"$",
"this",
"->",
"findConstants",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileConstants",
";",
"}"
] | Returns a list of defined constants in the namespace
@param bool $withDefined Include constants defined via "define(...)" in results.
@return array | [
"Returns",
"a",
"list",
"of",
"defined",
"constants",
"in",
"the",
"namespace"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L157-L172 |
33,168 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getDocComment | public function getDocComment()
{
$docComment = false;
$comments = $this->namespaceNode->getAttribute('comments');
if ($comments) {
$docComment = (string)$comments[0];
}
return $docComment;
} | php | public function getDocComment()
{
$docComment = false;
$comments = $this->namespaceNode->getAttribute('comments');
if ($comments) {
$docComment = (string)$comments[0];
}
return $docComment;
} | [
"public",
"function",
"getDocComment",
"(",
")",
"{",
"$",
"docComment",
"=",
"false",
";",
"$",
"comments",
"=",
"$",
"this",
"->",
"namespaceNode",
"->",
"getAttribute",
"(",
"'comments'",
")",
";",
"if",
"(",
"$",
"comments",
")",
"{",
"$",
"docComment",
"=",
"(",
"string",
")",
"$",
"comments",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"docComment",
";",
"}"
] | Gets doc comments from a class.
@return string|false The doc comment if it exists, otherwise "false" | [
"Gets",
"doc",
"comments",
"from",
"a",
"class",
"."
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L179-L189 |
33,169 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getFunctions | public function getFunctions()
{
if (!isset($this->fileFunctions)) {
$this->fileFunctions = $this->findFunctions();
}
return $this->fileFunctions;
} | php | public function getFunctions()
{
if (!isset($this->fileFunctions)) {
$this->fileFunctions = $this->findFunctions();
}
return $this->fileFunctions;
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileFunctions",
")",
")",
"{",
"$",
"this",
"->",
"fileFunctions",
"=",
"$",
"this",
"->",
"findFunctions",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileFunctions",
";",
"}"
] | Gets list of functions in the namespace
@return ReflectionFunction[]|array | [
"Gets",
"list",
"of",
"functions",
"in",
"the",
"namespace"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L232-L239 |
33,170 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getNamespaceAliases | public function getNamespaceAliases()
{
if (!isset($this->fileNamespaceAliases)) {
$this->fileNamespaceAliases = $this->findNamespaceAliases();
}
return $this->fileNamespaceAliases;
} | php | public function getNamespaceAliases()
{
if (!isset($this->fileNamespaceAliases)) {
$this->fileNamespaceAliases = $this->findNamespaceAliases();
}
return $this->fileNamespaceAliases;
} | [
"public",
"function",
"getNamespaceAliases",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileNamespaceAliases",
")",
")",
"{",
"$",
"this",
"->",
"fileNamespaceAliases",
"=",
"$",
"this",
"->",
"findNamespaceAliases",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fileNamespaceAliases",
";",
"}"
] | Returns a list of namespace aliases
@return array | [
"Returns",
"a",
"list",
"of",
"namespace",
"aliases"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L258-L265 |
33,171 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.getLastTokenPosition | public function getLastTokenPosition()
{
$endNamespaceTokenPosition = $this->namespaceNode->getAttribute('endTokenPos');
/** @var Node $lastNamespaceNode */
$lastNamespaceNode = end($this->namespaceNode->stmts);
$endStatementTokenPosition = $lastNamespaceNode->getAttribute('endTokenPos');
return max($endNamespaceTokenPosition, $endStatementTokenPosition);
} | php | public function getLastTokenPosition()
{
$endNamespaceTokenPosition = $this->namespaceNode->getAttribute('endTokenPos');
/** @var Node $lastNamespaceNode */
$lastNamespaceNode = end($this->namespaceNode->stmts);
$endStatementTokenPosition = $lastNamespaceNode->getAttribute('endTokenPos');
return max($endNamespaceTokenPosition, $endStatementTokenPosition);
} | [
"public",
"function",
"getLastTokenPosition",
"(",
")",
"{",
"$",
"endNamespaceTokenPosition",
"=",
"$",
"this",
"->",
"namespaceNode",
"->",
"getAttribute",
"(",
"'endTokenPos'",
")",
";",
"/** @var Node $lastNamespaceNode */",
"$",
"lastNamespaceNode",
"=",
"end",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
")",
";",
"$",
"endStatementTokenPosition",
"=",
"$",
"lastNamespaceNode",
"->",
"getAttribute",
"(",
"'endTokenPos'",
")",
";",
"return",
"max",
"(",
"$",
"endNamespaceTokenPosition",
",",
"$",
"endStatementTokenPosition",
")",
";",
"}"
] | Helper method to access last token position for namespace
This method is useful because namespace can be declared with braces or without them | [
"Helper",
"method",
"to",
"access",
"last",
"token",
"position",
"for",
"namespace"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L282-L291 |
33,172 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.findClasses | private function findClasses()
{
$classes = array();
$namespaceName = $this->getName();
// classes can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof ClassLike) {
$classShortName = $namespaceLevelNode->name->toString();
$className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName;
$namespaceLevelNode->setAttribute('fileName', $this->fileName);
$classes[$className] = new ReflectionClass($className, $namespaceLevelNode);
}
}
return $classes;
} | php | private function findClasses()
{
$classes = array();
$namespaceName = $this->getName();
// classes can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof ClassLike) {
$classShortName = $namespaceLevelNode->name->toString();
$className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName;
$namespaceLevelNode->setAttribute('fileName', $this->fileName);
$classes[$className] = new ReflectionClass($className, $namespaceLevelNode);
}
}
return $classes;
} | [
"private",
"function",
"findClasses",
"(",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"$",
"namespaceName",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"// classes can be only top-level nodes in the namespace, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"ClassLike",
")",
"{",
"$",
"classShortName",
"=",
"$",
"namespaceLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
";",
"$",
"className",
"=",
"$",
"namespaceName",
"?",
"$",
"namespaceName",
".",
"'\\\\'",
".",
"$",
"classShortName",
":",
"$",
"classShortName",
";",
"$",
"namespaceLevelNode",
"->",
"setAttribute",
"(",
"'fileName'",
",",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"classes",
"[",
"$",
"className",
"]",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
",",
"$",
"namespaceLevelNode",
")",
";",
"}",
"}",
"return",
"$",
"classes",
";",
"}"
] | Searches for classes in the given AST
@return array|ReflectionClass[] | [
"Searches",
"for",
"classes",
"in",
"the",
"given",
"AST"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L350-L366 |
33,173 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.findFunctions | private function findFunctions()
{
$functions = array();
$namespaceName = $this->getName();
// functions can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Function_) {
$funcShortName = $namespaceLevelNode->name->toString();
$functionName = $namespaceName ? $namespaceName .'\\' . $funcShortName : $funcShortName;
$namespaceLevelNode->setAttribute('fileName', $this->fileName);
$functions[$funcShortName] = new ReflectionFunction($functionName, $namespaceLevelNode);
}
}
return $functions;
} | php | private function findFunctions()
{
$functions = array();
$namespaceName = $this->getName();
// functions can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Function_) {
$funcShortName = $namespaceLevelNode->name->toString();
$functionName = $namespaceName ? $namespaceName .'\\' . $funcShortName : $funcShortName;
$namespaceLevelNode->setAttribute('fileName', $this->fileName);
$functions[$funcShortName] = new ReflectionFunction($functionName, $namespaceLevelNode);
}
}
return $functions;
} | [
"private",
"function",
"findFunctions",
"(",
")",
"{",
"$",
"functions",
"=",
"array",
"(",
")",
";",
"$",
"namespaceName",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"// functions can be only top-level nodes in the namespace, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"Function_",
")",
"{",
"$",
"funcShortName",
"=",
"$",
"namespaceLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
";",
"$",
"functionName",
"=",
"$",
"namespaceName",
"?",
"$",
"namespaceName",
".",
"'\\\\'",
".",
"$",
"funcShortName",
":",
"$",
"funcShortName",
";",
"$",
"namespaceLevelNode",
"->",
"setAttribute",
"(",
"'fileName'",
",",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"functions",
"[",
"$",
"funcShortName",
"]",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"functionName",
",",
"$",
"namespaceLevelNode",
")",
";",
"}",
"}",
"return",
"$",
"functions",
";",
"}"
] | Searches for functions in the given AST
@return array | [
"Searches",
"for",
"functions",
"in",
"the",
"given",
"AST"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L373-L390 |
33,174 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.findConstants | private function findConstants($withDefined = false)
{
$constants = array();
$expressionSolver = new NodeExpressionResolver($this);
// constants can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Const_) {
$nodeConstants = $namespaceLevelNode->consts;
if (!empty($nodeConstants)) {
foreach ($nodeConstants as $nodeConstant) {
$expressionSolver->process($nodeConstant->value);
$constants[$nodeConstant->name->toString()] = $expressionSolver->getValue();
}
}
}
}
if ($withDefined) {
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Expression
&& $namespaceLevelNode->expr instanceof FuncCall
&& $namespaceLevelNode->expr->name instanceof Name
&& (string)$namespaceLevelNode->expr->name === 'define'
) {
$functionCallNode = $namespaceLevelNode->expr;
$expressionSolver->process($functionCallNode->args[0]->value);
$constantName = $expressionSolver->getValue();
// Ignore constants, for which name can't be determined.
if (strlen($constantName)) {
$expressionSolver->process($functionCallNode->args[1]->value);
$constantValue = $expressionSolver->getValue();
$constants[$constantName] = $constantValue;
}
}
}
}
return $constants;
} | php | private function findConstants($withDefined = false)
{
$constants = array();
$expressionSolver = new NodeExpressionResolver($this);
// constants can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Const_) {
$nodeConstants = $namespaceLevelNode->consts;
if (!empty($nodeConstants)) {
foreach ($nodeConstants as $nodeConstant) {
$expressionSolver->process($nodeConstant->value);
$constants[$nodeConstant->name->toString()] = $expressionSolver->getValue();
}
}
}
}
if ($withDefined) {
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Expression
&& $namespaceLevelNode->expr instanceof FuncCall
&& $namespaceLevelNode->expr->name instanceof Name
&& (string)$namespaceLevelNode->expr->name === 'define'
) {
$functionCallNode = $namespaceLevelNode->expr;
$expressionSolver->process($functionCallNode->args[0]->value);
$constantName = $expressionSolver->getValue();
// Ignore constants, for which name can't be determined.
if (strlen($constantName)) {
$expressionSolver->process($functionCallNode->args[1]->value);
$constantValue = $expressionSolver->getValue();
$constants[$constantName] = $constantValue;
}
}
}
}
return $constants;
} | [
"private",
"function",
"findConstants",
"(",
"$",
"withDefined",
"=",
"false",
")",
"{",
"$",
"constants",
"=",
"array",
"(",
")",
";",
"$",
"expressionSolver",
"=",
"new",
"NodeExpressionResolver",
"(",
"$",
"this",
")",
";",
"// constants can be only top-level nodes in the namespace, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"Const_",
")",
"{",
"$",
"nodeConstants",
"=",
"$",
"namespaceLevelNode",
"->",
"consts",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"nodeConstants",
")",
")",
"{",
"foreach",
"(",
"$",
"nodeConstants",
"as",
"$",
"nodeConstant",
")",
"{",
"$",
"expressionSolver",
"->",
"process",
"(",
"$",
"nodeConstant",
"->",
"value",
")",
";",
"$",
"constants",
"[",
"$",
"nodeConstant",
"->",
"name",
"->",
"toString",
"(",
")",
"]",
"=",
"$",
"expressionSolver",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"withDefined",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"Expression",
"&&",
"$",
"namespaceLevelNode",
"->",
"expr",
"instanceof",
"FuncCall",
"&&",
"$",
"namespaceLevelNode",
"->",
"expr",
"->",
"name",
"instanceof",
"Name",
"&&",
"(",
"string",
")",
"$",
"namespaceLevelNode",
"->",
"expr",
"->",
"name",
"===",
"'define'",
")",
"{",
"$",
"functionCallNode",
"=",
"$",
"namespaceLevelNode",
"->",
"expr",
";",
"$",
"expressionSolver",
"->",
"process",
"(",
"$",
"functionCallNode",
"->",
"args",
"[",
"0",
"]",
"->",
"value",
")",
";",
"$",
"constantName",
"=",
"$",
"expressionSolver",
"->",
"getValue",
"(",
")",
";",
"// Ignore constants, for which name can't be determined.",
"if",
"(",
"strlen",
"(",
"$",
"constantName",
")",
")",
"{",
"$",
"expressionSolver",
"->",
"process",
"(",
"$",
"functionCallNode",
"->",
"args",
"[",
"1",
"]",
"->",
"value",
")",
";",
"$",
"constantValue",
"=",
"$",
"expressionSolver",
"->",
"getValue",
"(",
")",
";",
"$",
"constants",
"[",
"$",
"constantName",
"]",
"=",
"$",
"constantValue",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"constants",
";",
"}"
] | Searches for constants in the given AST
@param bool $withDefined Include constants defined via "define(...)" in results.
@return array | [
"Searches",
"for",
"constants",
"in",
"the",
"given",
"AST"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L399-L440 |
33,175 | goaop/parser-reflection | src/ReflectionFileNamespace.php | ReflectionFileNamespace.findNamespaceAliases | private function findNamespaceAliases()
{
$namespaceAliases = [];
// aliases can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Use_) {
$useAliases = $namespaceLevelNode->uses;
if (!empty($useAliases)) {
foreach ($useAliases as $useNode) {
$namespaceAliases[$useNode->name->toString()] = $useNode->alias;
}
}
}
}
return $namespaceAliases;
} | php | private function findNamespaceAliases()
{
$namespaceAliases = [];
// aliases can be only top-level nodes in the namespace, so we can scan them directly
foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof Use_) {
$useAliases = $namespaceLevelNode->uses;
if (!empty($useAliases)) {
foreach ($useAliases as $useNode) {
$namespaceAliases[$useNode->name->toString()] = $useNode->alias;
}
}
}
}
return $namespaceAliases;
} | [
"private",
"function",
"findNamespaceAliases",
"(",
")",
"{",
"$",
"namespaceAliases",
"=",
"[",
"]",
";",
"// aliases can be only top-level nodes in the namespace, so we can scan them directly",
"foreach",
"(",
"$",
"this",
"->",
"namespaceNode",
"->",
"stmts",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"Use_",
")",
"{",
"$",
"useAliases",
"=",
"$",
"namespaceLevelNode",
"->",
"uses",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"useAliases",
")",
")",
"{",
"foreach",
"(",
"$",
"useAliases",
"as",
"$",
"useNode",
")",
"{",
"$",
"namespaceAliases",
"[",
"$",
"useNode",
"->",
"name",
"->",
"toString",
"(",
")",
"]",
"=",
"$",
"useNode",
"->",
"alias",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"namespaceAliases",
";",
"}"
] | Searchse for namespace aliases for the current block
@return array | [
"Searchse",
"for",
"namespace",
"aliases",
"for",
"the",
"current",
"block"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionFileNamespace.php#L447-L464 |
33,176 | goaop/parser-reflection | src/Traits/ReflectionFunctionLikeTrait.php | ReflectionFunctionLikeTrait.getReturnType | public function getReturnType()
{
$isBuiltin = false;
$returnType = $this->functionLikeNode->getReturnType();
$isNullable = $returnType instanceof NullableType;
if ($isNullable) {
$returnType = $returnType->type;
}
if ($returnType instanceof Identifier) {
$isBuiltin = true;
$returnType = $returnType->toString();
} elseif (is_object($returnType)) {
$returnType = $returnType->toString();
} elseif (is_string($returnType)) {
$isBuiltin = true;
} else {
return null;
}
return new ReflectionType($returnType, $isNullable, $isBuiltin);
} | php | public function getReturnType()
{
$isBuiltin = false;
$returnType = $this->functionLikeNode->getReturnType();
$isNullable = $returnType instanceof NullableType;
if ($isNullable) {
$returnType = $returnType->type;
}
if ($returnType instanceof Identifier) {
$isBuiltin = true;
$returnType = $returnType->toString();
} elseif (is_object($returnType)) {
$returnType = $returnType->toString();
} elseif (is_string($returnType)) {
$isBuiltin = true;
} else {
return null;
}
return new ReflectionType($returnType, $isNullable, $isBuiltin);
} | [
"public",
"function",
"getReturnType",
"(",
")",
"{",
"$",
"isBuiltin",
"=",
"false",
";",
"$",
"returnType",
"=",
"$",
"this",
"->",
"functionLikeNode",
"->",
"getReturnType",
"(",
")",
";",
"$",
"isNullable",
"=",
"$",
"returnType",
"instanceof",
"NullableType",
";",
"if",
"(",
"$",
"isNullable",
")",
"{",
"$",
"returnType",
"=",
"$",
"returnType",
"->",
"type",
";",
"}",
"if",
"(",
"$",
"returnType",
"instanceof",
"Identifier",
")",
"{",
"$",
"isBuiltin",
"=",
"true",
";",
"$",
"returnType",
"=",
"$",
"returnType",
"->",
"toString",
"(",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"returnType",
")",
")",
"{",
"$",
"returnType",
"=",
"$",
"returnType",
"->",
"toString",
"(",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"returnType",
")",
")",
"{",
"$",
"isBuiltin",
"=",
"true",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ReflectionType",
"(",
"$",
"returnType",
",",
"$",
"isNullable",
",",
"$",
"isBuiltin",
")",
";",
"}"
] | Gets the specified return type of a function
@return \ReflectionType
@link http://php.net/manual/en/reflectionfunctionabstract.getreturntype.php | [
"Gets",
"the",
"specified",
"return",
"type",
"of",
"a",
"function"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Traits/ReflectionFunctionLikeTrait.php#L182-L203 |
33,177 | goaop/parser-reflection | src/ValueResolver/NodeExpressionResolver.php | NodeExpressionResolver.resolve | protected function resolve(Node $node)
{
$value = null;
try {
++$this->nodeLevel;
$methodName = $this->getDispatchMethodFor($node);
if (method_exists($this, $methodName)) {
$value = $this->$methodName($node);
}
} finally {
--$this->nodeLevel;
}
return $value;
} | php | protected function resolve(Node $node)
{
$value = null;
try {
++$this->nodeLevel;
$methodName = $this->getDispatchMethodFor($node);
if (method_exists($this, $methodName)) {
$value = $this->$methodName($node);
}
} finally {
--$this->nodeLevel;
}
return $value;
} | [
"protected",
"function",
"resolve",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"value",
"=",
"null",
";",
"try",
"{",
"++",
"$",
"this",
"->",
"nodeLevel",
";",
"$",
"methodName",
"=",
"$",
"this",
"->",
"getDispatchMethodFor",
"(",
"$",
"node",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"$",
"methodName",
"(",
"$",
"node",
")",
";",
"}",
"}",
"finally",
"{",
"--",
"$",
"this",
"->",
"nodeLevel",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Resolves node into valid value
@param Node $node
@return mixed | [
"Resolves",
"node",
"into",
"valid",
"value"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ValueResolver/NodeExpressionResolver.php#L115-L130 |
33,178 | goaop/parser-reflection | src/ValueResolver/NodeExpressionResolver.php | NodeExpressionResolver.fetchReflectionClass | private function fetchReflectionClass(Node\Name $node)
{
$className = $node->toString();
$isFQNClass = $node instanceof Node\Name\FullyQualified;
if ($isFQNClass) {
// check to see if the class is already loaded and is safe to use
// PHP's ReflectionClass to determine if the class is user defined
if (class_exists($className, false)) {
$refClass = new \ReflectionClass($className);
if (!$refClass->isUserDefined()) {
return $refClass;
}
}
return new ReflectionClass($className);
}
if ('self' === $className) {
if ($this->context instanceof \ReflectionClass) {
return $this->context;
} elseif (method_exists($this->context, 'getDeclaringClass')) {
return $this->context->getDeclaringClass();
}
}
if ('parent' === $className) {
if ($this->context instanceof \ReflectionClass) {
return $this->context->getParentClass();
} elseif (method_exists($this->context, 'getDeclaringClass')) {
return $this->context->getDeclaringClass()->getParentClass();
}
}
if (method_exists($this->context, 'getFileName')) {
/** @var ReflectionFileNamespace|null $fileNamespace */
$fileName = $this->context->getFileName();
$namespaceName = $this->resolveScalarMagicConstNamespace();
$fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName);
return $fileNamespace->getClass($className);
}
throw new ReflectionException("Can not resolve class $className");
} | php | private function fetchReflectionClass(Node\Name $node)
{
$className = $node->toString();
$isFQNClass = $node instanceof Node\Name\FullyQualified;
if ($isFQNClass) {
// check to see if the class is already loaded and is safe to use
// PHP's ReflectionClass to determine if the class is user defined
if (class_exists($className, false)) {
$refClass = new \ReflectionClass($className);
if (!$refClass->isUserDefined()) {
return $refClass;
}
}
return new ReflectionClass($className);
}
if ('self' === $className) {
if ($this->context instanceof \ReflectionClass) {
return $this->context;
} elseif (method_exists($this->context, 'getDeclaringClass')) {
return $this->context->getDeclaringClass();
}
}
if ('parent' === $className) {
if ($this->context instanceof \ReflectionClass) {
return $this->context->getParentClass();
} elseif (method_exists($this->context, 'getDeclaringClass')) {
return $this->context->getDeclaringClass()->getParentClass();
}
}
if (method_exists($this->context, 'getFileName')) {
/** @var ReflectionFileNamespace|null $fileNamespace */
$fileName = $this->context->getFileName();
$namespaceName = $this->resolveScalarMagicConstNamespace();
$fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName);
return $fileNamespace->getClass($className);
}
throw new ReflectionException("Can not resolve class $className");
} | [
"private",
"function",
"fetchReflectionClass",
"(",
"Node",
"\\",
"Name",
"$",
"node",
")",
"{",
"$",
"className",
"=",
"$",
"node",
"->",
"toString",
"(",
")",
";",
"$",
"isFQNClass",
"=",
"$",
"node",
"instanceof",
"Node",
"\\",
"Name",
"\\",
"FullyQualified",
";",
"if",
"(",
"$",
"isFQNClass",
")",
"{",
"// check to see if the class is already loaded and is safe to use",
"// PHP's ReflectionClass to determine if the class is user defined",
"if",
"(",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
")",
"{",
"$",
"refClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"$",
"refClass",
"->",
"isUserDefined",
"(",
")",
")",
"{",
"return",
"$",
"refClass",
";",
"}",
"}",
"return",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"}",
"if",
"(",
"'self'",
"===",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"instanceof",
"\\",
"ReflectionClass",
")",
"{",
"return",
"$",
"this",
"->",
"context",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"context",
",",
"'getDeclaringClass'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"context",
"->",
"getDeclaringClass",
"(",
")",
";",
"}",
"}",
"if",
"(",
"'parent'",
"===",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"instanceof",
"\\",
"ReflectionClass",
")",
"{",
"return",
"$",
"this",
"->",
"context",
"->",
"getParentClass",
"(",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"context",
",",
"'getDeclaringClass'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"context",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getParentClass",
"(",
")",
";",
"}",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"context",
",",
"'getFileName'",
")",
")",
"{",
"/** @var ReflectionFileNamespace|null $fileNamespace */",
"$",
"fileName",
"=",
"$",
"this",
"->",
"context",
"->",
"getFileName",
"(",
")",
";",
"$",
"namespaceName",
"=",
"$",
"this",
"->",
"resolveScalarMagicConstNamespace",
"(",
")",
";",
"$",
"fileNamespace",
"=",
"new",
"ReflectionFileNamespace",
"(",
"$",
"fileName",
",",
"$",
"namespaceName",
")",
";",
"return",
"$",
"fileNamespace",
"->",
"getClass",
"(",
"$",
"className",
")",
";",
"}",
"throw",
"new",
"ReflectionException",
"(",
"\"Can not resolve class $className\"",
")",
";",
"}"
] | Utility method to fetch reflection class instance by name
Supports:
'self' keyword
'parent' keyword
not-FQN class names
@param Node\Name $node Class name node
@return bool|\ReflectionClass
@throws ReflectionException | [
"Utility",
"method",
"to",
"fetch",
"reflection",
"class",
"instance",
"by",
"name"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ValueResolver/NodeExpressionResolver.php#L471-L513 |
33,179 | majkel89/dbase | src/Field.php | Field.removeFilter | public function removeFilter($indexOrFilter) {
if (is_scalar($indexOrFilter)) {
unset($this->filters[$indexOrFilter]);
} else if ($indexOrFilter instanceof FilterInterface) {
foreach ($this->filters as $i => $filter) {
if ($filter === $indexOrFilter) {
unset($this->filters[$i]);
}
}
}
return $this;
} | php | public function removeFilter($indexOrFilter) {
if (is_scalar($indexOrFilter)) {
unset($this->filters[$indexOrFilter]);
} else if ($indexOrFilter instanceof FilterInterface) {
foreach ($this->filters as $i => $filter) {
if ($filter === $indexOrFilter) {
unset($this->filters[$i]);
}
}
}
return $this;
} | [
"public",
"function",
"removeFilter",
"(",
"$",
"indexOrFilter",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"indexOrFilter",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"indexOrFilter",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"indexOrFilter",
"instanceof",
"FilterInterface",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"i",
"=>",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"===",
"$",
"indexOrFilter",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes filter at index or by object
@param integer $indexOrFilter
@return \org\majkel\dbase\Field | [
"Removes",
"filter",
"at",
"index",
"or",
"by",
"object"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L89-L100 |
33,180 | majkel89/dbase | src/Field.php | Field.setName | public function setName($name) {
if (strlen($name) > self::MAX_NAME_LENGTH) {
throw new Exception("Field name cannot be longer than ".self::MAX_NAME_LENGTH." characters");
}
$this->name = $name;
return $this;
} | php | public function setName($name) {
if (strlen($name) > self::MAX_NAME_LENGTH) {
throw new Exception("Field name cannot be longer than ".self::MAX_NAME_LENGTH." characters");
}
$this->name = $name;
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
">",
"self",
"::",
"MAX_NAME_LENGTH",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Field name cannot be longer than \"",
".",
"self",
"::",
"MAX_NAME_LENGTH",
".",
"\" characters\"",
")",
";",
"}",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Sets filed name
@param string $name
@return \org\majkel\dbase\Field
@throws \org\majkel\dbase\Exception | [
"Sets",
"filed",
"name"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L118-L124 |
33,181 | majkel89/dbase | src/Field.php | Field.unserialize | public function unserialize($data) {
$value = $this->fromData($data);
foreach ($this->getFilters() as $filter) {
$value = $filter->toValue($value);
}
return $value;
} | php | public function unserialize($data) {
$value = $this->fromData($data);
foreach ($this->getFilters() as $filter) {
$value = $filter->toValue($value);
}
return $value;
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"fromData",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFilters",
"(",
")",
"as",
"$",
"filter",
")",
"{",
"$",
"value",
"=",
"$",
"filter",
"->",
"toValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Constructs value from raw data and applies filters
@param string $data
@return mixed | [
"Constructs",
"value",
"from",
"raw",
"data",
"and",
"applies",
"filters"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L185-L191 |
33,182 | majkel89/dbase | src/Field.php | Field.serialize | public function serialize($value) {
$filters = $this->getFilters();
for ($i = count($filters) - 1; $i >= 0; --$i) {
$value = $filters[$i]->fromValue($value);
}
return $this->toData($value);
} | php | public function serialize($value) {
$filters = $this->getFilters();
for ($i = count($filters) - 1; $i >= 0; --$i) {
$value = $filters[$i]->fromValue($value);
}
return $this->toData($value);
} | [
"public",
"function",
"serialize",
"(",
"$",
"value",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"getFilters",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"filters",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"--",
"$",
"i",
")",
"{",
"$",
"value",
"=",
"$",
"filters",
"[",
"$",
"i",
"]",
"->",
"fromValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"toData",
"(",
"$",
"value",
")",
";",
"}"
] | Applies filters and converts value to raw data
@param mixed $value
@return string | [
"Applies",
"filters",
"and",
"converts",
"value",
"to",
"raw",
"data"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L198-L204 |
33,183 | majkel89/dbase | src/Field.php | Field.create | public static function create($type) {
switch ($type) {
case Field::TYPE_CHARACTER:
return new field\CharacterField;
case Field::TYPE_DATE:
return new field\DateField;
case Field::TYPE_LOGICAL:
return new field\LogicalField;
case Field::TYPE_MEMO:
return new field\MemoField;
case Field::TYPE_NUMERIC:
return new field\NumericField;
default:
throw new Exception("Unsupported field `$type`");
}
} | php | public static function create($type) {
switch ($type) {
case Field::TYPE_CHARACTER:
return new field\CharacterField;
case Field::TYPE_DATE:
return new field\DateField;
case Field::TYPE_LOGICAL:
return new field\LogicalField;
case Field::TYPE_MEMO:
return new field\MemoField;
case Field::TYPE_NUMERIC:
return new field\NumericField;
default:
throw new Exception("Unsupported field `$type`");
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"Field",
"::",
"TYPE_CHARACTER",
":",
"return",
"new",
"field",
"\\",
"CharacterField",
";",
"case",
"Field",
"::",
"TYPE_DATE",
":",
"return",
"new",
"field",
"\\",
"DateField",
";",
"case",
"Field",
"::",
"TYPE_LOGICAL",
":",
"return",
"new",
"field",
"\\",
"LogicalField",
";",
"case",
"Field",
"::",
"TYPE_MEMO",
":",
"return",
"new",
"field",
"\\",
"MemoField",
";",
"case",
"Field",
"::",
"TYPE_NUMERIC",
":",
"return",
"new",
"field",
"\\",
"NumericField",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"\"Unsupported field `$type`\"",
")",
";",
"}",
"}"
] | Constructs Filed based on type
@param string $type
@return \org\majkel\dbase\Field
@throws Exception | [
"Constructs",
"Filed",
"based",
"on",
"type"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L240-L255 |
33,184 | majkel89/dbase | src/Field.php | Field.getTypes | public static function getTypes() {
return array(
self::TYPE_CHARACTER,
self::TYPE_LOGICAL,
self::TYPE_DATE ,
self::TYPE_NUMERIC,
self::TYPE_MEMO,
);
} | php | public static function getTypes() {
return array(
self::TYPE_CHARACTER,
self::TYPE_LOGICAL,
self::TYPE_DATE ,
self::TYPE_NUMERIC,
self::TYPE_MEMO,
);
} | [
"public",
"static",
"function",
"getTypes",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"TYPE_CHARACTER",
",",
"self",
"::",
"TYPE_LOGICAL",
",",
"self",
"::",
"TYPE_DATE",
",",
"self",
"::",
"TYPE_NUMERIC",
",",
"self",
"::",
"TYPE_MEMO",
",",
")",
";",
"}"
] | Returns all supported types
@return integer[] | [
"Returns",
"all",
"supported",
"types"
] | 483f27e83bae5323817c26aa297d923a4231dd6f | https://github.com/majkel89/dbase/blob/483f27e83bae5323817c26aa297d923a4231dd6f/src/Field.php#L261-L269 |
33,185 | goaop/parser-reflection | src/ReflectionClass.php | ReflectionClass.collectInterfacesFromClassNode | public static function collectInterfacesFromClassNode(ClassLike $classLikeNode)
{
$interfaces = [];
$isInterface = $classLikeNode instanceof Interface_;
$interfaceField = $isInterface ? 'extends' : 'implements';
$hasInterfaces = in_array($interfaceField, $classLikeNode->getSubNodeNames());
$implementsList = $hasInterfaces ? $classLikeNode->$interfaceField : array();
if ($implementsList) {
foreach ($implementsList as $implementNode) {
if ($implementNode instanceof FullyQualified) {
$implementName = $implementNode->toString();
$interface = interface_exists($implementName, false)
? new parent($implementName)
: new static($implementName);
$interfaces[$implementName] = $interface;
}
}
}
return $interfaces;
} | php | public static function collectInterfacesFromClassNode(ClassLike $classLikeNode)
{
$interfaces = [];
$isInterface = $classLikeNode instanceof Interface_;
$interfaceField = $isInterface ? 'extends' : 'implements';
$hasInterfaces = in_array($interfaceField, $classLikeNode->getSubNodeNames());
$implementsList = $hasInterfaces ? $classLikeNode->$interfaceField : array();
if ($implementsList) {
foreach ($implementsList as $implementNode) {
if ($implementNode instanceof FullyQualified) {
$implementName = $implementNode->toString();
$interface = interface_exists($implementName, false)
? new parent($implementName)
: new static($implementName);
$interfaces[$implementName] = $interface;
}
}
}
return $interfaces;
} | [
"public",
"static",
"function",
"collectInterfacesFromClassNode",
"(",
"ClassLike",
"$",
"classLikeNode",
")",
"{",
"$",
"interfaces",
"=",
"[",
"]",
";",
"$",
"isInterface",
"=",
"$",
"classLikeNode",
"instanceof",
"Interface_",
";",
"$",
"interfaceField",
"=",
"$",
"isInterface",
"?",
"'extends'",
":",
"'implements'",
";",
"$",
"hasInterfaces",
"=",
"in_array",
"(",
"$",
"interfaceField",
",",
"$",
"classLikeNode",
"->",
"getSubNodeNames",
"(",
")",
")",
";",
"$",
"implementsList",
"=",
"$",
"hasInterfaces",
"?",
"$",
"classLikeNode",
"->",
"$",
"interfaceField",
":",
"array",
"(",
")",
";",
"if",
"(",
"$",
"implementsList",
")",
"{",
"foreach",
"(",
"$",
"implementsList",
"as",
"$",
"implementNode",
")",
"{",
"if",
"(",
"$",
"implementNode",
"instanceof",
"FullyQualified",
")",
"{",
"$",
"implementName",
"=",
"$",
"implementNode",
"->",
"toString",
"(",
")",
";",
"$",
"interface",
"=",
"interface_exists",
"(",
"$",
"implementName",
",",
"false",
")",
"?",
"new",
"parent",
"(",
"$",
"implementName",
")",
":",
"new",
"static",
"(",
"$",
"implementName",
")",
";",
"$",
"interfaces",
"[",
"$",
"implementName",
"]",
"=",
"$",
"interface",
";",
"}",
"}",
"}",
"return",
"$",
"interfaces",
";",
"}"
] | Parses interfaces from the concrete class node
@param ClassLike $classLikeNode Class-like node
@return array|\ReflectionClass[] List of reflections of interfaces | [
"Parses",
"interfaces",
"from",
"the",
"concrete",
"class",
"node"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionClass.php#L54-L75 |
33,186 | goaop/parser-reflection | src/ReflectionClass.php | ReflectionClass.collectTraitsFromClassNode | public static function collectTraitsFromClassNode(ClassLike $classLikeNode, array &$traitAdaptations)
{
$traits = [];
if (!empty($classLikeNode->stmts)) {
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof TraitUse) {
foreach ($classLevelNode->traits as $classTraitName) {
if ($classTraitName instanceof FullyQualified) {
$traitName = $classTraitName->toString();
$trait = trait_exists($traitName, false)
? new parent($traitName)
: new static($traitName);
$traits[$traitName] = $trait;
}
}
$traitAdaptations = $classLevelNode->adaptations;
}
}
}
return $traits;
} | php | public static function collectTraitsFromClassNode(ClassLike $classLikeNode, array &$traitAdaptations)
{
$traits = [];
if (!empty($classLikeNode->stmts)) {
foreach ($classLikeNode->stmts as $classLevelNode) {
if ($classLevelNode instanceof TraitUse) {
foreach ($classLevelNode->traits as $classTraitName) {
if ($classTraitName instanceof FullyQualified) {
$traitName = $classTraitName->toString();
$trait = trait_exists($traitName, false)
? new parent($traitName)
: new static($traitName);
$traits[$traitName] = $trait;
}
}
$traitAdaptations = $classLevelNode->adaptations;
}
}
}
return $traits;
} | [
"public",
"static",
"function",
"collectTraitsFromClassNode",
"(",
"ClassLike",
"$",
"classLikeNode",
",",
"array",
"&",
"$",
"traitAdaptations",
")",
"{",
"$",
"traits",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"classLikeNode",
"->",
"stmts",
")",
")",
"{",
"foreach",
"(",
"$",
"classLikeNode",
"->",
"stmts",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"TraitUse",
")",
"{",
"foreach",
"(",
"$",
"classLevelNode",
"->",
"traits",
"as",
"$",
"classTraitName",
")",
"{",
"if",
"(",
"$",
"classTraitName",
"instanceof",
"FullyQualified",
")",
"{",
"$",
"traitName",
"=",
"$",
"classTraitName",
"->",
"toString",
"(",
")",
";",
"$",
"trait",
"=",
"trait_exists",
"(",
"$",
"traitName",
",",
"false",
")",
"?",
"new",
"parent",
"(",
"$",
"traitName",
")",
":",
"new",
"static",
"(",
"$",
"traitName",
")",
";",
"$",
"traits",
"[",
"$",
"traitName",
"]",
"=",
"$",
"trait",
";",
"}",
"}",
"$",
"traitAdaptations",
"=",
"$",
"classLevelNode",
"->",
"adaptations",
";",
"}",
"}",
"}",
"return",
"$",
"traits",
";",
"}"
] | Parses traits from the concrete class node
@param ClassLike $classLikeNode Class-like node
@param array $traitAdaptations List of method adaptations
@return array|\ReflectionClass[] List of reflections of traits | [
"Parses",
"traits",
"from",
"the",
"concrete",
"class",
"node"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionClass.php#L85-L107 |
33,187 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.setMaximumCachedFiles | public static function setMaximumCachedFiles($newLimit)
{
self::$maximumCachedFiles = $newLimit;
if (count(self::$parsedFiles) > $newLimit) {
self::$parsedFiles = array_slice(self::$parsedFiles, 0, $newLimit);
}
} | php | public static function setMaximumCachedFiles($newLimit)
{
self::$maximumCachedFiles = $newLimit;
if (count(self::$parsedFiles) > $newLimit) {
self::$parsedFiles = array_slice(self::$parsedFiles, 0, $newLimit);
}
} | [
"public",
"static",
"function",
"setMaximumCachedFiles",
"(",
"$",
"newLimit",
")",
"{",
"self",
"::",
"$",
"maximumCachedFiles",
"=",
"$",
"newLimit",
";",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"parsedFiles",
")",
">",
"$",
"newLimit",
")",
"{",
"self",
"::",
"$",
"parsedFiles",
"=",
"array_slice",
"(",
"self",
"::",
"$",
"parsedFiles",
",",
"0",
",",
"$",
"newLimit",
")",
";",
"}",
"}"
] | Limits number of files, that can be cached at any given moment
@param integer $newLimit New limit
@return void | [
"Limits",
"number",
"of",
"files",
"that",
"can",
"be",
"cached",
"at",
"any",
"given",
"moment"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L91-L97 |
33,188 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.locateClassFile | public static function locateClassFile($fullClassName)
{
if (class_exists($fullClassName, false)
|| interface_exists($fullClassName, false)
|| trait_exists($fullClassName, false)
) {
$refClass = new \ReflectionClass($fullClassName);
$classFileName = $refClass->getFileName();
} else {
$classFileName = self::$locator->locateClass($fullClassName);
}
if (!$classFileName) {
throw new \InvalidArgumentException("Class $fullClassName was not found by locator");
}
return $classFileName;
} | php | public static function locateClassFile($fullClassName)
{
if (class_exists($fullClassName, false)
|| interface_exists($fullClassName, false)
|| trait_exists($fullClassName, false)
) {
$refClass = new \ReflectionClass($fullClassName);
$classFileName = $refClass->getFileName();
} else {
$classFileName = self::$locator->locateClass($fullClassName);
}
if (!$classFileName) {
throw new \InvalidArgumentException("Class $fullClassName was not found by locator");
}
return $classFileName;
} | [
"public",
"static",
"function",
"locateClassFile",
"(",
"$",
"fullClassName",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"fullClassName",
",",
"false",
")",
"||",
"interface_exists",
"(",
"$",
"fullClassName",
",",
"false",
")",
"||",
"trait_exists",
"(",
"$",
"fullClassName",
",",
"false",
")",
")",
"{",
"$",
"refClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"fullClassName",
")",
";",
"$",
"classFileName",
"=",
"$",
"refClass",
"->",
"getFileName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"classFileName",
"=",
"self",
"::",
"$",
"locator",
"->",
"locateClass",
"(",
"$",
"fullClassName",
")",
";",
"}",
"if",
"(",
"!",
"$",
"classFileName",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Class $fullClassName was not found by locator\"",
")",
";",
"}",
"return",
"$",
"classFileName",
";",
"}"
] | Locates a file name for class
@param string $fullClassName Full name of the class
@return string | [
"Locates",
"a",
"file",
"name",
"for",
"class"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L106-L123 |
33,189 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.parseClass | public static function parseClass($fullClassName)
{
$classFileName = self::locateClassFile($fullClassName);
$namespaceParts = explode('\\', $fullClassName);
$className = array_pop($namespaceParts);
$namespaceName = join('\\', $namespaceParts);
// we have a namespace node somewhere
$namespace = self::parseFileNamespace($classFileName, $namespaceName);
$namespaceNodes = $namespace->stmts;
foreach ($namespaceNodes as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof ClassLike && $namespaceLevelNode->name == $className) {
$namespaceLevelNode->setAttribute('fileName', $classFileName);
return $namespaceLevelNode;
}
}
throw new \InvalidArgumentException("Class $fullClassName was not found in the $classFileName");
} | php | public static function parseClass($fullClassName)
{
$classFileName = self::locateClassFile($fullClassName);
$namespaceParts = explode('\\', $fullClassName);
$className = array_pop($namespaceParts);
$namespaceName = join('\\', $namespaceParts);
// we have a namespace node somewhere
$namespace = self::parseFileNamespace($classFileName, $namespaceName);
$namespaceNodes = $namespace->stmts;
foreach ($namespaceNodes as $namespaceLevelNode) {
if ($namespaceLevelNode instanceof ClassLike && $namespaceLevelNode->name == $className) {
$namespaceLevelNode->setAttribute('fileName', $classFileName);
return $namespaceLevelNode;
}
}
throw new \InvalidArgumentException("Class $fullClassName was not found in the $classFileName");
} | [
"public",
"static",
"function",
"parseClass",
"(",
"$",
"fullClassName",
")",
"{",
"$",
"classFileName",
"=",
"self",
"::",
"locateClassFile",
"(",
"$",
"fullClassName",
")",
";",
"$",
"namespaceParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"fullClassName",
")",
";",
"$",
"className",
"=",
"array_pop",
"(",
"$",
"namespaceParts",
")",
";",
"$",
"namespaceName",
"=",
"join",
"(",
"'\\\\'",
",",
"$",
"namespaceParts",
")",
";",
"// we have a namespace node somewhere",
"$",
"namespace",
"=",
"self",
"::",
"parseFileNamespace",
"(",
"$",
"classFileName",
",",
"$",
"namespaceName",
")",
";",
"$",
"namespaceNodes",
"=",
"$",
"namespace",
"->",
"stmts",
";",
"foreach",
"(",
"$",
"namespaceNodes",
"as",
"$",
"namespaceLevelNode",
")",
"{",
"if",
"(",
"$",
"namespaceLevelNode",
"instanceof",
"ClassLike",
"&&",
"$",
"namespaceLevelNode",
"->",
"name",
"==",
"$",
"className",
")",
"{",
"$",
"namespaceLevelNode",
"->",
"setAttribute",
"(",
"'fileName'",
",",
"$",
"classFileName",
")",
";",
"return",
"$",
"namespaceLevelNode",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Class $fullClassName was not found in the $classFileName\"",
")",
";",
"}"
] | Tries to parse a class by name using LocatorInterface
@param string $fullClassName Class name to load
@return ClassLike | [
"Tries",
"to",
"parse",
"a",
"class",
"by",
"name",
"using",
"LocatorInterface"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L132-L152 |
33,190 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.parseClassMethod | public static function parseClassMethod($fullClassName, $methodName)
{
$class = self::parseClass($fullClassName);
$classNodes = $class->stmts;
foreach ($classNodes as $classLevelNode) {
if ($classLevelNode instanceof ClassMethod && $classLevelNode->name->toString() == $methodName) {
return $classLevelNode;
}
}
throw new \InvalidArgumentException("Method $methodName was not found in the $fullClassName");
} | php | public static function parseClassMethod($fullClassName, $methodName)
{
$class = self::parseClass($fullClassName);
$classNodes = $class->stmts;
foreach ($classNodes as $classLevelNode) {
if ($classLevelNode instanceof ClassMethod && $classLevelNode->name->toString() == $methodName) {
return $classLevelNode;
}
}
throw new \InvalidArgumentException("Method $methodName was not found in the $fullClassName");
} | [
"public",
"static",
"function",
"parseClassMethod",
"(",
"$",
"fullClassName",
",",
"$",
"methodName",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"parseClass",
"(",
"$",
"fullClassName",
")",
";",
"$",
"classNodes",
"=",
"$",
"class",
"->",
"stmts",
";",
"foreach",
"(",
"$",
"classNodes",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"ClassMethod",
"&&",
"$",
"classLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
"==",
"$",
"methodName",
")",
"{",
"return",
"$",
"classLevelNode",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Method $methodName was not found in the $fullClassName\"",
")",
";",
"}"
] | Parses class method
@param string $fullClassName Name of the class
@param string $methodName Name of the method
@return ClassMethod | [
"Parses",
"class",
"method"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L162-L174 |
33,191 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.parseClassProperty | public static function parseClassProperty($fullClassName, $propertyName)
{
$class = self::parseClass($fullClassName);
$classNodes = $class->stmts;
foreach ($classNodes as $classLevelNode) {
if ($classLevelNode instanceof Property) {
foreach ($classLevelNode->props as $classProperty) {
if ($classProperty->name->toString() == $propertyName) {
return [$classLevelNode, $classProperty];
}
}
}
}
throw new \InvalidArgumentException("Property $propertyName was not found in the $fullClassName");
} | php | public static function parseClassProperty($fullClassName, $propertyName)
{
$class = self::parseClass($fullClassName);
$classNodes = $class->stmts;
foreach ($classNodes as $classLevelNode) {
if ($classLevelNode instanceof Property) {
foreach ($classLevelNode->props as $classProperty) {
if ($classProperty->name->toString() == $propertyName) {
return [$classLevelNode, $classProperty];
}
}
}
}
throw new \InvalidArgumentException("Property $propertyName was not found in the $fullClassName");
} | [
"public",
"static",
"function",
"parseClassProperty",
"(",
"$",
"fullClassName",
",",
"$",
"propertyName",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"parseClass",
"(",
"$",
"fullClassName",
")",
";",
"$",
"classNodes",
"=",
"$",
"class",
"->",
"stmts",
";",
"foreach",
"(",
"$",
"classNodes",
"as",
"$",
"classLevelNode",
")",
"{",
"if",
"(",
"$",
"classLevelNode",
"instanceof",
"Property",
")",
"{",
"foreach",
"(",
"$",
"classLevelNode",
"->",
"props",
"as",
"$",
"classProperty",
")",
"{",
"if",
"(",
"$",
"classProperty",
"->",
"name",
"->",
"toString",
"(",
")",
"==",
"$",
"propertyName",
")",
"{",
"return",
"[",
"$",
"classLevelNode",
",",
"$",
"classProperty",
"]",
";",
"}",
"}",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Property $propertyName was not found in the $fullClassName\"",
")",
";",
"}"
] | Parses class property
@param string $fullClassName Name of the class
@param string $propertyName Name of the property
@return array Pair of [Property and PropertyProperty] nodes | [
"Parses",
"class",
"property"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L184-L200 |
33,192 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.parseFile | public static function parseFile($fileName, $fileContent = null)
{
$fileName = PathResolver::realpath($fileName);
if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) {
return self::$parsedFiles[$fileName];
}
if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) {
array_shift(self::$parsedFiles);
}
if (!isset($fileContent)) {
$fileContent = file_get_contents($fileName);
}
$treeNode = self::$parser->parse($fileContent);
$treeNode = self::$traverser->traverse($treeNode);
self::$parsedFiles[$fileName] = $treeNode;
return $treeNode;
} | php | public static function parseFile($fileName, $fileContent = null)
{
$fileName = PathResolver::realpath($fileName);
if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) {
return self::$parsedFiles[$fileName];
}
if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) {
array_shift(self::$parsedFiles);
}
if (!isset($fileContent)) {
$fileContent = file_get_contents($fileName);
}
$treeNode = self::$parser->parse($fileContent);
$treeNode = self::$traverser->traverse($treeNode);
self::$parsedFiles[$fileName] = $treeNode;
return $treeNode;
} | [
"public",
"static",
"function",
"parseFile",
"(",
"$",
"fileName",
",",
"$",
"fileContent",
"=",
"null",
")",
"{",
"$",
"fileName",
"=",
"PathResolver",
"::",
"realpath",
"(",
"$",
"fileName",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"parsedFiles",
"[",
"$",
"fileName",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"fileContent",
")",
")",
"{",
"return",
"self",
"::",
"$",
"parsedFiles",
"[",
"$",
"fileName",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"maximumCachedFiles",
")",
"&&",
"(",
"count",
"(",
"self",
"::",
"$",
"parsedFiles",
")",
"===",
"self",
"::",
"$",
"maximumCachedFiles",
")",
")",
"{",
"array_shift",
"(",
"self",
"::",
"$",
"parsedFiles",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"fileContent",
")",
")",
"{",
"$",
"fileContent",
"=",
"file_get_contents",
"(",
"$",
"fileName",
")",
";",
"}",
"$",
"treeNode",
"=",
"self",
"::",
"$",
"parser",
"->",
"parse",
"(",
"$",
"fileContent",
")",
";",
"$",
"treeNode",
"=",
"self",
"::",
"$",
"traverser",
"->",
"traverse",
"(",
"$",
"treeNode",
")",
";",
"self",
"::",
"$",
"parsedFiles",
"[",
"$",
"fileName",
"]",
"=",
"$",
"treeNode",
";",
"return",
"$",
"treeNode",
";",
"}"
] | Parses a file and returns an AST for it
@param string $fileName Name of the file
@param string|null $fileContent Optional content of the file
@return \PhpParser\Node[] | [
"Parses",
"a",
"file",
"and",
"returns",
"an",
"AST",
"for",
"it"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L210-L230 |
33,193 | goaop/parser-reflection | src/ReflectionEngine.php | ReflectionEngine.parseFileNamespace | public static function parseFileNamespace($fileName, $namespaceName)
{
$topLevelNodes = self::parseFile($fileName);
// namespaces can be only top-level nodes, so we can scan them directly
foreach ($topLevelNodes as $topLevelNode) {
if (!$topLevelNode instanceof Namespace_) {
continue;
}
$topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) {
return $topLevelNode;
}
}
throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName");
} | php | public static function parseFileNamespace($fileName, $namespaceName)
{
$topLevelNodes = self::parseFile($fileName);
// namespaces can be only top-level nodes, so we can scan them directly
foreach ($topLevelNodes as $topLevelNode) {
if (!$topLevelNode instanceof Namespace_) {
continue;
}
$topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) {
return $topLevelNode;
}
}
throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName");
} | [
"public",
"static",
"function",
"parseFileNamespace",
"(",
"$",
"fileName",
",",
"$",
"namespaceName",
")",
"{",
"$",
"topLevelNodes",
"=",
"self",
"::",
"parseFile",
"(",
"$",
"fileName",
")",
";",
"// namespaces can be only top-level nodes, so we can scan them directly",
"foreach",
"(",
"$",
"topLevelNodes",
"as",
"$",
"topLevelNode",
")",
"{",
"if",
"(",
"!",
"$",
"topLevelNode",
"instanceof",
"Namespace_",
")",
"{",
"continue",
";",
"}",
"$",
"topLevelNodeName",
"=",
"$",
"topLevelNode",
"->",
"name",
"?",
"$",
"topLevelNode",
"->",
"name",
"->",
"toString",
"(",
")",
":",
"''",
";",
"if",
"(",
"ltrim",
"(",
"$",
"topLevelNodeName",
",",
"'\\\\'",
")",
"===",
"trim",
"(",
"$",
"namespaceName",
",",
"'\\\\'",
")",
")",
"{",
"return",
"$",
"topLevelNode",
";",
"}",
"}",
"throw",
"new",
"ReflectionException",
"(",
"\"Namespace $namespaceName was not found in the file $fileName\"",
")",
";",
"}"
] | Parses a file namespace and returns an AST for it
@param string $fileName Name of the file
@param string $namespaceName Namespace name
@return Namespace_
@throws ReflectionException | [
"Parses",
"a",
"file",
"namespace",
"and",
"returns",
"an",
"AST",
"for",
"it"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/ReflectionEngine.php#L241-L256 |
33,194 | goaop/parser-reflection | src/Locator/ComposerLocator.php | ComposerLocator.locateClass | public function locateClass($className)
{
$filePath = $this->loader->findFile(ltrim($className, '\\'));
if (!empty($filePath)) {
$filePath = PathResolver::realpath($filePath);
}
return $filePath;
} | php | public function locateClass($className)
{
$filePath = $this->loader->findFile(ltrim($className, '\\'));
if (!empty($filePath)) {
$filePath = PathResolver::realpath($filePath);
}
return $filePath;
} | [
"public",
"function",
"locateClass",
"(",
"$",
"className",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"loader",
"->",
"findFile",
"(",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"filePath",
"=",
"PathResolver",
"::",
"realpath",
"(",
"$",
"filePath",
")",
";",
"}",
"return",
"$",
"filePath",
";",
"}"
] | Returns a path to the file for given class name
@param string $className Name of the class
@return string|false Path to the file with given class or false if not found | [
"Returns",
"a",
"path",
"to",
"the",
"file",
"for",
"given",
"class",
"name"
] | a71d0454ef8bfa416a39bbb7dd3ed497e063e54c | https://github.com/goaop/parser-reflection/blob/a71d0454ef8bfa416a39bbb7dd3ed497e063e54c/src/Locator/ComposerLocator.php#L52-L60 |
33,195 | rossedman/teamwork | src/Rossedman/Teamwork/AbstractObject.php | AbstractObject.areArgumentsValid | protected function areArgumentsValid($args, array $accepted)
{
if ($args == null)
{
return;
}
foreach ($accepted as $accept)
{
if (array_key_exists($accept, $args))
{
return true;
}
}
throw new \InvalidArgumentException('This call only accepts these arguments: ' . implode(" | ",$accepted));
} | php | protected function areArgumentsValid($args, array $accepted)
{
if ($args == null)
{
return;
}
foreach ($accepted as $accept)
{
if (array_key_exists($accept, $args))
{
return true;
}
}
throw new \InvalidArgumentException('This call only accepts these arguments: ' . implode(" | ",$accepted));
} | [
"protected",
"function",
"areArgumentsValid",
"(",
"$",
"args",
",",
"array",
"$",
"accepted",
")",
"{",
"if",
"(",
"$",
"args",
"==",
"null",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"accepted",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"accept",
",",
"$",
"args",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'This call only accepts these arguments: '",
".",
"implode",
"(",
"\" | \"",
",",
"$",
"accepted",
")",
")",
";",
"}"
] | Are Arguments Valid
@param array $args
@param string[] $accepted
@return null|bool | [
"Are",
"Arguments",
"Valid"
] | c929b0f11114ec6a808df81762879be84a9d2e36 | https://github.com/rossedman/teamwork/blob/c929b0f11114ec6a808df81762879be84a9d2e36/src/Rossedman/Teamwork/AbstractObject.php#L52-L68 |
33,196 | rossedman/teamwork | src/Rossedman/Teamwork/Client.php | Client.buildQuery | public function buildQuery($query)
{
$q = $this->request->getQuery();
foreach ($query as $key => $value)
{
$q[$key] = $value;
}
} | php | public function buildQuery($query)
{
$q = $this->request->getQuery();
foreach ($query as $key => $value)
{
$q[$key] = $value;
}
} | [
"public",
"function",
"buildQuery",
"(",
"$",
"query",
")",
"{",
"$",
"q",
"=",
"$",
"this",
"->",
"request",
"->",
"getQuery",
"(",
")",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"q",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Build Query String
if a query string is needed it will be built up
and added to the request. This is only used in certain
GET requests
@param $query | [
"Build",
"Query",
"String"
] | c929b0f11114ec6a808df81762879be84a9d2e36 | https://github.com/rossedman/teamwork/blob/c929b0f11114ec6a808df81762879be84a9d2e36/src/Rossedman/Teamwork/Client.php#L197-L205 |
33,197 | alterphp/components | src/AlterPHP/Component/ToolBox/BitTools.php | BitTools.getBitArrayFromInt | public static function getBitArrayFromInt($int)
{
$binstr = (string) decbin($int);
$binarr = array_reverse(str_split($binstr));
$bitarr = array_keys($binarr, '1', true);
return $bitarr;
} | php | public static function getBitArrayFromInt($int)
{
$binstr = (string) decbin($int);
$binarr = array_reverse(str_split($binstr));
$bitarr = array_keys($binarr, '1', true);
return $bitarr;
} | [
"public",
"static",
"function",
"getBitArrayFromInt",
"(",
"$",
"int",
")",
"{",
"$",
"binstr",
"=",
"(",
"string",
")",
"decbin",
"(",
"$",
"int",
")",
";",
"$",
"binarr",
"=",
"array_reverse",
"(",
"str_split",
"(",
"$",
"binstr",
")",
")",
";",
"$",
"bitarr",
"=",
"array_keys",
"(",
"$",
"binarr",
",",
"'1'",
",",
"true",
")",
";",
"return",
"$",
"bitarr",
";",
"}"
] | Return an array of active bits in the binary representation of the given integer
@param integer $int
@return array | [
"Return",
"an",
"array",
"of",
"active",
"bits",
"in",
"the",
"binary",
"representation",
"of",
"the",
"given",
"integer"
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/ToolBox/BitTools.php#L31-L38 |
33,198 | alterphp/components | src/AlterPHP/Component/Behavior/StatusableEntity.php | StatusableEntity.getStatusList | public static function getStatusList($withLabelsAsIndexes = false, array $filterStatus = null)
{
// Build $statusValues if this is the first call
if (null === static::$statusValues) {
static::$statusValues = array();
$refClass = new \ReflectionClass(get_called_class());
$classConstants = $refClass->getConstants();
$className = $refClass->getShortName();
$constantPrefix = 'STATUS_';
foreach ($classConstants as $key => $val) {
if (substr($key, 0, strlen($constantPrefix)) === $constantPrefix) {
static::$statusValues[$val] = static::getLowerCaseClassName().'.status.'.$val;
}
}
}
$statusValues = static::$statusValues;
// Filter on specified status list
if (isset($filterStatus)) {
$statusValues = array_filter($statusValues, function ($key) use ($filterStatus) {
return in_array($key, $filterStatus);
}, ARRAY_FILTER_USE_KEY);
}
if ($withLabelsAsIndexes) {
return array_flip($statusValues);
}
return array_keys($statusValues);
} | php | public static function getStatusList($withLabelsAsIndexes = false, array $filterStatus = null)
{
// Build $statusValues if this is the first call
if (null === static::$statusValues) {
static::$statusValues = array();
$refClass = new \ReflectionClass(get_called_class());
$classConstants = $refClass->getConstants();
$className = $refClass->getShortName();
$constantPrefix = 'STATUS_';
foreach ($classConstants as $key => $val) {
if (substr($key, 0, strlen($constantPrefix)) === $constantPrefix) {
static::$statusValues[$val] = static::getLowerCaseClassName().'.status.'.$val;
}
}
}
$statusValues = static::$statusValues;
// Filter on specified status list
if (isset($filterStatus)) {
$statusValues = array_filter($statusValues, function ($key) use ($filterStatus) {
return in_array($key, $filterStatus);
}, ARRAY_FILTER_USE_KEY);
}
if ($withLabelsAsIndexes) {
return array_flip($statusValues);
}
return array_keys($statusValues);
} | [
"public",
"static",
"function",
"getStatusList",
"(",
"$",
"withLabelsAsIndexes",
"=",
"false",
",",
"array",
"$",
"filterStatus",
"=",
"null",
")",
"{",
"// Build $statusValues if this is the first call",
"if",
"(",
"null",
"===",
"static",
"::",
"$",
"statusValues",
")",
"{",
"static",
"::",
"$",
"statusValues",
"=",
"array",
"(",
")",
";",
"$",
"refClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"$",
"classConstants",
"=",
"$",
"refClass",
"->",
"getConstants",
"(",
")",
";",
"$",
"className",
"=",
"$",
"refClass",
"->",
"getShortName",
"(",
")",
";",
"$",
"constantPrefix",
"=",
"'STATUS_'",
";",
"foreach",
"(",
"$",
"classConstants",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"strlen",
"(",
"$",
"constantPrefix",
")",
")",
"===",
"$",
"constantPrefix",
")",
"{",
"static",
"::",
"$",
"statusValues",
"[",
"$",
"val",
"]",
"=",
"static",
"::",
"getLowerCaseClassName",
"(",
")",
".",
"'.status.'",
".",
"$",
"val",
";",
"}",
"}",
"}",
"$",
"statusValues",
"=",
"static",
"::",
"$",
"statusValues",
";",
"// Filter on specified status list",
"if",
"(",
"isset",
"(",
"$",
"filterStatus",
")",
")",
"{",
"$",
"statusValues",
"=",
"array_filter",
"(",
"$",
"statusValues",
",",
"function",
"(",
"$",
"key",
")",
"use",
"(",
"$",
"filterStatus",
")",
"{",
"return",
"in_array",
"(",
"$",
"key",
",",
"$",
"filterStatus",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}",
"if",
"(",
"$",
"withLabelsAsIndexes",
")",
"{",
"return",
"array_flip",
"(",
"$",
"statusValues",
")",
";",
"}",
"return",
"array_keys",
"(",
"$",
"statusValues",
")",
";",
"}"
] | Returns status list, with or without labels.
@param bool $withLabelsAsIndexes
@param array $filterStatus
@return array | [
"Returns",
"status",
"list",
"with",
"or",
"without",
"labels",
"."
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L39-L70 |
33,199 | alterphp/components | src/AlterPHP/Component/Behavior/StatusableEntity.php | StatusableEntity.isStatusBetween | public function isStatusBetween($from = null, $to = null, $strict = false, $strictTo = null)
{
return in_array($this->status, static::getStatusBetween($from, $to, $strict, $strictTo));
} | php | public function isStatusBetween($from = null, $to = null, $strict = false, $strictTo = null)
{
return in_array($this->status, static::getStatusBetween($from, $to, $strict, $strictTo));
} | [
"public",
"function",
"isStatusBetween",
"(",
"$",
"from",
"=",
"null",
",",
"$",
"to",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"strictTo",
"=",
"null",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"status",
",",
"static",
"::",
"getStatusBetween",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"strict",
",",
"$",
"strictTo",
")",
")",
";",
"}"
] | Checks if status is between a "from" and a "to" status.
@param string $from
@param string $to
@param bool $strict
@param bool $strictTo
@return bool | [
"Checks",
"if",
"status",
"is",
"between",
"a",
"from",
"and",
"a",
"to",
"status",
"."
] | a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5 | https://github.com/alterphp/components/blob/a2fa91bf02746f9493ffc742ab3ef1d2f18b56d5/src/AlterPHP/Component/Behavior/StatusableEntity.php#L82-L85 |
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.