repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Edujugon/laradoo | docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php | __TwigTemplate_ea3e599f9a1fa64a525c9c39db3fa418c46acca48a9be27f93437ff01bba6e57.block_see | public function block_see($context, array $blocks = array())
{
// line 142
echo " <table class=\"table table-condensed\">
";
// line 143
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 143, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method"));
foreach ($context['_seq'] as $context["_key"] => $context["tag"]) {
// line 144
echo " <tr>
<td>";
// line 145
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["tag"], 0, array(), "array");
echo "</td>
<td>";
// line 146
echo twig_join_filter(twig_slice($this->env, $context["tag"], 1, null), " ");
echo "</td>
</tr>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['tag'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 149
echo " </table>
";
} | php | public function block_see($context, array $blocks = array())
{
// line 142
echo " <table class=\"table table-condensed\">
";
// line 143
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 143, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method"));
foreach ($context['_seq'] as $context["_key"] => $context["tag"]) {
// line 144
echo " <tr>
<td>";
// line 145
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["tag"], 0, array(), "array");
echo "</td>
<td>";
// line 146
echo twig_join_filter(twig_slice($this->env, $context["tag"], 1, null), " ");
echo "</td>
</tr>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['tag'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 149
echo " </table>
";
} | [
"public",
"function",
"block_see",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 142",
"echo",
"\" <table class=\\\"table table-condensed\\\">\n \"",
";",
"// line 143",
"$",
"context",
"[",
"'_parent'",
"]",
... | line 141 | [
"line",
"141"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php#L430-L458 |
Edujugon/laradoo | docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php | __TwigTemplate_ea3e599f9a1fa64a525c9c39db3fa418c46acca48a9be27f93437ff01bba6e57.block_properties | public function block_properties($context, array $blocks = array())
{
// line 167
echo " <table class=\"table table-condensed\">
";
// line 168
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["properties"]) || array_key_exists("properties", $context) ? $context["properties"] : (function () { throw new Twig_Error_Runtime('Variable "properties" does not exist.', 168, $this->getSourceContext()); })()));
foreach ($context['_seq'] as $context["_key"] => $context["property"]) {
// line 169
echo " <tr>
<td class=\"type\" id=\"property_";
// line 170
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
echo "\">
";
// line 171
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "static", array())) {
echo "static";
}
// line 172
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "protected", array())) {
echo "protected";
}
// line 173
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "private", array())) {
echo "private";
}
// line 174
echo " ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "hint", array()));
echo "
</td>
<td>\$";
// line 176
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
echo "</td>
<td class=\"last\">";
// line 177
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 177, $this->getSourceContext()); })()));
echo "</td>
<td>";
// line 179
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 179, $this->getSourceContext()); })()))) {
// line 180
echo "<small>from ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_property_link($context["property"], false, true);
echo "</small>";
}
// line 182
echo "</td>
</tr>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['property'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 185
echo " </table>
";
} | php | public function block_properties($context, array $blocks = array())
{
// line 167
echo " <table class=\"table table-condensed\">
";
// line 168
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["properties"]) || array_key_exists("properties", $context) ? $context["properties"] : (function () { throw new Twig_Error_Runtime('Variable "properties" does not exist.', 168, $this->getSourceContext()); })()));
foreach ($context['_seq'] as $context["_key"] => $context["property"]) {
// line 169
echo " <tr>
<td class=\"type\" id=\"property_";
// line 170
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
echo "\">
";
// line 171
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "static", array())) {
echo "static";
}
// line 172
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "protected", array())) {
echo "protected";
}
// line 173
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "private", array())) {
echo "private";
}
// line 174
echo " ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "hint", array()));
echo "
</td>
<td>\$";
// line 176
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
echo "</td>
<td class=\"last\">";
// line 177
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 177, $this->getSourceContext()); })()));
echo "</td>
<td>";
// line 179
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 179, $this->getSourceContext()); })()))) {
// line 180
echo "<small>from ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_property_link($context["property"], false, true);
echo "</small>";
}
// line 182
echo "</td>
</tr>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['property'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 185
echo " </table>
";
} | [
"public",
"function",
"block_properties",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 167",
"echo",
"\" <table class=\\\"table table-condensed\\\">\n \"",
";",
"// line 168",
"$",
"context",
"[",
"'_parent'",
... | line 166 | [
"line",
"166"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php#L498-L560 |
Edujugon/laradoo | docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php | __TwigTemplate_ea3e599f9a1fa64a525c9c39db3fa418c46acca48a9be27f93437ff01bba6e57.block_methods | public function block_methods($context, array $blocks = array())
{
// line 189
echo " <div class=\"container-fluid underlined\">
";
// line 190
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 190, $this->getSourceContext()); })()));
$context['loop'] = array(
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
);
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
// line 191
echo " <div class=\"row\">
<div class=\"col-md-2 type\">
";
// line 193
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "static", array())) {
echo "static ";
}
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "hint", array()));
echo "
</div>
<div class=\"col-md-8 type\">
<a href=\"#method_";
// line 196
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
echo "\">";
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
echo "</a>";
$this->displayBlock("method_parameters_signature", $context, $blocks);
echo "
";
// line 197
if ( !twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array())) {
// line 198
echo " <p class=\"no-description\">No description</p>
";
} else {
// line 200
echo " <p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 200, $this->getSourceContext()); })()));
echo "</p>";
}
// line 202
echo " </div>
<div class=\"col-md-2\">";
// line 204
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 204, $this->getSourceContext()); })()))) {
// line 205
echo "<small>from ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_link($context["method"], false, true);
echo "</small>";
}
// line 207
echo "</div>
</div>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 210
echo " </div>
";
} | php | public function block_methods($context, array $blocks = array())
{
// line 189
echo " <div class=\"container-fluid underlined\">
";
// line 190
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 190, $this->getSourceContext()); })()));
$context['loop'] = array(
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
);
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
// line 191
echo " <div class=\"row\">
<div class=\"col-md-2 type\">
";
// line 193
if (twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "static", array())) {
echo "static ";
}
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "hint", array()));
echo "
</div>
<div class=\"col-md-8 type\">
<a href=\"#method_";
// line 196
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
echo "\">";
echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
echo "</a>";
$this->displayBlock("method_parameters_signature", $context, $blocks);
echo "
";
// line 197
if ( !twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array())) {
// line 198
echo " <p class=\"no-description\">No description</p>
";
} else {
// line 200
echo " <p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 200, $this->getSourceContext()); })()));
echo "</p>";
}
// line 202
echo " </div>
<div class=\"col-md-2\">";
// line 204
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 204, $this->getSourceContext()); })()))) {
// line 205
echo "<small>from ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_link($context["method"], false, true);
echo "</small>";
}
// line 207
echo "</div>
</div>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 210
echo " </div>
";
} | [
"public",
"function",
"block_methods",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 189",
"echo",
"\" <div class=\\\"container-fluid underlined\\\">\n \"",
";",
"// line 190",
"$",
"context",
"[",
"'_parent'",
... | line 188 | [
"line",
"188"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php#L563-L646 |
Edujugon/laradoo | docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php | __TwigTemplate_ea3e599f9a1fa64a525c9c39db3fa418c46acca48a9be27f93437ff01bba6e57.block_methods_details | public function block_methods_details($context, array $blocks = array())
{
// line 214
echo " <div id=\"method-details\">
";
// line 215
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 215, $this->getSourceContext()); })()));
$context['loop'] = array(
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
);
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
// line 216
echo " <div class=\"method-item\">
";
// line 217
$this->displayBlock("method", $context, $blocks);
echo "
</div>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 220
echo " </div>
";
} | php | public function block_methods_details($context, array $blocks = array())
{
// line 214
echo " <div id=\"method-details\">
";
// line 215
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 215, $this->getSourceContext()); })()));
$context['loop'] = array(
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
);
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
// line 216
echo " <div class=\"method-item\">
";
// line 217
$this->displayBlock("method", $context, $blocks);
echo "
</div>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 220
echo " </div>
";
} | [
"public",
"function",
"block_methods_details",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 214",
"echo",
"\" <div id=\\\"method-details\\\">\n \"",
";",
"// line 215",
"$",
"context",
"[",
"'_parent'",
"]",
... | line 213 | [
"line",
"213"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php#L649-L694 |
Edujugon/laradoo | docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php | __TwigTemplate_ea3e599f9a1fa64a525c9c39db3fa418c46acca48a9be27f93437ff01bba6e57.block_method | public function block_method($context, array $blocks = array())
{
// line 224
echo " <h3 id=\"method_";
echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 224, $this->getSourceContext()); })()), "name", array());
echo "\">
<div class=\"location\">";
// line 225
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()), "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 225, $this->getSourceContext()); })()))) {
echo "in ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()), false, true);
echo " ";
}
echo "at ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_source_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()));
echo "</div>
<code>";
// line 226
$this->displayBlock("method_signature", $context, $blocks);
echo "</code>
</h3>
<div class=\"details\">
";
// line 229
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_deprecations((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 229, $this->getSourceContext()); })()));
echo "
";
// line 231
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 231, $this->getSourceContext()); })()), "shortdesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 231, $this->getSourceContext()); })()), "longdesc", array()))) {
// line 232
echo " <div class=\"method-description\">
";
// line 233
if (( !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 233, $this->getSourceContext()); })()), "shortdesc", array()) && !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 233, $this->getSourceContext()); })()), "longdesc", array()))) {
// line 234
echo " <p class=\"no-description\">No description</p>
";
} else {
// line 236
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 236, $this->getSourceContext()); })()), "shortdesc", array())) {
// line 237
echo "<p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 237, $this->getSourceContext()); })()), "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 237, $this->getSourceContext()); })()));
echo "</p>";
}
// line 239
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 239, $this->getSourceContext()); })()), "longdesc", array())) {
// line 240
echo "<p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 240, $this->getSourceContext()); })()), "longdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 240, $this->getSourceContext()); })()));
echo "</p>";
}
}
// line 243
echo " ";
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 243, $this->getSourceContext()); })()), "config", array(0 => "insert_todos"), "method") == true)) {
// line 244
echo " ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_todos((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 244, $this->getSourceContext()); })()));
echo "
";
}
// line 246
echo " </div>
";
}
// line 248
echo " <div class=\"tags\">
";
// line 249
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 249, $this->getSourceContext()); })()), "parameters", array())) {
// line 250
echo " <h4>Parameters</h4>
";
// line 252
$this->displayBlock("parameters", $context, $blocks);
echo "
";
}
// line 254
echo "
";
// line 255
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 255, $this->getSourceContext()); })()), "hintDesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 255, $this->getSourceContext()); })()), "hint", array()))) {
// line 256
echo " <h4>Return Value</h4>
";
// line 258
$this->displayBlock("return", $context, $blocks);
echo "
";
}
// line 260
echo "
";
// line 261
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 261, $this->getSourceContext()); })()), "exceptions", array())) {
// line 262
echo " <h4>Exceptions</h4>
";
// line 264
$this->displayBlock("exceptions", $context, $blocks);
echo "
";
}
// line 266
echo "
";
// line 267
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 267, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method")) {
// line 268
echo " <h4>See also</h4>
";
// line 270
$this->displayBlock("see", $context, $blocks);
echo "
";
}
// line 272
echo " </div>
</div>
";
} | php | public function block_method($context, array $blocks = array())
{
// line 224
echo " <h3 id=\"method_";
echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 224, $this->getSourceContext()); })()), "name", array());
echo "\">
<div class=\"location\">";
// line 225
if ( !(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()), "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 225, $this->getSourceContext()); })()))) {
echo "in ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()), false, true);
echo " ";
}
echo "at ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_method_source_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 225, $this->getSourceContext()); })()));
echo "</div>
<code>";
// line 226
$this->displayBlock("method_signature", $context, $blocks);
echo "</code>
</h3>
<div class=\"details\">
";
// line 229
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_deprecations((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 229, $this->getSourceContext()); })()));
echo "
";
// line 231
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 231, $this->getSourceContext()); })()), "shortdesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 231, $this->getSourceContext()); })()), "longdesc", array()))) {
// line 232
echo " <div class=\"method-description\">
";
// line 233
if (( !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 233, $this->getSourceContext()); })()), "shortdesc", array()) && !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 233, $this->getSourceContext()); })()), "longdesc", array()))) {
// line 234
echo " <p class=\"no-description\">No description</p>
";
} else {
// line 236
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 236, $this->getSourceContext()); })()), "shortdesc", array())) {
// line 237
echo "<p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 237, $this->getSourceContext()); })()), "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 237, $this->getSourceContext()); })()));
echo "</p>";
}
// line 239
echo " ";
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 239, $this->getSourceContext()); })()), "longdesc", array())) {
// line 240
echo "<p>";
echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 240, $this->getSourceContext()); })()), "longdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 240, $this->getSourceContext()); })()));
echo "</p>";
}
}
// line 243
echo " ";
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 243, $this->getSourceContext()); })()), "config", array(0 => "insert_todos"), "method") == true)) {
// line 244
echo " ";
echo $context["__internal_bcc9cc3629ca6471acc508322f3ab0a7c21ca6dda07f27cbbbdd260817d542d5"]->macro_todos((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 244, $this->getSourceContext()); })()));
echo "
";
}
// line 246
echo " </div>
";
}
// line 248
echo " <div class=\"tags\">
";
// line 249
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 249, $this->getSourceContext()); })()), "parameters", array())) {
// line 250
echo " <h4>Parameters</h4>
";
// line 252
$this->displayBlock("parameters", $context, $blocks);
echo "
";
}
// line 254
echo "
";
// line 255
if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 255, $this->getSourceContext()); })()), "hintDesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 255, $this->getSourceContext()); })()), "hint", array()))) {
// line 256
echo " <h4>Return Value</h4>
";
// line 258
$this->displayBlock("return", $context, $blocks);
echo "
";
}
// line 260
echo "
";
// line 261
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 261, $this->getSourceContext()); })()), "exceptions", array())) {
// line 262
echo " <h4>Exceptions</h4>
";
// line 264
$this->displayBlock("exceptions", $context, $blocks);
echo "
";
}
// line 266
echo "
";
// line 267
if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 267, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method")) {
// line 268
echo " <h4>See also</h4>
";
// line 270
$this->displayBlock("see", $context, $blocks);
echo "
";
}
// line 272
echo " </div>
</div>
";
} | [
"public",
"function",
"block_method",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 224",
"echo",
"\" <h3 id=\\\"method_\"",
";",
"echo",
"twig_get_attribute",
"(",
"$",
"this",
"->",
"env",
",",
"$",
"this",... | line 223 | [
"line",
"223"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/1e/1e2f0a1618dd9fe62176bfe39961717f07184ba591d447729d1dff81d11ffb0c.php#L697-L826 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.server | public static function server($services = null, $options = null, $documentor = null)
{
self::load('Ripcord_Server');
if ( !isset($documentor) )
{
$doc = array('name', 'css', 'wsdl', 'wsdl2');
$docOptions = array();
foreach ( $doc as $key )
{
if ( isset($options[$key]) )
{
$docOptions[$key] = $options[$key];
unset( $options[$key] );
}
}
$docOptions['version'] = $options['version'];
$documentor = self::documentor( $docOptions );
}
return new Ripcord_Server($services, $options, $documentor);
} | php | public static function server($services = null, $options = null, $documentor = null)
{
self::load('Ripcord_Server');
if ( !isset($documentor) )
{
$doc = array('name', 'css', 'wsdl', 'wsdl2');
$docOptions = array();
foreach ( $doc as $key )
{
if ( isset($options[$key]) )
{
$docOptions[$key] = $options[$key];
unset( $options[$key] );
}
}
$docOptions['version'] = $options['version'];
$documentor = self::documentor( $docOptions );
}
return new Ripcord_Server($services, $options, $documentor);
} | [
"public",
"static",
"function",
"server",
"(",
"$",
"services",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"documentor",
"=",
"null",
")",
"{",
"self",
"::",
"load",
"(",
"'Ripcord_Server'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
... | This method returns a new Ripcord server, which by default implements XML-RPC, Simple RPC and SOAP 1.1.
The server will publish any methods passed through the $services argument. It can be configured through
the $options argument.
@param mixed $services Optional. Either an object or an array of objects. If the array has non-numeric keys, the key will be used as a namespace for the methods in the object.
@param array $options Optional. An array of options to set for the Ripcord server.
@see Ripcord_Server | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"server",
"which",
"by",
"default",
"implements",
"XML",
"-",
"RPC",
"Simple",
"RPC",
"and",
"SOAP",
"1",
".",
"1",
".",
"The",
"server",
"will",
"publish",
"any",
"methods",
"passed",
"through",
"the",
... | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L51-L70 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.client | public static function client($url, $options = null, $transport = null )
{
self::load('Ripcord_Client');
if ( !isset($transport) )
{
$transport = new Ripcord_Transport_Stream();
}
return new Ripcord_Client($url, $options, $transport);
} | php | public static function client($url, $options = null, $transport = null )
{
self::load('Ripcord_Client');
if ( !isset($transport) )
{
$transport = new Ripcord_Transport_Stream();
}
return new Ripcord_Client($url, $options, $transport);
} | [
"public",
"static",
"function",
"client",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"null",
",",
"$",
"transport",
"=",
"null",
")",
"{",
"self",
"::",
"load",
"(",
"'Ripcord_Client'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"transport",
")",
... | This method returns a new Ripcord client. By default this will be an XML-RPC client, but you can change this
through the $options argument.
@param string $url The url of the RPC server to connect with
@param array $options Optional. An array of options to set for the Ripcord client.
@see Ripcord_Client | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"client",
".",
"By",
"default",
"this",
"will",
"be",
"an",
"XML",
"-",
"RPC",
"client",
"but",
"you",
"can",
"change",
"this",
"through",
"the",
"$options",
"argument",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L79-L87 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.documentor | public static function documentor( $options = null, $docCommentParser = null )
{
self::load('Ripcord_Documentor');
if (!$docCommentParser) {
$docCommentParser = new Ripcord_Documentor_Parser_phpdoc();
}
return new Ripcord_Documentor( $options, $docCommentParser );
} | php | public static function documentor( $options = null, $docCommentParser = null )
{
self::load('Ripcord_Documentor');
if (!$docCommentParser) {
$docCommentParser = new Ripcord_Documentor_Parser_phpdoc();
}
return new Ripcord_Documentor( $options, $docCommentParser );
} | [
"public",
"static",
"function",
"documentor",
"(",
"$",
"options",
"=",
"null",
",",
"$",
"docCommentParser",
"=",
"null",
")",
"{",
"self",
"::",
"load",
"(",
"'Ripcord_Documentor'",
")",
";",
"if",
"(",
"!",
"$",
"docCommentParser",
")",
"{",
"$",
"doc... | This method returns a new Ripcord documentor object.
@param array $options Optional. An array of options to set for the Ripcord documentor.
@param object docCommentParser Optional. An object that parses a docComment block. Must
implement the Ripcord_Documentor_CommentParser interface.
@see Ripcord_Client | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"documentor",
"object",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L96-L103 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.soapClient | public static function soapClient($url, $options = null, $transport = null)
{
$options['version'] = 'soap 1.1';
return self::client($url, $options, $transport);
} | php | public static function soapClient($url, $options = null, $transport = null)
{
$options['version'] = 'soap 1.1';
return self::client($url, $options, $transport);
} | [
"public",
"static",
"function",
"soapClient",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"null",
",",
"$",
"transport",
"=",
"null",
")",
"{",
"$",
"options",
"[",
"'version'",
"]",
"=",
"'soap 1.1'",
";",
"return",
"self",
"::",
"client",
"(",
"$",
... | This method returns a new Ripcord client, configured to access a SOAP 1.1 server.
@param string $url
@param array $options Optional.
@see Ripcord_Client | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"client",
"configured",
"to",
"access",
"a",
"SOAP",
"1",
".",
"1",
"server",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L179-L183 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.xmlrpcClient | public static function xmlrpcClient($url, $options = null, $transport = null)
{
$options['version'] = 'xmlrpc';
return self::client($url, $options, $transport);
} | php | public static function xmlrpcClient($url, $options = null, $transport = null)
{
$options['version'] = 'xmlrpc';
return self::client($url, $options, $transport);
} | [
"public",
"static",
"function",
"xmlrpcClient",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"null",
",",
"$",
"transport",
"=",
"null",
")",
"{",
"$",
"options",
"[",
"'version'",
"]",
"=",
"'xmlrpc'",
";",
"return",
"self",
"::",
"client",
"(",
"$",
... | This method returns a new Ripcord client, configured to access an XML-RPC server.
@param string $url
@param array $options Optional.
@return object
@see Ripcord_Client | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"client",
"configured",
"to",
"access",
"an",
"XML",
"-",
"RPC",
"server",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L192-L196 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.simpleClient | public static function simpleClient($url, $options = null, $transport = null)
{
$options['version'] = 'simple';
return self::client($url, $options, $transport);
} | php | public static function simpleClient($url, $options = null, $transport = null)
{
$options['version'] = 'simple';
return self::client($url, $options, $transport);
} | [
"public",
"static",
"function",
"simpleClient",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"null",
",",
"$",
"transport",
"=",
"null",
")",
"{",
"$",
"options",
"[",
"'version'",
"]",
"=",
"'simple'",
";",
"return",
"self",
"::",
"client",
"(",
"$",
... | This method returns a new Ripcord client, configured to access a Simple RPC server.
@param string $url
@param array $options Optional.
@return object
@see Ripcord_Client | [
"This",
"method",
"returns",
"a",
"new",
"Ripcord",
"client",
"configured",
"to",
"access",
"a",
"Simple",
"RPC",
"server",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L205-L209 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.load | public static function load($class)
{
if (substr($class, 0, 8)=='Ripcord_')
{
$root = dirname(__FILE__).'/ripcord_';
$class = substr($class, 8);
$file = str_replace('.', '', $class);
$file = str_replace('_', '/', $file);
$file = strtolower($file);
while ($file && $file!='.')
{
if ( file_exists($root.$file.'.php') )
{
require_once($root.$file.'.php');
return true;
} else {
$file = dirname($file);
}
}
}
return false;
} | php | public static function load($class)
{
if (substr($class, 0, 8)=='Ripcord_')
{
$root = dirname(__FILE__).'/ripcord_';
$class = substr($class, 8);
$file = str_replace('.', '', $class);
$file = str_replace('_', '/', $file);
$file = strtolower($file);
while ($file && $file!='.')
{
if ( file_exists($root.$file.'.php') )
{
require_once($root.$file.'.php');
return true;
} else {
$file = dirname($file);
}
}
}
return false;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"8",
")",
"==",
"'Ripcord_'",
")",
"{",
"$",
"root",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"'/ripcord_'",
";",
"$",
"... | This method includes a ripcord class, using require_once. Used for autoloading ripcord classes.
@param string $class The name of the class to load.
@return boolean | [
"This",
"method",
"includes",
"a",
"ripcord",
"class",
"using",
"require_once",
".",
"Used",
"for",
"autoloading",
"ripcord",
"classes",
"."
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L216-L237 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.encodeCall | public static function encodeCall()
{
self::load('Ripcord_Client');
$params = func_get_args();
$method = array_shift($params);
return new Ripcord_Client_Call( $method, $params );
} | php | public static function encodeCall()
{
self::load('Ripcord_Client');
$params = func_get_args();
$method = array_shift($params);
return new Ripcord_Client_Call( $method, $params );
} | [
"public",
"static",
"function",
"encodeCall",
"(",
")",
"{",
"self",
"::",
"load",
"(",
"'Ripcord_Client'",
")",
";",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"$",
"method",
"=",
"array_shift",
"(",
"$",
"params",
")",
";",
"return",
"new",
... | This method creates a new Ripcord_Client_Call object, which encodes the information needed for
a method call to an rpc server. This is mostly used for the system.multiCall method.
@param string $method The name of the method call to encode
@param mixed $args,... The remainder of the arguments are encoded as parameters to the call
@return object | [
"This",
"method",
"creates",
"a",
"new",
"Ripcord_Client_Call",
"object",
"which",
"encodes",
"the",
"information",
"needed",
"for",
"a",
"method",
"call",
"to",
"an",
"rpc",
"server",
".",
"This",
"is",
"mostly",
"used",
"for",
"the",
"system",
".",
"multiC... | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L246-L252 |
Edujugon/laradoo | src/ripcord/ripcord.php | ripcord.bind | public function bind(&$bound, $call)
{
if ( is_a( $call, 'Ripcord_Client_Call' ) )
{
$call->bound =& $bound;
} else {
$bound = $call;
}
return null;
} | php | public function bind(&$bound, $call)
{
if ( is_a( $call, 'Ripcord_Client_Call' ) )
{
$call->bound =& $bound;
} else {
$bound = $call;
}
return null;
} | [
"public",
"function",
"bind",
"(",
"&",
"$",
"bound",
",",
"$",
"call",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"call",
",",
"'Ripcord_Client_Call'",
")",
")",
"{",
"$",
"call",
"->",
"bound",
"=",
"&",
"$",
"bound",
";",
"}",
"else",
"{",
"$",
... | /*
This method binds the first parameter to the output of a Ripcord client call. If
the second argument is a Ripcord_Client_Call object, it binds the parameter to it,
if not it simply assigns the second parameter to the first parameter.
This means that doing:
> ripcord::bind( $result, $client->someMethod() )
will always result in $result eventually containing the return value of $client->someMethod().
Whether multiCall mode has been enabled or not. | [
"/",
"*",
"This",
"method",
"binds",
"the",
"first",
"parameter",
"to",
"the",
"output",
"of",
"a",
"Ripcord",
"client",
"call",
".",
"If",
"the",
"second",
"argument",
"is",
"a",
"Ripcord_Client_Call",
"object",
"it",
"binds",
"the",
"parameter",
"to",
"i... | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/src/ripcord/ripcord.php#L263-L272 |
Edujugon/laradoo | docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php | __TwigTemplate_6362edb63f13213514ccc7737015de2bd20f01ab25e45c876fdf093470629a2b.block_title | public function block_title($context, array $blocks = array())
{
echo (isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 3, $this->getSourceContext()); })());
echo " | ";
$this->displayParentBlock("title", $context, $blocks);
} | php | public function block_title($context, array $blocks = array())
{
echo (isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 3, $this->getSourceContext()); })());
echo " | ";
$this->displayParentBlock("title", $context, $blocks);
} | [
"public",
"function",
"block_title",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"echo",
"(",
"isset",
"(",
"$",
"context",
"[",
"\"namespace\"",
"]",
")",
"||",
"array_key_exists",
"(",
"\"namespace\"",
",",
"$",
... | line 3 | [
"line",
"3"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php#L35-L40 |
Edujugon/laradoo | docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php | __TwigTemplate_6362edb63f13213514ccc7737015de2bd20f01ab25e45c876fdf093470629a2b.block_page_id | public function block_page_id($context, array $blocks = array())
{
echo twig_escape_filter($this->env, ("namespace:" . twig_replace_filter((isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 5, $this->getSourceContext()); })()), array("\\" => "_"))), "html", null, true);
} | php | public function block_page_id($context, array $blocks = array())
{
echo twig_escape_filter($this->env, ("namespace:" . twig_replace_filter((isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 5, $this->getSourceContext()); })()), array("\\" => "_"))), "html", null, true);
} | [
"public",
"function",
"block_page_id",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"echo",
"twig_escape_filter",
"(",
"$",
"this",
"->",
"env",
",",
"(",
"\"namespace:\"",
".",
"twig_replace_filter",
"(",
"(",
"isset... | line 5 | [
"line",
"5"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php#L49-L52 |
Edujugon/laradoo | docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php | __TwigTemplate_6362edb63f13213514ccc7737015de2bd20f01ab25e45c876fdf093470629a2b.block_below_menu | public function block_below_menu($context, array $blocks = array())
{
// line 8
echo " <div class=\"namespace-breadcrumbs\">
<ol class=\"breadcrumb\">
<li><span class=\"label label-default\">Namespace</span></li>
";
// line 11
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_breadcrumbs((isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 11, $this->getSourceContext()); })()));
echo "
</ol>
</div>
";
} | php | public function block_below_menu($context, array $blocks = array())
{
// line 8
echo " <div class=\"namespace-breadcrumbs\">
<ol class=\"breadcrumb\">
<li><span class=\"label label-default\">Namespace</span></li>
";
// line 11
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_breadcrumbs((isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 11, $this->getSourceContext()); })()));
echo "
</ol>
</div>
";
} | [
"public",
"function",
"block_below_menu",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 8",
"echo",
"\" <div class=\\\"namespace-breadcrumbs\\\">\n <ol class=\\\"breadcrumb\\\">\n <li><span class=\\\"label label-... | line 7 | [
"line",
"7"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php#L55-L68 |
Edujugon/laradoo | docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php | __TwigTemplate_6362edb63f13213514ccc7737015de2bd20f01ab25e45c876fdf093470629a2b.block_page_content | public function block_page_content($context, array $blocks = array())
{
// line 17
echo "
<div class=\"page-header\">
<h1>";
// line 19
echo (isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 19, $this->getSourceContext()); })());
echo "</h1>
</div>
";
// line 22
if ((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 22, $this->getSourceContext()); })())) {
// line 23
echo " <h2>Namespaces</h2>
<div class=\"namespace-list\">
";
// line 25
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 25, $this->getSourceContext()); })()));
foreach ($context['_seq'] as $context["_key"] => $context["ns"]) {
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_namespace_link($context["ns"]);
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['ns'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 26
echo " </div>
";
}
// line 28
echo "
";
// line 29
if ((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 29, $this->getSourceContext()); })())) {
// line 30
echo " <h2>Classes</h2>
";
// line 31
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 31, $this->getSourceContext()); })()));
echo "
";
}
// line 33
echo "
";
// line 34
if ((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 34, $this->getSourceContext()); })())) {
// line 35
echo " <h2>Interfaces</h2>
";
// line 36
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 36, $this->getSourceContext()); })()));
echo "
";
}
// line 38
echo "
";
// line 39
if ((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 39, $this->getSourceContext()); })())) {
// line 40
echo " <h2>Exceptions</h2>
";
// line 41
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 41, $this->getSourceContext()); })()));
echo "
";
}
// line 43
echo "
";
} | php | public function block_page_content($context, array $blocks = array())
{
// line 17
echo "
<div class=\"page-header\">
<h1>";
// line 19
echo (isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 19, $this->getSourceContext()); })());
echo "</h1>
</div>
";
// line 22
if ((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 22, $this->getSourceContext()); })())) {
// line 23
echo " <h2>Namespaces</h2>
<div class=\"namespace-list\">
";
// line 25
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 25, $this->getSourceContext()); })()));
foreach ($context['_seq'] as $context["_key"] => $context["ns"]) {
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_namespace_link($context["ns"]);
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['ns'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 26
echo " </div>
";
}
// line 28
echo "
";
// line 29
if ((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 29, $this->getSourceContext()); })())) {
// line 30
echo " <h2>Classes</h2>
";
// line 31
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 31, $this->getSourceContext()); })()));
echo "
";
}
// line 33
echo "
";
// line 34
if ((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 34, $this->getSourceContext()); })())) {
// line 35
echo " <h2>Interfaces</h2>
";
// line 36
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 36, $this->getSourceContext()); })()));
echo "
";
}
// line 38
echo "
";
// line 39
if ((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 39, $this->getSourceContext()); })())) {
// line 40
echo " <h2>Exceptions</h2>
";
// line 41
echo $context["__internal_5b548bb90f3f36c5ad35e483a3f65b73c0886025646510ead090e478a5a5016a"]->macro_render_classes((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 41, $this->getSourceContext()); })()));
echo "
";
}
// line 43
echo "
";
} | [
"public",
"function",
"block_page_content",
"(",
"$",
"context",
",",
"array",
"$",
"blocks",
"=",
"array",
"(",
")",
")",
"{",
"// line 17",
"echo",
"\"\n <div class=\\\"page-header\\\">\n <h1>\"",
";",
"// line 19",
"echo",
"(",
"isset",
"(",
"$",
"con... | line 16 | [
"line",
"16"
] | train | https://github.com/Edujugon/laradoo/blob/e198e1303cc1339507f65db418f0b602f76c64e2/docs/cache/1.1.1/twig/be/be720166b1c57e0fefdc722a2ede454cea21bb6c50b76f2998bdda0a02903be4.php#L71-L144 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.getFilteredNamedPolicy | public function getFilteredNamedPolicy($ptype, $fieldIndex, ...$fieldValues)
{
return $this->model->getFilteredPolicy('p', $ptype, $fieldIndex, ...$fieldValues);
} | php | public function getFilteredNamedPolicy($ptype, $fieldIndex, ...$fieldValues)
{
return $this->model->getFilteredPolicy('p', $ptype, $fieldIndex, ...$fieldValues);
} | [
"public",
"function",
"getFilteredNamedPolicy",
"(",
"$",
"ptype",
",",
"$",
"fieldIndex",
",",
"...",
"$",
"fieldValues",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"getFilteredPolicy",
"(",
"'p'",
",",
"$",
"ptype",
",",
"$",
"fieldIndex",
","... | gets all the authorization rules in the named policy, field filters can be specified.
@param $ptype
@param $fieldIndex
@param mixed ...$fieldValues
@return array | [
"gets",
"all",
"the",
"authorization",
"rules",
"in",
"the",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L144-L147 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.getFilteredNamedGroupingPolicy | public function getFilteredNamedGroupingPolicy($ptype, $fieldIndex, ...$fieldValues)
{
return $this->model->getFilteredPolicy('g', $ptype, $fieldIndex, ...$fieldValues);
} | php | public function getFilteredNamedGroupingPolicy($ptype, $fieldIndex, ...$fieldValues)
{
return $this->model->getFilteredPolicy('g', $ptype, $fieldIndex, ...$fieldValues);
} | [
"public",
"function",
"getFilteredNamedGroupingPolicy",
"(",
"$",
"ptype",
",",
"$",
"fieldIndex",
",",
"...",
"$",
"fieldValues",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"getFilteredPolicy",
"(",
"'g'",
",",
"$",
"ptype",
",",
"$",
"fieldIndex... | gets all the role inheritance rules in the policy, field filters can be specified.
@param $ptype
@param $fieldIndex
@param mixed ...$fieldValues
@return array | [
"gets",
"all",
"the",
"role",
"inheritance",
"rules",
"in",
"the",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L193-L196 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.addNamedPolicy | public function addNamedPolicy($ptype, ...$params)
{
$ruleAdded = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->addPolicyInternal('p', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleAdded = $this->addPolicyInternal('p', $ptype, $policy);
}
return $ruleAdded;
} | php | public function addNamedPolicy($ptype, ...$params)
{
$ruleAdded = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->addPolicyInternal('p', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleAdded = $this->addPolicyInternal('p', $ptype, $policy);
}
return $ruleAdded;
} | [
"public",
"function",
"addNamedPolicy",
"(",
"$",
"ptype",
",",
"...",
"$",
"params",
")",
"{",
"$",
"ruleAdded",
"=",
"false",
";",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"0",
"]",
")",
... | AddNamedPolicy adds an authorization rule to the current named policy.
If the rule already exists, the function returns false and the rule will not be added.
Otherwise the function returns true by adding the new rule.
@param $ptype
@param mixed ...$params
@return bool | [
"AddNamedPolicy",
"adds",
"an",
"authorization",
"rule",
"to",
"the",
"current",
"named",
"policy",
".",
"If",
"the",
"rule",
"already",
"exists",
"the",
"function",
"returns",
"false",
"and",
"the",
"rule",
"will",
"not",
"be",
"added",
".",
"Otherwise",
"t... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L258-L274 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.removeNamedPolicy | public function removeNamedPolicy($ptype, ...$params)
{
$ruleRemoved = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->removePolicyInternal('p', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleRemoved = $this->removePolicyInternal('p', $ptype, $policy);
}
return $ruleRemoved;
} | php | public function removeNamedPolicy($ptype, ...$params)
{
$ruleRemoved = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->removePolicyInternal('p', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleRemoved = $this->removePolicyInternal('p', $ptype, $policy);
}
return $ruleRemoved;
} | [
"public",
"function",
"removeNamedPolicy",
"(",
"$",
"ptype",
",",
"...",
"$",
"params",
")",
"{",
"$",
"ruleRemoved",
"=",
"false",
";",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"0",
"]",
"... | removes an authorization rule from the current named policy.
@param $ptype
@param mixed ...$params
@return bool | [
"removes",
"an",
"authorization",
"rule",
"from",
"the",
"current",
"named",
"policy",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L309-L325 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.hasNamedGroupingPolicy | public function hasNamedGroupingPolicy($ptype, ...$params)
{
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
return $this->model->hasPolicy('g', $ptype, $strSlice);
}
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
return $this->model->hasPolicy('g', $ptype, $policy);
} | php | public function hasNamedGroupingPolicy($ptype, ...$params)
{
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
return $this->model->hasPolicy('g', $ptype, $strSlice);
}
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
return $this->model->hasPolicy('g', $ptype, $policy);
} | [
"public",
"function",
"hasNamedGroupingPolicy",
"(",
"$",
"ptype",
",",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"$",
"strSlice",
"="... | determines whether a named role inheritance rule exists.
@param $ptype
@param mixed ...$params
@return bool | [
"determines",
"whether",
"a",
"named",
"role",
"inheritance",
"rule",
"exists",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L361-L375 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.addNamedGroupingPolicy | public function addNamedGroupingPolicy($ptype, ...$params)
{
$ruleAdded = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->addPolicyInternal('g', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleAdded = $this->addPolicyInternal('g', $ptype, $policy);
}
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleAdded;
} | php | public function addNamedGroupingPolicy($ptype, ...$params)
{
$ruleAdded = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleAdded = $this->addPolicyInternal('g', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleAdded = $this->addPolicyInternal('g', $ptype, $policy);
}
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleAdded;
} | [
"public",
"function",
"addNamedGroupingPolicy",
"(",
"$",
"ptype",
",",
"...",
"$",
"params",
")",
"{",
"$",
"ruleAdded",
"=",
"false",
";",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"0",
"]",
... | AddNamedGroupingPolicy adds a named role inheritance rule to the current policy.
If the rule already exists, the function returns false and the rule will not be added.
Otherwise the function returns true by adding the new rule.
@param $ptype
@param mixed ...$params
@return bool | [
"AddNamedGroupingPolicy",
"adds",
"a",
"named",
"role",
"inheritance",
"rule",
"to",
"the",
"current",
"policy",
".",
"If",
"the",
"rule",
"already",
"exists",
"the",
"function",
"returns",
"false",
"and",
"the",
"rule",
"will",
"not",
"be",
"added",
".",
"O... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L401-L421 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.removeNamedGroupingPolicy | public function removeNamedGroupingPolicy($ptype, ...$params)
{
$ruleRemoved = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleRemoved = $this->removePolicyInternal('g', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleRemoved = $this->removePolicyInternal('g', $ptype, $policy);
}
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleRemoved;
} | php | public function removeNamedGroupingPolicy($ptype, ...$params)
{
$ruleRemoved = false;
if (1 == count($params) && is_array($params[0])) {
$strSlice = $params[0];
$ruleRemoved = $this->removePolicyInternal('g', $ptype, $strSlice);
} else {
$policy = [];
foreach ($params as $param) {
$policy[] = $param;
}
$ruleRemoved = $this->removePolicyInternal('g', $ptype, $policy);
}
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleRemoved;
} | [
"public",
"function",
"removeNamedGroupingPolicy",
"(",
"$",
"ptype",
",",
"...",
"$",
"params",
")",
"{",
"$",
"ruleRemoved",
"=",
"false",
";",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"0",
... | removes a role inheritance rule from the current named policy.
@param $ptype
@param mixed ...$params
@return bool | [
"removes",
"a",
"role",
"inheritance",
"rule",
"from",
"the",
"current",
"named",
"policy",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L456-L476 |
php-casbin/php-casbin | src/ManagementApi.php | ManagementApi.removeFilteredNamedGroupingPolicy | public function removeFilteredNamedGroupingPolicy($ptype, $fieldIndex, ...$fieldValues)
{
$ruleRemoved = $this->removeFilteredPolicyInternal('g', $ptype, $fieldIndex, ...$fieldValues);
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleRemoved;
} | php | public function removeFilteredNamedGroupingPolicy($ptype, $fieldIndex, ...$fieldValues)
{
$ruleRemoved = $this->removeFilteredPolicyInternal('g', $ptype, $fieldIndex, ...$fieldValues);
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
return $ruleRemoved;
} | [
"public",
"function",
"removeFilteredNamedGroupingPolicy",
"(",
"$",
"ptype",
",",
"$",
"fieldIndex",
",",
"...",
"$",
"fieldValues",
")",
"{",
"$",
"ruleRemoved",
"=",
"$",
"this",
"->",
"removeFilteredPolicyInternal",
"(",
"'g'",
",",
"$",
"ptype",
",",
"$",... | removes a role inheritance rule from the current named policy, field filters can be specified.
@param string $ptype
@param int $fieldIndex
@param mixed ...$fieldValues
@return bool | [
"removes",
"a",
"role",
"inheritance",
"rule",
"from",
"the",
"current",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/ManagementApi.php#L487-L496 |
php-casbin/php-casbin | src/Config/Config.php | Config.addConfig | public function addConfig($section, $option, $value)
{
if (empty($section)) {
$section = self::DEFAULT_SECTION;
}
if (!isset($this->data[$section])) {
$this->data[$section] = [];
}
$this->data[$section][$option] = $value;
return true;
} | php | public function addConfig($section, $option, $value)
{
if (empty($section)) {
$section = self::DEFAULT_SECTION;
}
if (!isset($this->data[$section])) {
$this->data[$section] = [];
}
$this->data[$section][$option] = $value;
return true;
} | [
"public",
"function",
"addConfig",
"(",
"$",
"section",
",",
"$",
"option",
",",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"section",
")",
")",
"{",
"$",
"section",
"=",
"self",
"::",
"DEFAULT_SECTION",
";",
"}",
"if",
"(",
"!",
"isset"... | adds a new section->key:value to the configuration.
@param string $section
@param string $option
@param string $value
@return bool | [
"adds",
"a",
"new",
"section",
"-",
">",
"key",
":",
"value",
"to",
"the",
"configuration",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L63-L76 |
php-casbin/php-casbin | src/Config/Config.php | Config.parse | private function parse($fname)
{
$buf = file_get_contents($fname);
$res = $this->parseBuffer($buf);
return $res;
} | php | private function parse($fname)
{
$buf = file_get_contents($fname);
$res = $this->parseBuffer($buf);
return $res;
} | [
"private",
"function",
"parse",
"(",
"$",
"fname",
")",
"{",
"$",
"buf",
"=",
"file_get_contents",
"(",
"$",
"fname",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"parseBuffer",
"(",
"$",
"buf",
")",
";",
"return",
"$",
"res",
";",
"}"
] | @param string $fname
@return bool
@throws CasbinException | [
"@param",
"string",
"$fname"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L85-L92 |
php-casbin/php-casbin | src/Config/Config.php | Config.parseBuffer | private function parseBuffer($buf)
{
$section = null;
$lineNum = 0;
$buffer = '';
$canWrite = null;
$buf = preg_replace('/[\r\n]+/', PHP_EOL, $buf);
$buf = explode(PHP_EOL, $buf);
for ($i = 0; $i <= \count($buf); ++$i) {
if ($canWrite) {
$this->write($section, $lineNum, $buffer);
$canWrite = false;
}
++$lineNum;
$line = isset($buf[$i]) ? $buf[$i] : '';
if ($i == \count($buf)) {
if (\strlen($buffer) > 0) {
$this->write($section, $lineNum, $buffer);
}
break;
}
$line = trim($line);
if ('' == $line || self::DEFAULT_COMMENT == substr($line, 0, 1) || self::DEFAULT_COMMENT_SEM == substr($line, 0, 1)) {
$canWrite = true;
continue;
} elseif ('[' == substr($line, 0, 1) && ']' == substr($line, -1)) {
if (\strlen($buffer) > 0) {
$this->write($section, $lineNum, $buffer);
$canWrite = false;
}
$section = substr($line, 1, -1);
} else {
$p = '';
if (self::DEFAULT_MULTI_LINE_SEPARATOR == substr($line, -1)) {
$p = trim(substr($line, 0, -1));
} else {
$p = $line;
$canWrite = true;
}
$buffer .= $p;
}
}
return true;
} | php | private function parseBuffer($buf)
{
$section = null;
$lineNum = 0;
$buffer = '';
$canWrite = null;
$buf = preg_replace('/[\r\n]+/', PHP_EOL, $buf);
$buf = explode(PHP_EOL, $buf);
for ($i = 0; $i <= \count($buf); ++$i) {
if ($canWrite) {
$this->write($section, $lineNum, $buffer);
$canWrite = false;
}
++$lineNum;
$line = isset($buf[$i]) ? $buf[$i] : '';
if ($i == \count($buf)) {
if (\strlen($buffer) > 0) {
$this->write($section, $lineNum, $buffer);
}
break;
}
$line = trim($line);
if ('' == $line || self::DEFAULT_COMMENT == substr($line, 0, 1) || self::DEFAULT_COMMENT_SEM == substr($line, 0, 1)) {
$canWrite = true;
continue;
} elseif ('[' == substr($line, 0, 1) && ']' == substr($line, -1)) {
if (\strlen($buffer) > 0) {
$this->write($section, $lineNum, $buffer);
$canWrite = false;
}
$section = substr($line, 1, -1);
} else {
$p = '';
if (self::DEFAULT_MULTI_LINE_SEPARATOR == substr($line, -1)) {
$p = trim(substr($line, 0, -1));
} else {
$p = $line;
$canWrite = true;
}
$buffer .= $p;
}
}
return true;
} | [
"private",
"function",
"parseBuffer",
"(",
"$",
"buf",
")",
"{",
"$",
"section",
"=",
"null",
";",
"$",
"lineNum",
"=",
"0",
";",
"$",
"buffer",
"=",
"''",
";",
"$",
"canWrite",
"=",
"null",
";",
"$",
"buf",
"=",
"preg_replace",
"(",
"'/[\\r\\n]+/'",... | @param string $buf
@return bool
@throws CasbinException | [
"@param",
"string",
"$buf"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L101-L151 |
php-casbin/php-casbin | src/Config/Config.php | Config.write | private function write($section, $lineNum, &$b)
{
if (\strlen($b) <= 0) {
return;
}
$optionVal = explode('=', $b, 2);
if (2 != \count($optionVal)) {
throw new CasbinException(sprintf('parse the content error : line %d , %s = ?', $lineNum, current($optionVal)));
}
$option = trim($optionVal[0]);
$value = trim($optionVal[1]);
$this->addConfig($section, $option, $value);
$b = '';
} | php | private function write($section, $lineNum, &$b)
{
if (\strlen($b) <= 0) {
return;
}
$optionVal = explode('=', $b, 2);
if (2 != \count($optionVal)) {
throw new CasbinException(sprintf('parse the content error : line %d , %s = ?', $lineNum, current($optionVal)));
}
$option = trim($optionVal[0]);
$value = trim($optionVal[1]);
$this->addConfig($section, $option, $value);
$b = '';
} | [
"private",
"function",
"write",
"(",
"$",
"section",
",",
"$",
"lineNum",
",",
"&",
"$",
"b",
")",
"{",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"b",
")",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"$",
"optionVal",
"=",
"explode",
"(",
"'='",
",",
... | @param string $section
@param int $lineNum
@param $b
@throws CasbinException | [
"@param",
"string",
"$section",
"@param",
"int",
"$lineNum",
"@param",
"$b"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L160-L177 |
php-casbin/php-casbin | src/Config/Config.php | Config.set | public function set($key, $value)
{
if (0 == \strlen($key)) {
throw new CasbinException('key is empty');
}
$section = '';
$keys = explode('::', strtolower($key));
if (\count($keys) >= 2) {
$section = $keys[0];
$option = $keys[1];
} else {
$option = $keys[0];
}
$this->addConfig($section, $option, $value);
} | php | public function set($key, $value)
{
if (0 == \strlen($key)) {
throw new CasbinException('key is empty');
}
$section = '';
$keys = explode('::', strtolower($key));
if (\count($keys) >= 2) {
$section = $keys[0];
$option = $keys[1];
} else {
$option = $keys[0];
}
$this->addConfig($section, $option, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"0",
"==",
"\\",
"strlen",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"CasbinException",
"(",
"'key is empty'",
")",
";",
"}",
"$",
"section",
"=",
"''",
"... | sets the value for the specific key in the Config.
@param string $key
@param string $value
@throws CasbinException | [
"sets",
"the",
"value",
"for",
"the",
"specific",
"key",
"in",
"the",
"Config",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L217-L233 |
php-casbin/php-casbin | src/Config/Config.php | Config.get | public function get($key)
{
$keys = explode('::', $key);
if (\count($keys) >= 2) {
$section = $keys[0];
$option = $keys[1];
} else {
$section = self::DEFAULT_SECTION;
$option = $keys[0];
}
return isset($this->data[$section][$option]) ? $this->data[$section][$option] : '';
} | php | public function get($key)
{
$keys = explode('::', $key);
if (\count($keys) >= 2) {
$section = $keys[0];
$option = $keys[1];
} else {
$section = self::DEFAULT_SECTION;
$option = $keys[0];
}
return isset($this->data[$section][$option]) ? $this->data[$section][$option] : '';
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'::'",
",",
"$",
"key",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"keys",
")",
">=",
"2",
")",
"{",
"$",
"section",
"=",
"$",
"keys",
"[",
"0",
"... | section.key or key.
@param string $key
@return string | [
"section",
".",
"key",
"or",
"key",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Config/Config.php#L242-L254 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.initWithFile | public function initWithFile($modelPath, $policyPath)
{
$adapter = new FileAdapter($policyPath);
$this->initWithAdapter($modelPath, $adapter);
} | php | public function initWithFile($modelPath, $policyPath)
{
$adapter = new FileAdapter($policyPath);
$this->initWithAdapter($modelPath, $adapter);
} | [
"public",
"function",
"initWithFile",
"(",
"$",
"modelPath",
",",
"$",
"policyPath",
")",
"{",
"$",
"adapter",
"=",
"new",
"FileAdapter",
"(",
"$",
"policyPath",
")",
";",
"$",
"this",
"->",
"initWithAdapter",
"(",
"$",
"modelPath",
",",
"$",
"adapter",
... | initializes an enforcer with a model file and a policy file.
@param $modelPath
@param $policyPath
@throws CasbinException | [
"initializes",
"an",
"enforcer",
"with",
"a",
"model",
"file",
"and",
"a",
"policy",
"file",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L169-L173 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.initWithAdapter | public function initWithAdapter($modelPath, Adapter $adapter)
{
$m = self::newModel($modelPath, '');
$this->initWithModelAndAdapter($m, $adapter);
$this->modelPath = $modelPath;
} | php | public function initWithAdapter($modelPath, Adapter $adapter)
{
$m = self::newModel($modelPath, '');
$this->initWithModelAndAdapter($m, $adapter);
$this->modelPath = $modelPath;
} | [
"public",
"function",
"initWithAdapter",
"(",
"$",
"modelPath",
",",
"Adapter",
"$",
"adapter",
")",
"{",
"$",
"m",
"=",
"self",
"::",
"newModel",
"(",
"$",
"modelPath",
",",
"''",
")",
";",
"$",
"this",
"->",
"initWithModelAndAdapter",
"(",
"$",
"m",
... | initializes an enforcer with a database adapter.
@param $modelPath
@param Adapter $adapter
@throws CasbinException | [
"initializes",
"an",
"enforcer",
"with",
"a",
"database",
"adapter",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L183-L189 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.initWithModelAndAdapter | public function initWithModelAndAdapter(Model $m, $adapter)
{
$this->adapter = $adapter;
$this->model = $m;
$this->model->printModel();
$this->fm = Model::loadFunctionMap();
$this->initialize();
if (null !== $this->adapter) {
try {
$this->loadPolicy();
} catch (\Exception $e) {
// error intentionally ignored
}
}
} | php | public function initWithModelAndAdapter(Model $m, $adapter)
{
$this->adapter = $adapter;
$this->model = $m;
$this->model->printModel();
$this->fm = Model::loadFunctionMap();
$this->initialize();
if (null !== $this->adapter) {
try {
$this->loadPolicy();
} catch (\Exception $e) {
// error intentionally ignored
}
}
} | [
"public",
"function",
"initWithModelAndAdapter",
"(",
"Model",
"$",
"m",
",",
"$",
"adapter",
")",
"{",
"$",
"this",
"->",
"adapter",
"=",
"$",
"adapter",
";",
"$",
"this",
"->",
"model",
"=",
"$",
"m",
";",
"$",
"this",
"->",
"model",
"->",
"printMo... | initWithModelAndAdapter initializes an enforcer with a model and a database adapter.
@param Model $m
@param Adapter|null $adapter | [
"initWithModelAndAdapter",
"initializes",
"an",
"enforcer",
"with",
"a",
"model",
"and",
"a",
"database",
"adapter",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L197-L215 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.initialize | protected function initialize()
{
$this->rm = new DefaultRoleManager(10);
$this->eft = new DefaultEffector();
$this->watcher = null;
$this->enabled = true;
$this->autoSave = true;
$this->autoBuildRoleLinks = true;
} | php | protected function initialize()
{
$this->rm = new DefaultRoleManager(10);
$this->eft = new DefaultEffector();
$this->watcher = null;
$this->enabled = true;
$this->autoSave = true;
$this->autoBuildRoleLinks = true;
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"$",
"this",
"->",
"rm",
"=",
"new",
"DefaultRoleManager",
"(",
"10",
")",
";",
"$",
"this",
"->",
"eft",
"=",
"new",
"DefaultEffector",
"(",
")",
";",
"$",
"this",
"->",
"watcher",
"=",
"null",
"... | initializes an enforcer with a database adapter. | [
"initializes",
"an",
"enforcer",
"with",
"a",
"database",
"adapter",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L220-L229 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.newModel | public static function newModel(...$text)
{
$model = new Model();
if (2 == \count($text)) {
if ('' != $text[0]) {
$model->loadModel($text[0]);
}
} elseif (1 == \count($text)) {
$model->loadModelFromText($text[0]);
} elseif (0 != \count($text)) {
throw new CasbinException('Invalid parameters for model.');
}
return $model;
} | php | public static function newModel(...$text)
{
$model = new Model();
if (2 == \count($text)) {
if ('' != $text[0]) {
$model->loadModel($text[0]);
}
} elseif (1 == \count($text)) {
$model->loadModelFromText($text[0]);
} elseif (0 != \count($text)) {
throw new CasbinException('Invalid parameters for model.');
}
return $model;
} | [
"public",
"static",
"function",
"newModel",
"(",
"...",
"$",
"text",
")",
"{",
"$",
"model",
"=",
"new",
"Model",
"(",
")",
";",
"if",
"(",
"2",
"==",
"\\",
"count",
"(",
"$",
"text",
")",
")",
"{",
"if",
"(",
"''",
"!=",
"$",
"text",
"[",
"0... | creates a model.
@param mixed ...$text
@return Model
@throws CasbinException | [
"creates",
"a",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L240-L254 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.loadModel | public function loadModel()
{
$this->model = self::newModel();
$this->model->loadModel($this->modelPath);
$this->model->printModel();
$this->fm = Model::LoadFunctionMap();
} | php | public function loadModel()
{
$this->model = self::newModel();
$this->model->loadModel($this->modelPath);
$this->model->printModel();
$this->fm = Model::LoadFunctionMap();
} | [
"public",
"function",
"loadModel",
"(",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"self",
"::",
"newModel",
"(",
")",
";",
"$",
"this",
"->",
"model",
"->",
"loadModel",
"(",
"$",
"this",
"->",
"modelPath",
")",
";",
"$",
"this",
"->",
"model",
"-... | reloads the model from the model CONF file.
Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling LoadPolicy().
@throws CasbinException | [
"reloads",
"the",
"model",
"from",
"the",
"model",
"CONF",
"file",
".",
"Because",
"the",
"policy",
"is",
"attached",
"to",
"a",
"model",
"so",
"the",
"policy",
"is",
"invalidated",
"and",
"needs",
"to",
"be",
"reloaded",
"by",
"calling",
"LoadPolicy",
"()... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L262-L268 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.setModel | public function setModel(Model $model)
{
$this->model = $model;
$this->fm = $this->model->loadFunctionMap();
} | php | public function setModel(Model $model)
{
$this->model = $model;
$this->fm = $this->model->loadFunctionMap();
} | [
"public",
"function",
"setModel",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"model",
";",
"$",
"this",
"->",
"fm",
"=",
"$",
"this",
"->",
"model",
"->",
"loadFunctionMap",
"(",
")",
";",
"}"
] | sets the current model.
@param Model $model | [
"sets",
"the",
"current",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L285-L289 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.setWatcher | public function setWatcher(Watcher $watcher)
{
$this->watcher = $watcher;
$this->watcher->setUpdateCallback(function () {
$this->loadPolicy();
});
} | php | public function setWatcher(Watcher $watcher)
{
$this->watcher = $watcher;
$this->watcher->setUpdateCallback(function () {
$this->loadPolicy();
});
} | [
"public",
"function",
"setWatcher",
"(",
"Watcher",
"$",
"watcher",
")",
"{",
"$",
"this",
"->",
"watcher",
"=",
"$",
"watcher",
";",
"$",
"this",
"->",
"watcher",
"->",
"setUpdateCallback",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"loadPolicy"... | sets the current watcher.
@param Watcher $watcher | [
"sets",
"the",
"current",
"watcher",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L316-L322 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.loadPolicy | public function loadPolicy()
{
$this->model->clearPolicy();
$this->adapter->loadPolicy($this->model);
$this->model->printPolicy();
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
} | php | public function loadPolicy()
{
$this->model->clearPolicy();
$this->adapter->loadPolicy($this->model);
$this->model->printPolicy();
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
} | [
"public",
"function",
"loadPolicy",
"(",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"clearPolicy",
"(",
")",
";",
"$",
"this",
"->",
"adapter",
"->",
"loadPolicy",
"(",
"$",
"this",
"->",
"model",
")",
";",
"$",
"this",
"->",
"model",
"->",
"printPo... | reloads the policy from file/database. | [
"reloads",
"the",
"policy",
"from",
"file",
"/",
"database",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L355-L364 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.loadFilteredPolicy | public function loadFilteredPolicy($filter)
{
$this->model->clearPolicy();
if ($this->adapter instanceof FilteredAdapter) {
$filteredAdapter = $this->adapter;
} else {
throw new CasbinException('filtered policies are not supported by this adapter');
}
$filteredAdapter->loadFilteredPolicy($this->model, $filter);
$this->model->printPolicy();
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
} | php | public function loadFilteredPolicy($filter)
{
$this->model->clearPolicy();
if ($this->adapter instanceof FilteredAdapter) {
$filteredAdapter = $this->adapter;
} else {
throw new CasbinException('filtered policies are not supported by this adapter');
}
$filteredAdapter->loadFilteredPolicy($this->model, $filter);
$this->model->printPolicy();
if ($this->autoBuildRoleLinks) {
$this->buildRoleLinks();
}
} | [
"public",
"function",
"loadFilteredPolicy",
"(",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"clearPolicy",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"adapter",
"instanceof",
"FilteredAdapter",
")",
"{",
"$",
"filteredAdapter",
"=",
"$",
... | reloads a filtered policy from file/database.
@param $filter
@throws CasbinException | [
"reloads",
"a",
"filtered",
"policy",
"from",
"file",
"/",
"database",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L373-L388 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.isFiltered | public function isFiltered()
{
if (!$this->adapter instanceof FilteredAdapter) {
return false;
}
$filteredAdapter = $this->adapter;
$filteredAdapter->isFiltered();
} | php | public function isFiltered()
{
if (!$this->adapter instanceof FilteredAdapter) {
return false;
}
$filteredAdapter = $this->adapter;
$filteredAdapter->isFiltered();
} | [
"public",
"function",
"isFiltered",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"instanceof",
"FilteredAdapter",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filteredAdapter",
"=",
"$",
"this",
"->",
"adapter",
";",
"$",
"filteredAdapter",... | returns true if the loaded policy has been filtered.
@return bool | [
"returns",
"true",
"if",
"the",
"loaded",
"policy",
"has",
"been",
"filtered",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L395-L403 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.savePolicy | public function savePolicy()
{
if ($this->isFiltered()) {
throw new CasbinException('cannot save a filtered policy');
}
$this->adapter->savePolicy($this->model);
if (null !== $this->watcher) {
return $this->watcher->update();
}
} | php | public function savePolicy()
{
if ($this->isFiltered()) {
throw new CasbinException('cannot save a filtered policy');
}
$this->adapter->savePolicy($this->model);
if (null !== $this->watcher) {
return $this->watcher->update();
}
} | [
"public",
"function",
"savePolicy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFiltered",
"(",
")",
")",
"{",
"throw",
"new",
"CasbinException",
"(",
"'cannot save a filtered policy'",
")",
";",
"}",
"$",
"this",
"->",
"adapter",
"->",
"savePolicy",
"... | saves the current policy (usually after changed with Casbin API) back to file/database.
@return mixed
@throws CasbinException | [
"saves",
"the",
"current",
"policy",
"(",
"usually",
"after",
"changed",
"with",
"Casbin",
"API",
")",
"back",
"to",
"file",
"/",
"database",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L412-L423 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.enforce | public function enforce(...$rvals)
{
if (!$this->enabled) {
return true;
}
$functions = [];
foreach ($this->fm->getFunctions() as $key => $func) {
$functions[$key] = $func;
}
if (isset($this->model->model['g'])) {
foreach ($this->model->model['g'] as $key => $ast) {
$rm = $ast->rM;
$functions[$key] = BuiltinOperations::GenerateGFunction($rm);
}
}
if (!isset($this->model->model['m']['m'])) {
throw new CasbinException('model is undefined');
}
$expString = $this->model->model['m']['m']->value;
$policyEffects = [];
$matcherResults = [];
$policyLen = \count($this->model->model['p']['p']->policy);
if (0 != $policyLen) {
foreach ($this->model->model['p']['p']->policy as $i => $pvals) {
$parameters = [];
foreach ($this->model->model['r']['r']->tokens as $j => $token) {
$parameters[$token] = $rvals[$j];
}
foreach ($this->model->model['p']['p']->tokens as $j => $token) {
$parameters[$token] = $pvals[$j];
}
$result = $this->expressionEvaluate($expString, $parameters, $functions);
if (\is_bool($result)) {
if (!$result) {
$policyEffects[$i] = Effector::INDETERMINATE;
continue;
}
} elseif (\is_float($result)) {
if (0 == $result) {
$policyEffects[$i] = Effector::INDETERMINATE;
continue;
} else {
$matcherResults[$i] = $result;
}
} else {
throw new CasbinException('matcher result should be bool, int or float');
}
if (isset($parameters['p_eft'])) {
$eft = $parameters['p_eft'];
if ('allow' == $eft) {
$policyEffects[$i] = Effector::ALLOW;
} elseif ('deny' == $eft) {
$policyEffects[$i] = Effector::DENY;
} else {
$policyEffects[$i] = Effector::INDETERMINATE;
}
} else {
$policyEffects[$i] = Effector::ALLOW;
}
if (isset($this->model->model['e']['e']) && 'priority(p_eft) || deny' == $this->model->model['e']['e']->value) {
break;
}
}
} else {
$parameters = [];
foreach ($this->model->model['r']['r']->tokens as $j => $token) {
$parameters[$token] = $rvals[$j];
}
foreach ($this->model->model['p']['p']->tokens as $token) {
$parameters[$token] = '';
}
$result = $this->expressionEvaluate($expString, $parameters, $functions);
if ($result) {
$policyEffects[0] = Effector::ALLOW;
} else {
$policyEffects[0] = Effector::INDETERMINATE;
}
}
$result = $this->eft->mergeEffects($this->model->model['e']['e']->value, $policyEffects, $matcherResults);
if (Log::getLogger()->isEnabled()) {
$reqStr = 'Request: ';
$reqStr .= implode(', ', array_values($rvals));
$reqStr .= sprintf(' ---> %s', (string) $result);
Log::logPrint($reqStr);
}
return $result;
} | php | public function enforce(...$rvals)
{
if (!$this->enabled) {
return true;
}
$functions = [];
foreach ($this->fm->getFunctions() as $key => $func) {
$functions[$key] = $func;
}
if (isset($this->model->model['g'])) {
foreach ($this->model->model['g'] as $key => $ast) {
$rm = $ast->rM;
$functions[$key] = BuiltinOperations::GenerateGFunction($rm);
}
}
if (!isset($this->model->model['m']['m'])) {
throw new CasbinException('model is undefined');
}
$expString = $this->model->model['m']['m']->value;
$policyEffects = [];
$matcherResults = [];
$policyLen = \count($this->model->model['p']['p']->policy);
if (0 != $policyLen) {
foreach ($this->model->model['p']['p']->policy as $i => $pvals) {
$parameters = [];
foreach ($this->model->model['r']['r']->tokens as $j => $token) {
$parameters[$token] = $rvals[$j];
}
foreach ($this->model->model['p']['p']->tokens as $j => $token) {
$parameters[$token] = $pvals[$j];
}
$result = $this->expressionEvaluate($expString, $parameters, $functions);
if (\is_bool($result)) {
if (!$result) {
$policyEffects[$i] = Effector::INDETERMINATE;
continue;
}
} elseif (\is_float($result)) {
if (0 == $result) {
$policyEffects[$i] = Effector::INDETERMINATE;
continue;
} else {
$matcherResults[$i] = $result;
}
} else {
throw new CasbinException('matcher result should be bool, int or float');
}
if (isset($parameters['p_eft'])) {
$eft = $parameters['p_eft'];
if ('allow' == $eft) {
$policyEffects[$i] = Effector::ALLOW;
} elseif ('deny' == $eft) {
$policyEffects[$i] = Effector::DENY;
} else {
$policyEffects[$i] = Effector::INDETERMINATE;
}
} else {
$policyEffects[$i] = Effector::ALLOW;
}
if (isset($this->model->model['e']['e']) && 'priority(p_eft) || deny' == $this->model->model['e']['e']->value) {
break;
}
}
} else {
$parameters = [];
foreach ($this->model->model['r']['r']->tokens as $j => $token) {
$parameters[$token] = $rvals[$j];
}
foreach ($this->model->model['p']['p']->tokens as $token) {
$parameters[$token] = '';
}
$result = $this->expressionEvaluate($expString, $parameters, $functions);
if ($result) {
$policyEffects[0] = Effector::ALLOW;
} else {
$policyEffects[0] = Effector::INDETERMINATE;
}
}
$result = $this->eft->mergeEffects($this->model->model['e']['e']->value, $policyEffects, $matcherResults);
if (Log::getLogger()->isEnabled()) {
$reqStr = 'Request: ';
$reqStr .= implode(', ', array_values($rvals));
$reqStr .= sprintf(' ---> %s', (string) $result);
Log::logPrint($reqStr);
}
return $result;
} | [
"public",
"function",
"enforce",
"(",
"...",
"$",
"rvals",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"true",
";",
"}",
"$",
"functions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"fm",
"->",
"getFunc... | decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
@param mixed ...$rvals
@return bool|mixed
@throws CasbinException | [
"decides",
"whether",
"a",
"subject",
"can",
"access",
"a",
"object",
"with",
"the",
"operation",
"action",
"input",
"parameters",
"are",
"usually",
":",
"(",
"sub",
"obj",
"act",
")",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L483-L587 |
php-casbin/php-casbin | src/Enforcer.php | Enforcer.expressionEvaluate | protected function expressionEvaluate($expString, $parameters, $functions)
{
$expString = preg_replace_callback(
'/([\s\S]*in\s+)\(([\s\S]+)\)([\s\S]*)/',
function ($m) {
return $m[1].'['.$m[2].']'.$m[3];
},
$expString
);
$expressionLanguage = new ExpressionLanguage();
foreach ($functions as $key => $func) {
$expressionLanguage->register($key, function (...$args) use ($key) {
return sprintf($key.'(%1$s)', implode(',', $args));
}, function ($arguments, ...$args) use ($func) {
return $func(...$args);
});
}
// $expressionLanguage->compile($expString, array_keys($parameters));
return $expressionLanguage->evaluate($expString, $parameters);
} | php | protected function expressionEvaluate($expString, $parameters, $functions)
{
$expString = preg_replace_callback(
'/([\s\S]*in\s+)\(([\s\S]+)\)([\s\S]*)/',
function ($m) {
return $m[1].'['.$m[2].']'.$m[3];
},
$expString
);
$expressionLanguage = new ExpressionLanguage();
foreach ($functions as $key => $func) {
$expressionLanguage->register($key, function (...$args) use ($key) {
return sprintf($key.'(%1$s)', implode(',', $args));
}, function ($arguments, ...$args) use ($func) {
return $func(...$args);
});
}
// $expressionLanguage->compile($expString, array_keys($parameters));
return $expressionLanguage->evaluate($expString, $parameters);
} | [
"protected",
"function",
"expressionEvaluate",
"(",
"$",
"expString",
",",
"$",
"parameters",
",",
"$",
"functions",
")",
"{",
"$",
"expString",
"=",
"preg_replace_callback",
"(",
"'/([\\s\\S]*in\\s+)\\(([\\s\\S]+)\\)([\\s\\S]*)/'",
",",
"function",
"(",
"$",
"m",
"... | @param $expString
@param $parameters
@param $functions
@return mixed | [
"@param",
"$expString",
"@param",
"$parameters",
"@param",
"$functions"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Enforcer.php#L596-L616 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.keyMatch | public static function keyMatch($key1, $key2)
{
if (false === strpos($key2, '*')) {
return $key1 == $key2;
}
$needle = rtrim($key2, '*');
return substr($key1, 0, \strlen($needle)) === (string) $needle;
} | php | public static function keyMatch($key1, $key2)
{
if (false === strpos($key2, '*')) {
return $key1 == $key2;
}
$needle = rtrim($key2, '*');
return substr($key1, 0, \strlen($needle)) === (string) $needle;
} | [
"public",
"static",
"function",
"keyMatch",
"(",
"$",
"key1",
",",
"$",
"key2",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"key2",
",",
"'*'",
")",
")",
"{",
"return",
"$",
"key1",
"==",
"$",
"key2",
";",
"}",
"$",
"needle",
"=",
... | determines whether key1 matches the pattern of key2 (similar to RESTful path), key2 can contain a *.
For example, "/foo/bar" matches "/foo/*".
@param string $key1
@param string $key2
@return bool | [
"determines",
"whether",
"key1",
"matches",
"the",
"pattern",
"of",
"key2",
"(",
"similar",
"to",
"RESTful",
"path",
")",
"key2",
"can",
"contain",
"a",
"*",
".",
"For",
"example",
"/",
"foo",
"/",
"bar",
"matches",
"/",
"foo",
"/",
"*",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L25-L34 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.keyMatchFunc | public static function keyMatchFunc(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch($name1, $name2);
} | php | public static function keyMatchFunc(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch($name1, $name2);
} | [
"public",
"static",
"function",
"keyMatchFunc",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"name1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"name2",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"self",
"::",
"keyMatch",
"(",
"$",
"name1",
",",... | the wrapper for KeyMatch.
@param mixed ...$args
@return bool | [
"the",
"wrapper",
"for",
"KeyMatch",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L43-L49 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.keyMatch2 | public static function keyMatch2($key1, $key2)
{
$key2 = str_replace(['/*'], ['/.*'], $key2);
$pattern = '/(.*):[^\/]+(.*)/';
for (; ;) {
if (false === strpos($key2, '/:')) {
break;
}
$key2 = preg_replace_callback(
$pattern,
function ($m) {
return $m[1].'[^\/]+'.$m[2];
},
$key2
);
$key2 = '^'.$key2.'$';
}
return self::regexMatch($key1, $key2);
} | php | public static function keyMatch2($key1, $key2)
{
$key2 = str_replace(['/*'], ['/.*'], $key2);
$pattern = '/(.*):[^\/]+(.*)/';
for (; ;) {
if (false === strpos($key2, '/:')) {
break;
}
$key2 = preg_replace_callback(
$pattern,
function ($m) {
return $m[1].'[^\/]+'.$m[2];
},
$key2
);
$key2 = '^'.$key2.'$';
}
return self::regexMatch($key1, $key2);
} | [
"public",
"static",
"function",
"keyMatch2",
"(",
"$",
"key1",
",",
"$",
"key2",
")",
"{",
"$",
"key2",
"=",
"str_replace",
"(",
"[",
"'/*'",
"]",
",",
"[",
"'/.*'",
"]",
",",
"$",
"key2",
")",
";",
"$",
"pattern",
"=",
"'/(.*):[^\\/]+(.*)/'",
";",
... | determines whether key1 matches the pattern of key2 (similar to RESTful path), key2 can contain a *.
For example, "/foo/bar" matches "/foo/*", "/resource1" matches "/:resource".
@param string $key1
@param string $key2
@return false|int | [
"determines",
"whether",
"key1",
"matches",
"the",
"pattern",
"of",
"key2",
"(",
"similar",
"to",
"RESTful",
"path",
")",
"key2",
"can",
"contain",
"a",
"*",
".",
"For",
"example",
"/",
"foo",
"/",
"bar",
"matches",
"/",
"foo",
"/",
"*",
"/",
"resource... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L60-L80 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.keyMatch2Func | public static function keyMatch2Func(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch2($name1, $name2);
} | php | public static function keyMatch2Func(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch2($name1, $name2);
} | [
"public",
"static",
"function",
"keyMatch2Func",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"name1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"name2",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"self",
"::",
"keyMatch2",
"(",
"$",
"name1",
",... | the wrapper for KeyMatch2.
@param mixed ...$args
@return false|int | [
"the",
"wrapper",
"for",
"KeyMatch2",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L89-L95 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.keyMatch3Func | public static function keyMatch3Func(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch3($name1, $name2);
} | php | public static function keyMatch3Func(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::keyMatch3($name1, $name2);
} | [
"public",
"static",
"function",
"keyMatch3Func",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"name1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"name2",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"self",
"::",
"keyMatch3",
"(",
"$",
"name1",
",... | the wrapper for KeyMatch3.
@param mixed ...$args
@return false|int | [
"the",
"wrapper",
"for",
"KeyMatch3",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L134-L140 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.regexMatchFunc | public static function regexMatchFunc(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::regexMatch($name1, $name2);
} | php | public static function regexMatchFunc(...$args)
{
$name1 = $args[0];
$name2 = $args[1];
return self::regexMatch($name1, $name2);
} | [
"public",
"static",
"function",
"regexMatchFunc",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"name1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"name2",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"self",
"::",
"regexMatch",
"(",
"$",
"name1",
... | the wrapper for RegexMatch.
@param mixed ...$args
@return false|int | [
"the",
"wrapper",
"for",
"RegexMatch",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L162-L168 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.iPMatch | public static function iPMatch($ip1, $ip2)
{
$objIP1 = IP::parse($ip1);
$objIP2 = Range::parse($ip2);
return $objIP2->contains($objIP1);
} | php | public static function iPMatch($ip1, $ip2)
{
$objIP1 = IP::parse($ip1);
$objIP2 = Range::parse($ip2);
return $objIP2->contains($objIP1);
} | [
"public",
"static",
"function",
"iPMatch",
"(",
"$",
"ip1",
",",
"$",
"ip2",
")",
"{",
"$",
"objIP1",
"=",
"IP",
"::",
"parse",
"(",
"$",
"ip1",
")",
";",
"$",
"objIP2",
"=",
"Range",
"::",
"parse",
"(",
"$",
"ip2",
")",
";",
"return",
"$",
"ob... | determines whether IP address ip1 matches the pattern of IP address ip2, ip2 can be an IP address or a CIDR pattern.
@param string $ip1
@param string $ip2
@return bool
@throws \Exception | [
"determines",
"whether",
"IP",
"address",
"ip1",
"matches",
"the",
"pattern",
"of",
"IP",
"address",
"ip2",
"ip2",
"can",
"be",
"an",
"IP",
"address",
"or",
"a",
"CIDR",
"pattern",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L180-L187 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.iPMatchFunc | public static function iPMatchFunc(...$args)
{
$ip1 = $args[0];
$ip2 = $args[1];
return self::iPMatch($ip1, $ip2);
} | php | public static function iPMatchFunc(...$args)
{
$ip1 = $args[0];
$ip2 = $args[1];
return self::iPMatch($ip1, $ip2);
} | [
"public",
"static",
"function",
"iPMatchFunc",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"ip1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"ip2",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"self",
"::",
"iPMatch",
"(",
"$",
"ip1",
",",
"$",
... | the wrapper for IPMatch.
@param mixed ...$args
@return bool
@throws \Exception | [
"the",
"wrapper",
"for",
"IPMatch",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L198-L204 |
php-casbin/php-casbin | src/Util/BuiltinOperations.php | BuiltinOperations.generateGFunction | public static function generateGFunction(RoleManager $rm = null)
{
return function (...$args) use ($rm) {
$name1 = $args[0];
$name2 = $args[1];
if (null === $rm) {
return $name1 == $name2;
} elseif (2 == \count($args)) {
$res = $rm->hasLink($name1, $name2);
return $res;
} else {
$domain = (string) $args[2];
$res = $rm->hasLink($name1, $name2, $domain);
return $res;
}
};
} | php | public static function generateGFunction(RoleManager $rm = null)
{
return function (...$args) use ($rm) {
$name1 = $args[0];
$name2 = $args[1];
if (null === $rm) {
return $name1 == $name2;
} elseif (2 == \count($args)) {
$res = $rm->hasLink($name1, $name2);
return $res;
} else {
$domain = (string) $args[2];
$res = $rm->hasLink($name1, $name2, $domain);
return $res;
}
};
} | [
"public",
"static",
"function",
"generateGFunction",
"(",
"RoleManager",
"$",
"rm",
"=",
"null",
")",
"{",
"return",
"function",
"(",
"...",
"$",
"args",
")",
"use",
"(",
"$",
"rm",
")",
"{",
"$",
"name1",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",... | the factory method of the g(_, _) function.
@param RoleManager|null $rm
@return \Closure | [
"the",
"factory",
"method",
"of",
"the",
"g",
"(",
"_",
"_",
")",
"function",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/BuiltinOperations.php#L213-L232 |
php-casbin/php-casbin | src/Model/FunctionMap.php | FunctionMap.loadFunctionMap | public static function loadFunctionMap()
{
$fm = new self();
$fm->addFunction('keyMatch', function (...$args) {
return BuiltinOperations::keyMatchFunc(...$args);
});
$fm->addFunction('keyMatch2', function (...$args) {
return BuiltinOperations::keyMatch2Func(...$args);
});
$fm->addFunction('regexMatch', function (...$args) {
return BuiltinOperations::regexMatchFunc(...$args);
});
$fm->addFunction('ipMatch', function (...$args) {
return BuiltinOperations::iPMatchFunc(...$args);
});
return $fm;
} | php | public static function loadFunctionMap()
{
$fm = new self();
$fm->addFunction('keyMatch', function (...$args) {
return BuiltinOperations::keyMatchFunc(...$args);
});
$fm->addFunction('keyMatch2', function (...$args) {
return BuiltinOperations::keyMatch2Func(...$args);
});
$fm->addFunction('regexMatch', function (...$args) {
return BuiltinOperations::regexMatchFunc(...$args);
});
$fm->addFunction('ipMatch', function (...$args) {
return BuiltinOperations::iPMatchFunc(...$args);
});
return $fm;
} | [
"public",
"static",
"function",
"loadFunctionMap",
"(",
")",
"{",
"$",
"fm",
"=",
"new",
"self",
"(",
")",
";",
"$",
"fm",
"->",
"addFunction",
"(",
"'keyMatch'",
",",
"function",
"(",
"...",
"$",
"args",
")",
"{",
"return",
"BuiltinOperations",
"::",
... | loads an initial function map.
@return FunctionMap | [
"loads",
"an",
"initial",
"function",
"map",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/FunctionMap.php#L30-L48 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.createRole | protected function createRole($name)
{
if (!isset($this->allRoles[$name])) {
$this->allRoles[$name] = new Role($name);
}
return $this->allRoles[$name];
} | php | protected function createRole($name)
{
if (!isset($this->allRoles[$name])) {
$this->allRoles[$name] = new Role($name);
}
return $this->allRoles[$name];
} | [
"protected",
"function",
"createRole",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"allRoles",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"allRoles",
"[",
"$",
"name",
"]",
"=",
"new",
"Role",
"(",
... | @param string $name
@return mixed | [
"@param",
"string",
"$name"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L54-L61 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.addLink | public function addLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
$role1 = $this->createRole($name1);
$role2 = $this->createRole($name2);
$role1->addRole($role2);
} | php | public function addLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
$role1 = $this->createRole($name1);
$role2 = $this->createRole($name2);
$role1->addRole($role2);
} | [
"public",
"function",
"addLink",
"(",
"$",
"name1",
",",
"$",
"name2",
",",
"...",
"$",
"domain",
")",
"{",
"if",
"(",
"1",
"==",
"\\",
"count",
"(",
"$",
"domain",
")",
")",
"{",
"$",
"name1",
"=",
"$",
"domain",
"[",
"0",
"]",
".",
"'::'",
... | adds the inheritance link between role: name1 and role: name2.
aka role: name1 inherits role: name2.
domain is a prefix to the roles.
@param string $name1
@param string $name2
@param mixed ...$domain
@throws CasbinException | [
"adds",
"the",
"inheritance",
"link",
"between",
"role",
":",
"name1",
"and",
"role",
":",
"name2",
".",
"aka",
"role",
":",
"name1",
"inherits",
"role",
":",
"name2",
".",
"domain",
"is",
"a",
"prefix",
"to",
"the",
"roles",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L82-L94 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.deleteLink | public function deleteLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if (!$this->hasRole($name1) || !$this->hasRole($name2)) {
throw new CasbinException('error: name1 or name2 does not exist');
}
$role1 = $this->createRole($name1);
$role2 = $this->createRole($name2);
$role1->deleteRole($role2);
} | php | public function deleteLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if (!$this->hasRole($name1) || !$this->hasRole($name2)) {
throw new CasbinException('error: name1 or name2 does not exist');
}
$role1 = $this->createRole($name1);
$role2 = $this->createRole($name2);
$role1->deleteRole($role2);
} | [
"public",
"function",
"deleteLink",
"(",
"$",
"name1",
",",
"$",
"name2",
",",
"...",
"$",
"domain",
")",
"{",
"if",
"(",
"1",
"==",
"\\",
"count",
"(",
"$",
"domain",
")",
")",
"{",
"$",
"name1",
"=",
"$",
"domain",
"[",
"0",
"]",
".",
"'::'",... | deletes the inheritance link between role: name1 and role: name2.
aka role: name1 does not inherit role: name2 any more.
domain is a prefix to the roles.
@param string $name1
@param string $name2
@param mixed ...$domain
@throws CasbinException | [
"deletes",
"the",
"inheritance",
"link",
"between",
"role",
":",
"name1",
"and",
"role",
":",
"name2",
".",
"aka",
"role",
":",
"name1",
"does",
"not",
"inherit",
"role",
":",
"name2",
"any",
"more",
".",
"domain",
"is",
"a",
"prefix",
"to",
"the",
"ro... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L107-L123 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.hasLink | public function hasLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if ($name1 == $name2) {
return true;
}
if (!$this->hasRole($name1) || !$this->hasRole($name2)) {
return false;
}
$role1 = $this->createRole($name1);
return $role1->hasRole($name2, $this->maxHierarchyLevel);
} | php | public function hasLink($name1, $name2, ...$domain)
{
if (1 == \count($domain)) {
$name1 = $domain[0].'::'.$name1;
$name2 = $domain[0].'::'.$name2;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if ($name1 == $name2) {
return true;
}
if (!$this->hasRole($name1) || !$this->hasRole($name2)) {
return false;
}
$role1 = $this->createRole($name1);
return $role1->hasRole($name2, $this->maxHierarchyLevel);
} | [
"public",
"function",
"hasLink",
"(",
"$",
"name1",
",",
"$",
"name2",
",",
"...",
"$",
"domain",
")",
"{",
"if",
"(",
"1",
"==",
"\\",
"count",
"(",
"$",
"domain",
")",
")",
"{",
"$",
"name1",
"=",
"$",
"domain",
"[",
"0",
"]",
".",
"'::'",
... | determines whether role: name1 inherits role: name2.
domain is a prefix to the roles.
@param string $name1
@param string $name2
@param mixed ...$domain
@return bool
@throws CasbinException | [
"determines",
"whether",
"role",
":",
"name1",
"inherits",
"role",
":",
"name2",
".",
"domain",
"is",
"a",
"prefix",
"to",
"the",
"roles",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L137-L157 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.getRoles | public function getRoles($name, ...$domain)
{
if (1 == \count($domain)) {
$name = $domain[0].'::'.$name;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if (!$this->hasRole($name)) {
return [];
}
$roles = $this->createRole($name)->getRoles();
if (1 == \count($domain)) {
foreach ($roles as $key => $value) {
$roles[$key] = \array_slice($roles[$key], \strlen($domain[0]) + 2);
}
}
return $roles;
} | php | public function getRoles($name, ...$domain)
{
if (1 == \count($domain)) {
$name = $domain[0].'::'.$name;
} elseif (\count($domain) > 1) {
throw new CasbinException('error: domain should be 1 parameter');
}
if (!$this->hasRole($name)) {
return [];
}
$roles = $this->createRole($name)->getRoles();
if (1 == \count($domain)) {
foreach ($roles as $key => $value) {
$roles[$key] = \array_slice($roles[$key], \strlen($domain[0]) + 2);
}
}
return $roles;
} | [
"public",
"function",
"getRoles",
"(",
"$",
"name",
",",
"...",
"$",
"domain",
")",
"{",
"if",
"(",
"1",
"==",
"\\",
"count",
"(",
"$",
"domain",
")",
")",
"{",
"$",
"name",
"=",
"$",
"domain",
"[",
"0",
"]",
".",
"'::'",
".",
"$",
"name",
";... | gets the roles that a subject inherits.
domain is a prefix to the roles.
@param string $name
@param mixed ...$domain
@return array
@throws CasbinException | [
"gets",
"the",
"roles",
"that",
"a",
"subject",
"inherits",
".",
"domain",
"is",
"a",
"prefix",
"to",
"the",
"roles",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L170-L190 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.getUsers | public function getUsers($name, ...$domain)
{
if (!$this->hasRole($name)) {
throw new CasbinException('error: name does not exist');
}
$names = [];
array_map(function ($role) use (&$names, $name) {
if ($role->hasDirectRole($name)) {
$names[] = $role->name;
}
}, $this->allRoles);
return $names;
} | php | public function getUsers($name, ...$domain)
{
if (!$this->hasRole($name)) {
throw new CasbinException('error: name does not exist');
}
$names = [];
array_map(function ($role) use (&$names, $name) {
if ($role->hasDirectRole($name)) {
$names[] = $role->name;
}
}, $this->allRoles);
return $names;
} | [
"public",
"function",
"getUsers",
"(",
"$",
"name",
",",
"...",
"$",
"domain",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRole",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"CasbinException",
"(",
"'error: name does not exist'",
")",
";",
"}... | gets the users that inherits a subject.
domain is an unreferenced parameter here, may be used in other implementations.
@param string $name
@param mixed ...$domain
@return array
@throws CasbinException | [
"gets",
"the",
"users",
"that",
"inherits",
"a",
"subject",
".",
"domain",
"is",
"an",
"unreferenced",
"parameter",
"here",
"may",
"be",
"used",
"in",
"other",
"implementations",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L203-L217 |
php-casbin/php-casbin | src/Rbac/DefaultRoleManager/RoleManager.php | RoleManager.printRoles | public function printRoles()
{
$line = [];
array_map(function ($role) use (&$line) {
if ($text = $role->toString()) {
$line[] = $text;
}
}, $this->allRoles);
Log::logPrint(implode(', ', $line));
} | php | public function printRoles()
{
$line = [];
array_map(function ($role) use (&$line) {
if ($text = $role->toString()) {
$line[] = $text;
}
}, $this->allRoles);
Log::logPrint(implode(', ', $line));
} | [
"public",
"function",
"printRoles",
"(",
")",
"{",
"$",
"line",
"=",
"[",
"]",
";",
"array_map",
"(",
"function",
"(",
"$",
"role",
")",
"use",
"(",
"&",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"text",
"=",
"$",
"role",
"->",
"toString",
"(",
")... | prints all the roles to log. | [
"prints",
"all",
"the",
"roles",
"to",
"log",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/DefaultRoleManager/RoleManager.php#L222-L231 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.buildRoleLinks | public function buildRoleLinks($rm)
{
if (!isset($this->model['g'])) {
return;
}
foreach ($this->model['g'] as $ast) {
$ast->buildRoleLinks($rm);
}
} | php | public function buildRoleLinks($rm)
{
if (!isset($this->model['g'])) {
return;
}
foreach ($this->model['g'] as $ast) {
$ast->buildRoleLinks($rm);
}
} | [
"public",
"function",
"buildRoleLinks",
"(",
"$",
"rm",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"model",
"[",
"'g'",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"model",
"[",
"'g'",
"]",
"as",
"... | initializes the roles in RBAC.
@param RoleManager $rm | [
"initializes",
"the",
"roles",
"in",
"RBAC",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L21-L29 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.printPolicy | public function printPolicy()
{
Log::logPrint('Policy:');
foreach (['p', 'g'] as $sec) {
if (!isset($this->model[$sec])) {
return;
}
foreach ($this->model[$sec] as $key => $ast) {
Log::logPrint($key, ': ', $ast->value, ': ', $ast->policy);
}
}
} | php | public function printPolicy()
{
Log::logPrint('Policy:');
foreach (['p', 'g'] as $sec) {
if (!isset($this->model[$sec])) {
return;
}
foreach ($this->model[$sec] as $key => $ast) {
Log::logPrint($key, ': ', $ast->value, ': ', $ast->policy);
}
}
} | [
"public",
"function",
"printPolicy",
"(",
")",
"{",
"Log",
"::",
"logPrint",
"(",
"'Policy:'",
")",
";",
"foreach",
"(",
"[",
"'p'",
",",
"'g'",
"]",
"as",
"$",
"sec",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
... | prints the policy to log. | [
"prints",
"the",
"policy",
"to",
"log",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L34-L45 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.clearPolicy | public function clearPolicy()
{
foreach (['p', 'g'] as $sec) {
if (!isset($this->model[$sec])) {
return;
}
foreach ($this->model[$sec] as $key => $ast) {
$this->model[$sec][$key]->policy = [];
}
}
} | php | public function clearPolicy()
{
foreach (['p', 'g'] as $sec) {
if (!isset($this->model[$sec])) {
return;
}
foreach ($this->model[$sec] as $key => $ast) {
$this->model[$sec][$key]->policy = [];
}
}
} | [
"public",
"function",
"clearPolicy",
"(",
")",
"{",
"foreach",
"(",
"[",
"'p'",
",",
"'g'",
"]",
"as",
"$",
"sec",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
"sec",
"]",
")",
")",
"{",
"return",
";",
"}",
"f... | clears all current policy. | [
"clears",
"all",
"current",
"policy",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L50-L60 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.getFilteredPolicy | public function getFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
{
$res = [];
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$matched = true;
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;
break;
}
}
if ($matched) {
$res[] = $rule;
}
}
return $res;
} | php | public function getFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
{
$res = [];
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$matched = true;
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;
break;
}
}
if ($matched) {
$res[] = $rule;
}
}
return $res;
} | [
"public",
"function",
"getFilteredPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"$",
"fieldIndex",
",",
"...",
"$",
"fieldValues",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
"sec",
"]",
"[",
... | gets rules based on field filters from a policy.
@param string $sec
@param string $ptype
@param int $fieldIndex
@param mixed ...$fieldValues
@return array | [
"gets",
"rules",
"based",
"on",
"field",
"filters",
"from",
"a",
"policy",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L85-L105 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.hasPolicy | public function hasPolicy($sec, $ptype, $rule)
{
if (!isset($this->model[$sec][$ptype])) {
return false;
}
foreach ($this->model[$sec][$ptype]->policy as $r) {
if (empty(array_diff($rule, $r))) {
return true;
}
}
return false;
} | php | public function hasPolicy($sec, $ptype, $rule)
{
if (!isset($this->model[$sec][$ptype])) {
return false;
}
foreach ($this->model[$sec][$ptype]->policy as $r) {
if (empty(array_diff($rule, $r))) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"$",
"rule",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
"sec",
"]",
"[",
"$",
"ptype",
"]",
")",
")",
"{",
"return",
"false",
";",
... | determines whether a model has the specified policy rule.
@param string $sec
@param string $ptype
@param array $rule
@return bool | [
"determines",
"whether",
"a",
"model",
"has",
"the",
"specified",
"policy",
"rule",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L116-L129 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.addPolicy | public function addPolicy($sec, $ptype, array $rule)
{
if (!$this->hasPolicy($sec, $ptype, $rule)) {
$this->model[$sec][$ptype]->policy[] = $rule;
return true;
}
return false;
} | php | public function addPolicy($sec, $ptype, array $rule)
{
if (!$this->hasPolicy($sec, $ptype, $rule)) {
$this->model[$sec][$ptype]->policy[] = $rule;
return true;
}
return false;
} | [
"public",
"function",
"addPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"array",
"$",
"rule",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"$",
"rule",
")",
")",
"{",
"$",
"this",
"->",
... | adds a policy rule to the model.
@param $sec
@param $ptype
@param array $rule
@return bool | [
"adds",
"a",
"policy",
"rule",
"to",
"the",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L140-L149 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.removePolicy | public function removePolicy($sec, $ptype, array $rule)
{
foreach ($this->model[$sec][$ptype]->policy as $i => $r) {
if (empty(array_diff($rule, $r))) {
array_splice($this->model[$sec][$ptype]->policy, $i, 1);
return true;
}
}
return false;
} | php | public function removePolicy($sec, $ptype, array $rule)
{
foreach ($this->model[$sec][$ptype]->policy as $i => $r) {
if (empty(array_diff($rule, $r))) {
array_splice($this->model[$sec][$ptype]->policy, $i, 1);
return true;
}
}
return false;
} | [
"public",
"function",
"removePolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"array",
"$",
"rule",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
"sec",
"]",
"[",
"$",
"ptype",
"]",
"->",
"policy",
"as",
"$",
"i",
"=>",
"$",
... | removes a policy rule from the model.
@param string $sec
@param string $ptype
@param array $rule
@return bool | [
"removes",
"a",
"policy",
"rule",
"from",
"the",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L160-L171 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.removeFilteredPolicy | public function removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
{
$tmp = [];
$res = false;
if (!isset($this->model[$sec][$ptype])) {
return $res;
}
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$matched = true;
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;
break;
}
}
if ($matched) {
$res = true;
} else {
$tmp[] = $rule;
}
}
$this->model[$sec][$ptype]->policy = $tmp;
return $res;
} | php | public function removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
{
$tmp = [];
$res = false;
if (!isset($this->model[$sec][$ptype])) {
return $res;
}
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$matched = true;
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;
break;
}
}
if ($matched) {
$res = true;
} else {
$tmp[] = $rule;
}
}
$this->model[$sec][$ptype]->policy = $tmp;
return $res;
} | [
"public",
"function",
"removeFilteredPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"$",
"fieldIndex",
",",
"...",
"$",
"fieldValues",
")",
"{",
"$",
"tmp",
"=",
"[",
"]",
";",
"$",
"res",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
... | removes policy rules based on field filters from the model.
@param string $sec
@param string $ptype
@param int $fieldIndex
@param mixed ...$fieldValues
@return bool | [
"removes",
"policy",
"rules",
"based",
"on",
"field",
"filters",
"from",
"the",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L183-L212 |
php-casbin/php-casbin | src/Model/Policy.php | Policy.getValuesForFieldInPolicy | public function getValuesForFieldInPolicy($sec, $ptype, $fieldIndex)
{
$values = [];
if (!isset($this->model[$sec][$ptype])) {
return $values;
}
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$values[] = $rule[$fieldIndex];
}
Util::arrayRemoveDuplicates($values);
return $values;
} | php | public function getValuesForFieldInPolicy($sec, $ptype, $fieldIndex)
{
$values = [];
if (!isset($this->model[$sec][$ptype])) {
return $values;
}
foreach ($this->model[$sec][$ptype]->policy as $rule) {
$values[] = $rule[$fieldIndex];
}
Util::arrayRemoveDuplicates($values);
return $values;
} | [
"public",
"function",
"getValuesForFieldInPolicy",
"(",
"$",
"sec",
",",
"$",
"ptype",
",",
"$",
"fieldIndex",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"model",
"[",
"$",
"sec",
"]",
"[",
"$",
... | gets all values for a field for all rules in a policy, duplicated values are removed.
@param string $sec
@param string $ptype
@param int $fieldIndex
@return array | [
"gets",
"all",
"values",
"for",
"a",
"field",
"for",
"all",
"rules",
"in",
"a",
"policy",
"duplicated",
"values",
"are",
"removed",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Policy.php#L223-L238 |
php-casbin/php-casbin | src/Util/Util.php | Util.escapeAssertion | public static function escapeAssertion($s)
{
if (0 === strpos($s, 'r.')) {
$s = substr_replace($s, 'r_', 0, 2);
}
if (0 === strpos($s, 'p.')) {
$s = substr_replace($s, 'p_', 0, 2);
}
$s = preg_replace_callback("~(\|| |=|\)|\(|&|<|>|,|\+|-|!|\*|\/)(r|p)(\.)~", function ($m) {
return $m[1].$m[2].'_';
}, $s);
return $s;
} | php | public static function escapeAssertion($s)
{
if (0 === strpos($s, 'r.')) {
$s = substr_replace($s, 'r_', 0, 2);
}
if (0 === strpos($s, 'p.')) {
$s = substr_replace($s, 'p_', 0, 2);
}
$s = preg_replace_callback("~(\|| |=|\)|\(|&|<|>|,|\+|-|!|\*|\/)(r|p)(\.)~", function ($m) {
return $m[1].$m[2].'_';
}, $s);
return $s;
} | [
"public",
"static",
"function",
"escapeAssertion",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"s",
",",
"'r.'",
")",
")",
"{",
"$",
"s",
"=",
"substr_replace",
"(",
"$",
"s",
",",
"'r_'",
",",
"0",
",",
"2",
")",
";",
... | escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.
@param string $s
@return string | [
"escapes",
"the",
"dots",
"in",
"the",
"assertion",
"because",
"the",
"expression",
"evaluation",
"doesn",
"t",
"support",
"such",
"variable",
"names",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/Util.php#L19-L33 |
php-casbin/php-casbin | src/Util/Util.php | Util.removeComments | public static function removeComments($s)
{
$pos = strpos($s, '#');
return false === $pos ? $s : trim(substr($s, 0, $pos));
} | php | public static function removeComments($s)
{
$pos = strpos($s, '#');
return false === $pos ? $s : trim(substr($s, 0, $pos));
} | [
"public",
"static",
"function",
"removeComments",
"(",
"$",
"s",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"s",
",",
"'#'",
")",
";",
"return",
"false",
"===",
"$",
"pos",
"?",
"$",
"s",
":",
"trim",
"(",
"substr",
"(",
"$",
"s",
",",
"0",... | removes the comments starting with # in the text.
@param string $s
@return string | [
"removes",
"the",
"comments",
"starting",
"with",
"#",
"in",
"the",
"text",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/Util.php#L42-L47 |
php-casbin/php-casbin | src/Util/Util.php | Util.arrayRemoveDuplicates | public static function arrayRemoveDuplicates(&$s)
{
$found = [];
$j = 0;
foreach ($s as $i => $x) {
if (!isset($found[$x])) {
$found[$x] = true;
$s[$j] = $s[$i];
++$j;
}
}
$s = \array_slice($s, 0, $j);
} | php | public static function arrayRemoveDuplicates(&$s)
{
$found = [];
$j = 0;
foreach ($s as $i => $x) {
if (!isset($found[$x])) {
$found[$x] = true;
$s[$j] = $s[$i];
++$j;
}
}
$s = \array_slice($s, 0, $j);
} | [
"public",
"static",
"function",
"arrayRemoveDuplicates",
"(",
"&",
"$",
"s",
")",
"{",
"$",
"found",
"=",
"[",
"]",
";",
"$",
"j",
"=",
"0",
";",
"foreach",
"(",
"$",
"s",
"as",
"$",
"i",
"=>",
"$",
"x",
")",
"{",
"if",
"(",
"!",
"isset",
"("... | removes any duplicated elements in a string array.
@param array $s | [
"removes",
"any",
"duplicated",
"elements",
"in",
"a",
"string",
"array",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Util/Util.php#L66-L78 |
php-casbin/php-casbin | src/Effect/DefaultEffector.php | DefaultEffector.mergeEffects | public function mergeEffects($expr, array $effects, array $results)
{
$result = false;
if ('some(where (p_eft == allow))' == $expr) {
foreach ($effects as $eft) {
if (self::ALLOW == $eft) {
$result = true;
break;
}
}
} elseif ('!some(where (p_eft == deny))' == $expr) {
$result = true;
foreach ($effects as $eft) {
if (self::DENY == $eft) {
$result = false;
break;
}
}
} elseif ('some(where (p_eft == allow)) && !some(where (p_eft == deny))' == $expr) {
foreach ($effects as $eft) {
if (self::ALLOW == $eft) {
$result = true;
} elseif (self::DENY == $eft) {
$result = false;
break;
}
}
} elseif ('priority(p_eft) || deny' == $expr) {
foreach ($effects as $eft) {
if (self::INDETERMINATE != $eft) {
if (self::ALLOW == $eft) {
$result = true;
} else {
$result = false;
}
break;
}
}
} else {
throw new CasbinException('unsupported effect');
}
return $result;
} | php | public function mergeEffects($expr, array $effects, array $results)
{
$result = false;
if ('some(where (p_eft == allow))' == $expr) {
foreach ($effects as $eft) {
if (self::ALLOW == $eft) {
$result = true;
break;
}
}
} elseif ('!some(where (p_eft == deny))' == $expr) {
$result = true;
foreach ($effects as $eft) {
if (self::DENY == $eft) {
$result = false;
break;
}
}
} elseif ('some(where (p_eft == allow)) && !some(where (p_eft == deny))' == $expr) {
foreach ($effects as $eft) {
if (self::ALLOW == $eft) {
$result = true;
} elseif (self::DENY == $eft) {
$result = false;
break;
}
}
} elseif ('priority(p_eft) || deny' == $expr) {
foreach ($effects as $eft) {
if (self::INDETERMINATE != $eft) {
if (self::ALLOW == $eft) {
$result = true;
} else {
$result = false;
}
break;
}
}
} else {
throw new CasbinException('unsupported effect');
}
return $result;
} | [
"public",
"function",
"mergeEffects",
"(",
"$",
"expr",
",",
"array",
"$",
"effects",
",",
"array",
"$",
"results",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"'some(where (p_eft == allow))'",
"==",
"$",
"expr",
")",
"{",
"foreach",
"(",
"$",... | merges all matching results collected by the enforcer into a single decision.
@param $expr
@param array $effects
@param array $results
@return bool
@throws CasbinException | [
"merges",
"all",
"matching",
"results",
"collected",
"by",
"the",
"enforcer",
"into",
"a",
"single",
"decision",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Effect/DefaultEffector.php#L25-L72 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.hasRoleForUser | public function hasRoleForUser($name, $role)
{
$roles = $this->getRolesForUser($name);
$hasRole = false;
foreach ($roles as $r) {
if ($r == $role) {
$hasRole = true;
break;
}
}
return $hasRole;
} | php | public function hasRoleForUser($name, $role)
{
$roles = $this->getRolesForUser($name);
$hasRole = false;
foreach ($roles as $r) {
if ($r == $role) {
$hasRole = true;
break;
}
}
return $hasRole;
} | [
"public",
"function",
"hasRoleForUser",
"(",
"$",
"name",
",",
"$",
"role",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"getRolesForUser",
"(",
"$",
"name",
")",
";",
"$",
"hasRole",
"=",
"false",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"... | determines whether a user has a role.
@param string $name
@param string $role
@return bool | [
"determines",
"whether",
"a",
"user",
"has",
"a",
"role",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L44-L58 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.addPermissionForUser | public function addPermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->addPolicy(...$params);
} | php | public function addPermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->addPolicy(...$params);
} | [
"public",
"function",
"addPermissionForUser",
"(",
"$",
"user",
",",
"...",
"$",
"permission",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"user",
";",
"foreach",
"(",
"$",
"permission",
"as",
"$",
"perm",
")",
"... | adds a permission for a user or role.
returns false if the user or role already has the permission (aka not affected).
@param string $user
@param string ...$permission
@return bool | [
"adds",
"a",
"permission",
"for",
"a",
"user",
"or",
"role",
".",
"returns",
"false",
"if",
"the",
"user",
"or",
"role",
"already",
"has",
"the",
"permission",
"(",
"aka",
"not",
"affected",
")",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L147-L157 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.deletePermissionForUser | public function deletePermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->removePolicy(...$params);
} | php | public function deletePermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->removePolicy(...$params);
} | [
"public",
"function",
"deletePermissionForUser",
"(",
"$",
"user",
",",
"...",
"$",
"permission",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"user",
";",
"foreach",
"(",
"$",
"permission",
"as",
"$",
"perm",
")",
... | deletes a permission for a user or role.
returns false if the user or role does not have the permission (aka not affected).
@param string $user
@param string ...$permission
@return bool | [
"deletes",
"a",
"permission",
"for",
"a",
"user",
"or",
"role",
".",
"returns",
"false",
"if",
"the",
"user",
"or",
"role",
"does",
"not",
"have",
"the",
"permission",
"(",
"aka",
"not",
"affected",
")",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L168-L178 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.hasPermissionForUser | public function hasPermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->hasPolicy($params);
} | php | public function hasPermissionForUser($user, ...$permission)
{
$params = [];
$params[] = $user;
foreach ($permission as $perm) {
$params[] = $perm;
}
return $this->hasPolicy($params);
} | [
"public",
"function",
"hasPermissionForUser",
"(",
"$",
"user",
",",
"...",
"$",
"permission",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"user",
";",
"foreach",
"(",
"$",
"permission",
"as",
"$",
"perm",
")",
"... | determines whether a user has a permission.
@param string $user
@param string ...$permission
@return bool | [
"determines",
"whether",
"a",
"user",
"has",
"a",
"permission",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L213-L223 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.getImplicitRolesForUser | public function getImplicitRolesForUser($name)
{
$res = [];
$roleSet = [];
$roleSet[$name] = true;
$q = [];
$q[] = $name;
for (; count($q) > 0;) {
$name = $q[0];
$q = array_slice($q, 1);
$roles = $this->rm->getRoles($name);
foreach ($roles as $r) {
if (!isset($roleSet[$r])) {
$res[] = $r;
$q[] = $r;
$roleSet[$r] = true;
}
}
}
return $res;
} | php | public function getImplicitRolesForUser($name)
{
$res = [];
$roleSet = [];
$roleSet[$name] = true;
$q = [];
$q[] = $name;
for (; count($q) > 0;) {
$name = $q[0];
$q = array_slice($q, 1);
$roles = $this->rm->getRoles($name);
foreach ($roles as $r) {
if (!isset($roleSet[$r])) {
$res[] = $r;
$q[] = $r;
$roleSet[$r] = true;
}
}
}
return $res;
} | [
"public",
"function",
"getImplicitRolesForUser",
"(",
"$",
"name",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"roleSet",
"=",
"[",
"]",
";",
"$",
"roleSet",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"$",
"q",
"=",
"[",
"]",
";",
"$",
"q",
... | gets implicit roles that a user has.
Compared to getRolesForUser(), this function retrieves indirect roles besides direct roles.
For example:
g, alice, role:admin
g, role:admin, role:user.
getRolesForUser("alice") can only get: ["role:admin"].
But getImplicitRolesForUser("alice") will get: ["role:admin", "role:user"].
@param string $name
@return array | [
"gets",
"implicit",
"roles",
"that",
"a",
"user",
"has",
".",
"Compared",
"to",
"getRolesForUser",
"()",
"this",
"function",
"retrieves",
"indirect",
"roles",
"besides",
"direct",
"roles",
".",
"For",
"example",
":",
"g",
"alice",
"role",
":",
"admin",
"g",
... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L239-L263 |
php-casbin/php-casbin | src/RbacApi.php | RbacApi.getImplicitPermissionsForUser | public function getImplicitPermissionsForUser($user)
{
$roles[] = $user;
$roles = array_merge(
$roles,
$this->getImplicitRolesForUser($user)
);
$res = [];
foreach ($roles as $role) {
$permissions = $this->getPermissionsForUser($role);
$res = array_merge($res, $permissions);
}
return $res;
} | php | public function getImplicitPermissionsForUser($user)
{
$roles[] = $user;
$roles = array_merge(
$roles,
$this->getImplicitRolesForUser($user)
);
$res = [];
foreach ($roles as $role) {
$permissions = $this->getPermissionsForUser($role);
$res = array_merge($res, $permissions);
}
return $res;
} | [
"public",
"function",
"getImplicitPermissionsForUser",
"(",
"$",
"user",
")",
"{",
"$",
"roles",
"[",
"]",
"=",
"$",
"user",
";",
"$",
"roles",
"=",
"array_merge",
"(",
"$",
"roles",
",",
"$",
"this",
"->",
"getImplicitRolesForUser",
"(",
"$",
"user",
")... | gets implicit permissions for a user or role.
Compared to getPermissionsForUser(), this function retrieves permissions for inherited roles.
For example:
p, admin, data1, read
p, alice, data2, read
g, alice, admin.
getPermissionsForUser("alice") can only get: [["alice", "data2", "read"]].
But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
@param string $user
@return array | [
"gets",
"implicit",
"permissions",
"for",
"a",
"user",
"or",
"role",
".",
"Compared",
"to",
"getPermissionsForUser",
"()",
"this",
"function",
"retrieves",
"permissions",
"for",
"inherited",
"roles",
".",
"For",
"example",
":",
"p",
"admin",
"data1",
"read",
"... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/RbacApi.php#L280-L295 |
php-casbin/php-casbin | src/Rbac/Role.php | Role.hasRole | public function hasRole($name, $hierarchyLevel)
{
if ($name == $this->name) {
return true;
}
if ($hierarchyLevel <= 0) {
return false;
}
foreach ($this->roles as $role) {
if ($role->hasRole($name, $hierarchyLevel - 1)) {
return true;
}
}
return false;
} | php | public function hasRole($name, $hierarchyLevel)
{
if ($name == $this->name) {
return true;
}
if ($hierarchyLevel <= 0) {
return false;
}
foreach ($this->roles as $role) {
if ($role->hasRole($name, $hierarchyLevel - 1)) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasRole",
"(",
"$",
"name",
",",
"$",
"hierarchyLevel",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"$",
"this",
"->",
"name",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"hierarchyLevel",
"<=",
"0",
")",
"{",
"return",... | @param string $name
@param int $hierarchyLevel
@return bool | [
"@param",
"string",
"$name",
"@param",
"int",
"$hierarchyLevel"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/Role.php#L66-L82 |
php-casbin/php-casbin | src/Rbac/Role.php | Role.hasDirectRole | public function hasDirectRole($name)
{
foreach ($this->roles as $role) {
if ($role->name == $name) {
return true;
}
}
return false;
} | php | public function hasDirectRole($name)
{
foreach ($this->roles as $role) {
if ($role->name == $name) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasDirectRole",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"->",
"name",
"==",
"$",
"name",
")",
"{",
"return",
"true",
";",
"}",
"}",
"retur... | @param string $name
@return bool | [
"@param",
"string",
"$name"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Rbac/Role.php#L89-L98 |
php-casbin/php-casbin | src/CachedEnforcer.php | CachedEnforcer.enforce | public function enforce(...$rvals)
{
if (!$this->enableCache) {
return parent::enforce(...$rvals);
}
$key = '';
foreach ($rvals as $rval) {
if (is_string($rval)) {
$key .= $rval.'$$';
} else {
return parent::enforce(...$rvals);
}
}
if (isset(self::$m[$key])) {
return self::$m[$key];
} else {
$res = parent::enforce(...$rvals);
self::$m[$key] = $res;
return $res;
}
} | php | public function enforce(...$rvals)
{
if (!$this->enableCache) {
return parent::enforce(...$rvals);
}
$key = '';
foreach ($rvals as $rval) {
if (is_string($rval)) {
$key .= $rval.'$$';
} else {
return parent::enforce(...$rvals);
}
}
if (isset(self::$m[$key])) {
return self::$m[$key];
} else {
$res = parent::enforce(...$rvals);
self::$m[$key] = $res;
return $res;
}
} | [
"public",
"function",
"enforce",
"(",
"...",
"$",
"rvals",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enableCache",
")",
"{",
"return",
"parent",
"::",
"enforce",
"(",
"...",
"$",
"rvals",
")",
";",
"}",
"$",
"key",
"=",
"''",
";",
"foreach",
... | Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
if rvals is not string , ingore the cache.
@param mixed ...$rvals
@return bool|mixed
@throws Exceptions\CasbinException | [
"Enforce",
"decides",
"whether",
"a",
"subject",
"can",
"access",
"a",
"object",
"with",
"the",
"operation",
"action",
"input",
"parameters",
"are",
"usually",
":",
"(",
"sub",
"obj",
"act",
")",
".",
"if",
"rvals",
"is",
"not",
"string",
"ingore",
"the",
... | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/CachedEnforcer.php#L61-L84 |
php-casbin/php-casbin | src/Persist/Adapters/FileAdapter.php | FileAdapter.savePolicy | public function savePolicy($model)
{
if ('' == $this->filePath) {
throw new CasbinException('invalid file path, file path cannot be empty');
}
$writeString = '';
if (isset($model->model['p'])) {
foreach ($model->model['p'] as $ptype => $ast) {
foreach ($ast->policy as $rule) {
$writeString .= $ptype.', ';
$writeString .= Util::arrayToString($rule);
$writeString .= PHP_EOL;
}
}
}
if (isset($model->model['g'])) {
foreach ($model->model['g'] as $ptype => $ast) {
foreach ($ast->policy as $rule) {
$writeString .= $ptype.', ';
$writeString .= Util::arrayToString($rule);
$writeString .= PHP_EOL;
}
}
}
return $this->savePolicyFile(rtrim($writeString, PHP_EOL));
} | php | public function savePolicy($model)
{
if ('' == $this->filePath) {
throw new CasbinException('invalid file path, file path cannot be empty');
}
$writeString = '';
if (isset($model->model['p'])) {
foreach ($model->model['p'] as $ptype => $ast) {
foreach ($ast->policy as $rule) {
$writeString .= $ptype.', ';
$writeString .= Util::arrayToString($rule);
$writeString .= PHP_EOL;
}
}
}
if (isset($model->model['g'])) {
foreach ($model->model['g'] as $ptype => $ast) {
foreach ($ast->policy as $rule) {
$writeString .= $ptype.', ';
$writeString .= Util::arrayToString($rule);
$writeString .= PHP_EOL;
}
}
}
return $this->savePolicyFile(rtrim($writeString, PHP_EOL));
} | [
"public",
"function",
"savePolicy",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"''",
"==",
"$",
"this",
"->",
"filePath",
")",
"{",
"throw",
"new",
"CasbinException",
"(",
"'invalid file path, file path cannot be empty'",
")",
";",
"}",
"$",
"writeString",
"=",
... | saves all policy rules to the storage.
@param \Casbin\Model\Model $model
@return bool|int
@throws CasbinException | [
"saves",
"all",
"policy",
"rules",
"to",
"the",
"storage",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Persist/Adapters/FileAdapter.php#L64-L93 |
php-casbin/php-casbin | src/Model/Model.php | Model.loadAssertion | private function loadAssertion($cfg, $sec, $key)
{
$value = $cfg->getString($this->sectionNameMap[$sec].'::'.$key);
return $this->addDef($sec, $key, $value);
} | php | private function loadAssertion($cfg, $sec, $key)
{
$value = $cfg->getString($this->sectionNameMap[$sec].'::'.$key);
return $this->addDef($sec, $key, $value);
} | [
"private",
"function",
"loadAssertion",
"(",
"$",
"cfg",
",",
"$",
"sec",
",",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"cfg",
"->",
"getString",
"(",
"$",
"this",
"->",
"sectionNameMap",
"[",
"$",
"sec",
"]",
".",
"'::'",
".",
"$",
"key",
"... | @param ConfigContract $cfg
@param string $sec
@param string $key
@return bool|void | [
"@param",
"ConfigContract",
"$cfg",
"@param",
"string",
"$sec",
"@param",
"string",
"$key"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Model.php#L43-L48 |
php-casbin/php-casbin | src/Model/Model.php | Model.addDef | public function addDef($sec, $key, $value)
{
if ('' == $value) {
return;
}
$ast = new Assertion();
$ast->key = $key;
$ast->value = $value;
if ('r' == $sec || 'p' == $sec) {
$ast->tokens = explode(', ', $ast->value);
foreach ($ast->tokens as $i => $token) {
$ast->tokens[$i] = $key.'_'.$token;
}
} else {
$ast->value = Util::removeComments(Util::escapeAssertion($ast->value));
}
$this->model[$sec][$key] = $ast;
return true;
} | php | public function addDef($sec, $key, $value)
{
if ('' == $value) {
return;
}
$ast = new Assertion();
$ast->key = $key;
$ast->value = $value;
if ('r' == $sec || 'p' == $sec) {
$ast->tokens = explode(', ', $ast->value);
foreach ($ast->tokens as $i => $token) {
$ast->tokens[$i] = $key.'_'.$token;
}
} else {
$ast->value = Util::removeComments(Util::escapeAssertion($ast->value));
}
$this->model[$sec][$key] = $ast;
return true;
} | [
"public",
"function",
"addDef",
"(",
"$",
"sec",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"''",
"==",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"ast",
"=",
"new",
"Assertion",
"(",
")",
";",
"$",
"ast",
"->",
"key",
"="... | adds an assertion to the model.
@param string $sec
@param string $key
@param mixed $value
@return bool|void | [
"adds",
"an",
"assertion",
"to",
"the",
"model",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Model.php#L59-L80 |
php-casbin/php-casbin | src/Model/Model.php | Model.loadModel | public function loadModel($path)
{
$cfg = Config::newConfig($path);
$this->loadSection($cfg, 'r');
$this->loadSection($cfg, 'p');
$this->loadSection($cfg, 'e');
$this->loadSection($cfg, 'm');
$this->loadSection($cfg, 'g');
} | php | public function loadModel($path)
{
$cfg = Config::newConfig($path);
$this->loadSection($cfg, 'r');
$this->loadSection($cfg, 'p');
$this->loadSection($cfg, 'e');
$this->loadSection($cfg, 'm');
$this->loadSection($cfg, 'g');
} | [
"public",
"function",
"loadModel",
"(",
"$",
"path",
")",
"{",
"$",
"cfg",
"=",
"Config",
"::",
"newConfig",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"loadSection",
"(",
"$",
"cfg",
",",
"'r'",
")",
";",
"$",
"this",
"->",
"loadSection",
"(",... | loads the model from model CONF file.
@param string $path | [
"loads",
"the",
"model",
"from",
"model",
"CONF",
"file",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Model.php#L117-L127 |
php-casbin/php-casbin | src/Model/Model.php | Model.loadModelFromText | public function loadModelFromText($text)
{
$cfg = Config::newConfigFromText($text);
$this->loadSection($cfg, 'r');
$this->loadSection($cfg, 'p');
$this->loadSection($cfg, 'e');
$this->loadSection($cfg, 'm');
$this->loadSection($cfg, 'g');
} | php | public function loadModelFromText($text)
{
$cfg = Config::newConfigFromText($text);
$this->loadSection($cfg, 'r');
$this->loadSection($cfg, 'p');
$this->loadSection($cfg, 'e');
$this->loadSection($cfg, 'm');
$this->loadSection($cfg, 'g');
} | [
"public",
"function",
"loadModelFromText",
"(",
"$",
"text",
")",
"{",
"$",
"cfg",
"=",
"Config",
"::",
"newConfigFromText",
"(",
"$",
"text",
")",
";",
"$",
"this",
"->",
"loadSection",
"(",
"$",
"cfg",
",",
"'r'",
")",
";",
"$",
"this",
"->",
"load... | loads the model from the text.
@param string $text | [
"loads",
"the",
"model",
"from",
"the",
"text",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Model.php#L134-L144 |
php-casbin/php-casbin | src/Model/Model.php | Model.printModel | public function printModel()
{
Log::logPrint('Model:');
foreach ($this->model as $k => $v) {
foreach ($v as $i => $j) {
Log::logPrintf('%s.%s: %s', $k, $i, $j->value);
}
}
} | php | public function printModel()
{
Log::logPrint('Model:');
foreach ($this->model as $k => $v) {
foreach ($v as $i => $j) {
Log::logPrintf('%s.%s: %s', $k, $i, $j->value);
}
}
} | [
"public",
"function",
"printModel",
"(",
")",
"{",
"Log",
"::",
"logPrint",
"(",
"'Model:'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"model",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"$",
"v",
"as",
"$",
"i",
"=>",
"$",
"j... | prints the model to the log. | [
"prints",
"the",
"model",
"to",
"the",
"log",
"."
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Model.php#L149-L157 |
php-casbin/php-casbin | src/Model/Assertion.php | Assertion.buildRoleLinks | public function buildRoleLinks(RoleManager $rm)
{
$this->rM = $rm;
$count = substr_count($this->value, '_');
foreach ($this->policy as $rule) {
if ($count < 2) {
throw new CasbinException('the number of "_" in role definition should be at least 2');
}
if (\count($rule) < $count) {
throw new CasbinException('grouping policy elements do not meet role definition');
}
if (2 == $count) {
$this->rM->addLink($rule[0], $rule[1]);
} elseif (3 == $count) {
$this->rM->addLink($rule[0], $rule[1], $rule[2]);
} elseif (4 == $count) {
$this->rM->addLink($rule[0], $rule[1], $rule[2], $rule[3]);
}
}
Log::logPrint('Role links for: '.$this->key);
$this->rM->printRoles();
} | php | public function buildRoleLinks(RoleManager $rm)
{
$this->rM = $rm;
$count = substr_count($this->value, '_');
foreach ($this->policy as $rule) {
if ($count < 2) {
throw new CasbinException('the number of "_" in role definition should be at least 2');
}
if (\count($rule) < $count) {
throw new CasbinException('grouping policy elements do not meet role definition');
}
if (2 == $count) {
$this->rM->addLink($rule[0], $rule[1]);
} elseif (3 == $count) {
$this->rM->addLink($rule[0], $rule[1], $rule[2]);
} elseif (4 == $count) {
$this->rM->addLink($rule[0], $rule[1], $rule[2], $rule[3]);
}
}
Log::logPrint('Role links for: '.$this->key);
$this->rM->printRoles();
} | [
"public",
"function",
"buildRoleLinks",
"(",
"RoleManager",
"$",
"rm",
")",
"{",
"$",
"this",
"->",
"rM",
"=",
"$",
"rm",
";",
"$",
"count",
"=",
"substr_count",
"(",
"$",
"this",
"->",
"value",
",",
"'_'",
")",
";",
"foreach",
"(",
"$",
"this",
"-... | @param RoleManager $rm
@throws CasbinException | [
"@param",
"RoleManager",
"$rm"
] | train | https://github.com/php-casbin/php-casbin/blob/7dce1785af3d927dc725f35a82b38e97e19b0089/src/Model/Assertion.php#L57-L81 |
maschmann/php-ansible | Ansible/Command/AnsibleGalaxy.php | AnsibleGalaxy.install | public function install($roles = ''): AnsibleGalaxyInterface
{
$roles = $this->checkParam($roles, ' ');
$this->addBaseoption('install');
if ('' !== $roles) {
$this->addBaseoption($roles);
}
return $this;
} | php | public function install($roles = ''): AnsibleGalaxyInterface
{
$roles = $this->checkParam($roles, ' ');
$this->addBaseoption('install');
if ('' !== $roles) {
$this->addBaseoption($roles);
}
return $this;
} | [
"public",
"function",
"install",
"(",
"$",
"roles",
"=",
"''",
")",
":",
"AnsibleGalaxyInterface",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"roles",
",",
"' '",
")",
";",
"$",
"this",
"->",
"addBaseoption",
"(",
"'install'",
"... | Install packages.
If you are unsure whether the role(s) is already installed,
either check first or use the "force" option.
@param string|array $roles role_name(s)[,version] | scm+role_repo_url[,version]
@return AnsibleGalaxyInterface | [
"Install",
"packages",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsibleGalaxy.php#L76-L87 |
maschmann/php-ansible | Ansible/Command/AnsibleGalaxy.php | AnsibleGalaxy.modulelist | public function modulelist(string $roleName = ''): AnsibleGalaxyInterface
{
$this->addBaseoption('list');
if ('' !== $roleName) {
$this->addBaseoption($roleName);
}
return $this;
} | php | public function modulelist(string $roleName = ''): AnsibleGalaxyInterface
{
$this->addBaseoption('list');
if ('' !== $roleName) {
$this->addBaseoption($roleName);
}
return $this;
} | [
"public",
"function",
"modulelist",
"(",
"string",
"$",
"roleName",
"=",
"''",
")",
":",
"AnsibleGalaxyInterface",
"{",
"$",
"this",
"->",
"addBaseoption",
"(",
"'list'",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"roleName",
")",
"{",
"$",
"this",
"->",
"... | Get a list of installed modules.
@param string $roleName
@return AnsibleGalaxyInterface | [
"Get",
"a",
"list",
"of",
"installed",
"modules",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsibleGalaxy.php#L95-L104 |
maschmann/php-ansible | Ansible/Command/AnsibleGalaxy.php | AnsibleGalaxy.remove | public function remove($roles = ''): AnsibleGalaxyInterface
{
$roles = $this->checkParam($roles, ' ');
$this
->addBaseoption('remove')
->addBaseoption($roles);
return $this;
} | php | public function remove($roles = ''): AnsibleGalaxyInterface
{
$roles = $this->checkParam($roles, ' ');
$this
->addBaseoption('remove')
->addBaseoption($roles);
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"roles",
"=",
"''",
")",
":",
"AnsibleGalaxyInterface",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"roles",
",",
"' '",
")",
";",
"$",
"this",
"->",
"addBaseoption",
"(",
"'remove'",
")"... | Add package(s)
@param string|array $roles
@return AnsibleGalaxyInterface | [
"Add",
"package",
"(",
"s",
")"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsibleGalaxy.php#L112-L121 |
maschmann/php-ansible | Ansible/Command/AbstractAnsibleCommand.php | AbstractAnsibleCommand.prepareArguments | protected function prepareArguments(bool $asArray = true)
{
$arguments = array_merge(
[$this->getBaseOptions()],
$this->getOptions(),
$this->getParameters()
);
if (false === $asArray) {
$arguments = implode(' ', $arguments);
}
return $arguments;
} | php | protected function prepareArguments(bool $asArray = true)
{
$arguments = array_merge(
[$this->getBaseOptions()],
$this->getOptions(),
$this->getParameters()
);
if (false === $asArray) {
$arguments = implode(' ', $arguments);
}
return $arguments;
} | [
"protected",
"function",
"prepareArguments",
"(",
"bool",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"arguments",
"=",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"getBaseOptions",
"(",
")",
"]",
",",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
"$... | Get parameter string which will be used to call ansible.
@param bool $asArray
@return string|array | [
"Get",
"parameter",
"string",
"which",
"will",
"be",
"used",
"to",
"call",
"ansible",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AbstractAnsibleCommand.php#L60-L73 |
maschmann/php-ansible | Ansible/Command/AbstractAnsibleCommand.php | AbstractAnsibleCommand.addOption | protected function addOption(string $name, string $value): void
{
$this->options[$name] = $value;
} | php | protected function addOption(string $name, string $value): void
{
$this->options[$name] = $value;
} | [
"protected",
"function",
"addOption",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] | Add an Option.
@param string $name
@param string $value | [
"Add",
"an",
"Option",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AbstractAnsibleCommand.php#L81-L84 |
maschmann/php-ansible | Ansible/Command/AbstractAnsibleCommand.php | AbstractAnsibleCommand.getOptions | protected function getOptions(): array
{
$options = [];
foreach ($this->options as $name => $value) {
$options[] = $name . '=' . $value;
}
return $options;
} | php | protected function getOptions(): array
{
$options = [];
foreach ($this->options as $name => $value) {
$options[] = $name . '=' . $value;
}
return $options;
} | [
"protected",
"function",
"getOptions",
"(",
")",
":",
"array",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"name",
"."... | Get all options as array.
@return array | [
"Get",
"all",
"options",
"as",
"array",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AbstractAnsibleCommand.php#L101-L110 |
maschmann/php-ansible | Ansible/Command/AbstractAnsibleCommand.php | AbstractAnsibleCommand.checkParam | protected function checkParam($param, string $glue = ' '): string
{
if (is_array($param)) {
$param = implode($glue, $param);
}
return $param;
} | php | protected function checkParam($param, string $glue = ' '): string
{
if (is_array($param)) {
$param = implode($glue, $param);
}
return $param;
} | [
"protected",
"function",
"checkParam",
"(",
"$",
"param",
",",
"string",
"$",
"glue",
"=",
"' '",
")",
":",
"string",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
")",
"{",
"$",
"param",
"=",
"implode",
"(",
"$",
"glue",
",",
"$",
"param",
... | Check if param is array or string and implode with glue if necessary.
@param string|array $param
@param string $glue
@return string | [
"Check",
"if",
"param",
"is",
"array",
"or",
"string",
"and",
"implode",
"with",
"glue",
"if",
"necessary",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AbstractAnsibleCommand.php#L153-L160 |
maschmann/php-ansible | Ansible/Command/AbstractAnsibleCommand.php | AbstractAnsibleCommand.runProcess | protected function runProcess($callback = null)
{
$process = $this->processBuilder
->setArguments(
$this->prepareArguments()
)
->getProcess();
// exit code
$result = $process->run($callback);
// text-mode
if (null === $callback) {
$result = $process->getOutput();
if (false === $process->isSuccessful()) {
$process->getErrorOutput();
}
}
return $result;
} | php | protected function runProcess($callback = null)
{
$process = $this->processBuilder
->setArguments(
$this->prepareArguments()
)
->getProcess();
// exit code
$result = $process->run($callback);
// text-mode
if (null === $callback) {
$result = $process->getOutput();
if (false === $process->isSuccessful()) {
$process->getErrorOutput();
}
}
return $result;
} | [
"protected",
"function",
"runProcess",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"processBuilder",
"->",
"setArguments",
"(",
"$",
"this",
"->",
"prepareArguments",
"(",
")",
")",
"->",
"getProcess",
"(",
")",
"... | Creates process with processBuilder builder and executes it.
@param callable|null $callback
@return int|string | [
"Creates",
"process",
"with",
"processBuilder",
"builder",
"and",
"executes",
"it",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AbstractAnsibleCommand.php#L168-L189 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.