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
yiisoft/yii-console
src/Controllers/MigrateController.php
MigrateController.beforeAction
public function beforeAction(Action $action): bool { if (parent::beforeAction($action)) { $this->db = Yii::ensureObject($this->db, Connection::class); return true; } return false; }
php
public function beforeAction(Action $action): bool { if (parent::beforeAction($action)) { $this->db = Yii::ensureObject($this->db, Connection::class); return true; } return false; }
[ "public", "function", "beforeAction", "(", "Action", "$", "action", ")", ":", "bool", "{", "if", "(", "parent", "::", "beforeAction", "(", "$", "action", ")", ")", "{", "$", "this", "->", "db", "=", "Yii", "::", "ensureObject", "(", "$", "this", "->"...
This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]]. @param \yii\base\Action $action the action to be executed. @return bool whether the action should continue to be executed.
[ "This", "method", "is", "invoked", "right", "before", "an", "action", "is", "to", "be", "executed", "(", "after", "all", "possible", "filters", ".", ")", "It", "checks", "the", "existence", "of", "the", "[[", "migrationPath", "]]", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MigrateController.php#L179-L187
yiisoft/yii-console
src/Controllers/MigrateController.php
MigrateController.createMigration
protected function createMigration($class) { $this->includeMigrationFile($class); return $this->app->createObject([ '__class' => $class, 'db' => $this->db, 'compact' => $this->compact, ]); }
php
protected function createMigration($class) { $this->includeMigrationFile($class); return $this->app->createObject([ '__class' => $class, 'db' => $this->db, 'compact' => $this->compact, ]); }
[ "protected", "function", "createMigration", "(", "$", "class", ")", "{", "$", "this", "->", "includeMigrationFile", "(", "$", "class", ")", ";", "return", "$", "this", "->", "app", "->", "createObject", "(", "[", "'__class'", "=>", "$", "class", ",", "'d...
Creates a new migration instance. @param string $class the migration class name @return \Yiisoft\Db\Migration the migration instance
[ "Creates", "a", "new", "migration", "instance", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MigrateController.php#L194-L203
yiisoft/yii-console
src/Controllers/MigrateController.php
MigrateController.truncateDatabase
protected function truncateDatabase() { $db = $this->db; $schemas = $db->schema->getTableSchemas(); // First drop all foreign keys, foreach ($schemas as $schema) { if ($schema->foreignKeys) { foreach ($schema->foreignKeys as $name => $foreignKey) { ...
php
protected function truncateDatabase() { $db = $this->db; $schemas = $db->schema->getTableSchemas(); // First drop all foreign keys, foreach ($schemas as $schema) { if ($schema->foreignKeys) { foreach ($schema->foreignKeys as $name => $foreignKey) { ...
[ "protected", "function", "truncateDatabase", "(", ")", "{", "$", "db", "=", "$", "this", "->", "db", ";", "$", "schemas", "=", "$", "db", "->", "schema", "->", "getTableSchemas", "(", ")", ";", "// First drop all foreign keys,", "foreach", "(", "$", "schem...
{@inheritdoc} @since 2.0.13
[ "{" ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MigrateController.php#L296-L316
yiisoft/yii-jquery
src/Validators/Client/UrlValidator.php
UrlValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { if (strpos($validator->pattern, '{schemes}') !== false) { $pattern = str_replace('{schemes}', '(' . implode('|', $validator->validSchemes) . ')', $validator->pattern); } else { $pattern = $validator->pattern; ...
php
public function getClientOptions($validator, $model, $attribute) { if (strpos($validator->pattern, '{schemes}') !== false) { $pattern = str_replace('{schemes}', '(' . implode('|', $validator->validSchemes) . ')', $validator->pattern); } else { $pattern = $validator->pattern; ...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "if", "(", "strpos", "(", "$", "validator", "->", "pattern", ",", "'{schemes}'", ")", "!==", "false", ")", "{", "$", "pattern", "=", "s...
Returns the client-side validation options. @param \yii\validators\UrlValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/UrlValidator.php#L48-L71
yiisoft/yii-jquery
src/Validators/Client/FileValidator.php
FileValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = []; if ($validator->message !== null) { $options['message'] = $validator->formatMessage($validator->message, [ 'attribute' => $label, ...
php
public function getClientOptions($validator, $model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = []; if ($validator->message !== null) { $options['message'] = $validator->formatMessage($validator->message, [ 'attribute' => $label, ...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "label", "=", "$", "model", "->", "getAttributeLabel", "(", "$", "attribute", ")", ";", "$", "options", "=", "[", "]", ";", "if", ...
Returns the client-side validation options. @param \yii\validators\FileValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/FileValidator.php#L45-L111
yiisoft/yii-jquery
src/Validators/Client/RangeValidator.php
RangeValidator.build
public function build($validator, $model, $attribute, $view) { /* @var $validator \yii\validators\RangeValidator */ if ($validator->range instanceof \Closure) { $validator->range = call_user_func($validator->range, $model, $attribute); } ValidationAsset::register($view); ...
php
public function build($validator, $model, $attribute, $view) { /* @var $validator \yii\validators\RangeValidator */ if ($validator->range instanceof \Closure) { $validator->range = call_user_func($validator->range, $model, $attribute); } ValidationAsset::register($view); ...
[ "public", "function", "build", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ",", "$", "view", ")", "{", "/* @var $validator \\yii\\validators\\RangeValidator */", "if", "(", "$", "validator", "->", "range", "instanceof", "\\", "Closure", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/RangeValidator.php#L27-L36
yiisoft/yii-jquery
src/Validators/Client/RangeValidator.php
RangeValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $range = []; foreach ($validator->range as $value) { $range[] = (string) $value; } $options = [ 'range' => $range, 'not' => $validator->not, 'message' => $validator->for...
php
public function getClientOptions($validator, $model, $attribute) { $range = []; foreach ($validator->range as $value) { $range[] = (string) $value; } $options = [ 'range' => $range, 'not' => $validator->not, 'message' => $validator->for...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "range", "=", "[", "]", ";", "foreach", "(", "$", "validator", "->", "range", "as", "$", "value", ")", "{", "$", "range", "[", ...
Returns the client-side validation options. @param \yii\validators\RangeValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/RangeValidator.php#L45-L66
yiisoft/yii-jquery
src/Validators/Client/EmailValidator.php
EmailValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $options = [ 'pattern' => new JsExpression($validator->pattern), 'fullPattern' => new JsExpression($validator->fullPattern), 'allowName' => $validator->allowName, 'message' => $validator->forma...
php
public function getClientOptions($validator, $model, $attribute) { $options = [ 'pattern' => new JsExpression($validator->pattern), 'fullPattern' => new JsExpression($validator->fullPattern), 'allowName' => $validator->allowName, 'message' => $validator->forma...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "options", "=", "[", "'pattern'", "=>", "new", "JsExpression", "(", "$", "validator", "->", "pattern", ")", ",", "'fullPattern'", "=>"...
Returns the client-side validation options. @param \yii\validators\EmailValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/EmailValidator.php#L48-L64
yiisoft/yii-jquery
src/Validators/Client/ImageValidator.php
ImageValidator.build
public function build($validator, $model, $attribute, $view) { ValidationAsset::register($view); $options = $this->getClientOptions($validator, $model, $attribute); return 'yii.validation.image(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ...
php
public function build($validator, $model, $attribute, $view) { ValidationAsset::register($view); $options = $this->getClientOptions($validator, $model, $attribute); return 'yii.validation.image(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ...
[ "public", "function", "build", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ",", "$", "view", ")", "{", "ValidationAsset", "::", "register", "(", "$", "view", ")", ";", "$", "options", "=", "$", "this", "->", "getClientOptions", "("...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/ImageValidator.php#L26-L31
yiisoft/yii-jquery
src/Validators/Client/ImageValidator.php
ImageValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $options = parent::getClientOptions($validator, $model, $attribute); $label = $model->getAttributeLabel($attribute); if ($validator->notImage !== null) { $options['notImage'] = $validator->formatMessage($validat...
php
public function getClientOptions($validator, $model, $attribute) { $options = parent::getClientOptions($validator, $model, $attribute); $label = $model->getAttributeLabel($attribute); if ($validator->notImage !== null) { $options['notImage'] = $validator->formatMessage($validat...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "options", "=", "parent", "::", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", ";", "$", ...
Returns the client-side validation options. @param \yii\validators\ImageValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/ImageValidator.php#L40-L85
yiisoft/yii-jquery
src/Validators/Client/StringValidator.php
StringValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = [ 'message' => $validator->formatMessage($validator->message, [ 'attribute' => $label, ]), ]; if ($validator->min !=...
php
public function getClientOptions($validator, $model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = [ 'message' => $validator->formatMessage($validator->message, [ 'attribute' => $label, ]), ]; if ($validator->min !=...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "label", "=", "$", "model", "->", "getAttributeLabel", "(", "$", "attribute", ")", ";", "$", "options", "=", "[", "'message'", "=>",...
Returns the client-side validation options. @param \yii\validators\StringValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/StringValidator.php#L41-L77
yiisoft/yii-console
src/Controllers/HelpController.php
HelpController.getCommands
public function getCommands() { $commands = $this->getModuleCommands($this->app); sort($commands); return array_unique($commands); }
php
public function getCommands() { $commands = $this->getModuleCommands($this->app); sort($commands); return array_unique($commands); }
[ "public", "function", "getCommands", "(", ")", "{", "$", "commands", "=", "$", "this", "->", "getModuleCommands", "(", "$", "this", "->", "app", ")", ";", "sort", "(", "$", "commands", ")", ";", "return", "array_unique", "(", "$", "commands", ")", ";",...
Returns all available command names. @return array all available command names
[ "Returns", "all", "available", "command", "names", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/HelpController.php#L173-L178
yiisoft/yii-console
src/Controllers/HelpController.php
HelpController.getCommandDescriptions
protected function getCommandDescriptions() { $descriptions = []; foreach ($this->getCommands() as $command) { $description = ''; $result = $this->app->createController($command); if ($result !== false && $result[0] instanceof Controller) { [$cont...
php
protected function getCommandDescriptions() { $descriptions = []; foreach ($this->getCommands() as $command) { $description = ''; $result = $this->app->createController($command); if ($result !== false && $result[0] instanceof Controller) { [$cont...
[ "protected", "function", "getCommandDescriptions", "(", ")", "{", "$", "descriptions", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getCommands", "(", ")", "as", "$", "command", ")", "{", "$", "description", "=", "''", ";", "$", "result", "=...
Returns an array of commands an their descriptions. @return array all available commands as keys and their description as values.
[ "Returns", "an", "array", "of", "commands", "an", "their", "descriptions", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/HelpController.php#L184-L201
yiisoft/yii-console
src/Controllers/HelpController.php
HelpController.getModuleCommands
protected function getModuleCommands($module) { $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/'; $commands = []; foreach (array_keys($module->controllerMap) as $id) { $commands[] = $prefix . $id; } foreach ($module->getModules() as $...
php
protected function getModuleCommands($module) { $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/'; $commands = []; foreach (array_keys($module->controllerMap) as $id) { $commands[] = $prefix . $id; } foreach ($module->getModules() as $...
[ "protected", "function", "getModuleCommands", "(", "$", "module", ")", "{", "$", "prefix", "=", "$", "module", "instanceof", "Application", "?", "''", ":", "$", "module", "->", "getUniqueId", "(", ")", ".", "'/'", ";", "$", "commands", "=", "[", "]", "...
Returns available commands of a specified module. @param \yii\base\Module $module the module instance @return array the available command names
[ "Returns", "available", "commands", "of", "a", "specified", "module", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/HelpController.php#L228-L271
yiisoft/yii-console
src/Controllers/HelpController.php
HelpController.validateControllerClass
protected function validateControllerClass($controllerClass) { if (class_exists($controllerClass)) { $class = new \ReflectionClass($controllerClass); return !$class->isAbstract() && $class->isSubclassOf(Controller::class); } return false; }
php
protected function validateControllerClass($controllerClass) { if (class_exists($controllerClass)) { $class = new \ReflectionClass($controllerClass); return !$class->isAbstract() && $class->isSubclassOf(Controller::class); } return false; }
[ "protected", "function", "validateControllerClass", "(", "$", "controllerClass", ")", "{", "if", "(", "class_exists", "(", "$", "controllerClass", ")", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "controllerClass", ")", ";", "return"...
Validates if the given class is a valid console controller class. @param string $controllerClass @return bool
[ "Validates", "if", "the", "given", "class", "is", "a", "valid", "console", "controller", "class", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/HelpController.php#L278-L286
yiisoft/yii-console
src/Widgets/Table.php
Table.renderRow
protected function renderRow(array $row, $spanLeft, $spanMiddle, $spanRight) { $size = $this->_columnWidths; $buffer = ''; $arrayPointer = []; $finalChunk = []; for ($i = 0, ($max = $this->calculateRowHeight($row)) ?: $max = 1; $i < $max; $i++) { $buffer .= $span...
php
protected function renderRow(array $row, $spanLeft, $spanMiddle, $spanRight) { $size = $this->_columnWidths; $buffer = ''; $arrayPointer = []; $finalChunk = []; for ($i = 0, ($max = $this->calculateRowHeight($row)) ?: $max = 1; $i < $max; $i++) { $buffer .= $span...
[ "protected", "function", "renderRow", "(", "array", "$", "row", ",", "$", "spanLeft", ",", "$", "spanMiddle", ",", "$", "spanRight", ")", "{", "$", "size", "=", "$", "this", "->", "_columnWidths", ";", "$", "buffer", "=", "''", ";", "$", "arrayPointer"...
Renders a row of data into a string. @param array $row row of data @param string $spanLeft character for left border @param string $spanMiddle character for middle border @param string $spanRight character for right border @return string @see \Yiisoft\Yii\Console\Widgets\Table::render()
[ "Renders", "a", "row", "of", "data", "into", "a", "string", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Widgets/Table.php#L223-L269
yiisoft/yii-console
src/Widgets/Table.php
Table.calculateRowsSize
protected function calculateRowsSize() { $this->_columnWidths = $columns = []; $totalWidth = 0; $screenWidth = $this->getScreenWidth() - self::CONSOLE_SCROLLBAR_OFFSET; for ($i = 0, $count = count($this->_headers); $i < $count; $i++) { $columns[] = ArrayHelper::getColumn...
php
protected function calculateRowsSize() { $this->_columnWidths = $columns = []; $totalWidth = 0; $screenWidth = $this->getScreenWidth() - self::CONSOLE_SCROLLBAR_OFFSET; for ($i = 0, $count = count($this->_headers); $i < $count; $i++) { $columns[] = ArrayHelper::getColumn...
[ "protected", "function", "calculateRowsSize", "(", ")", "{", "$", "this", "->", "_columnWidths", "=", "$", "columns", "=", "[", "]", ";", "$", "totalWidth", "=", "0", ";", "$", "screenWidth", "=", "$", "this", "->", "getScreenWidth", "(", ")", "-", "se...
Calculate the size of rows to draw anchor of columns in console. @see \Yiisoft\Yii\Console\Widgets\Table::render()
[ "Calculate", "the", "size", "of", "rows", "to", "draw", "anchor", "of", "columns", "in", "console", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Widgets/Table.php#L299-L334
yiisoft/yii-console
src/Widgets/Table.php
Table.calculateRowHeight
protected function calculateRowHeight($row) { $rowsPerCell = array_map(function ($size, $columnWidth) { if (is_array($columnWidth)) { $rows = 0; foreach ($columnWidth as $width) { $rows += ceil($width / ($size - 2)); } ...
php
protected function calculateRowHeight($row) { $rowsPerCell = array_map(function ($size, $columnWidth) { if (is_array($columnWidth)) { $rows = 0; foreach ($columnWidth as $width) { $rows += ceil($width / ($size - 2)); } ...
[ "protected", "function", "calculateRowHeight", "(", "$", "row", ")", "{", "$", "rowsPerCell", "=", "array_map", "(", "function", "(", "$", "size", ",", "$", "columnWidth", ")", "{", "if", "(", "is_array", "(", "$", "columnWidth", ")", ")", "{", "$", "r...
Calculate the height of a row. @param array $row @return int maximum row per cell @see \Yiisoft\Yii\Console\Widgets\Table::render()
[ "Calculate", "the", "height", "of", "a", "row", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Widgets/Table.php#L343-L367
yiisoft/yii-console
src/Widgets/Table.php
Table.getScreenWidth
protected function getScreenWidth() { if (!$this->_screenWidth) { $size = Console::getScreenSize(); $this->_screenWidth = $size[0] ?? self::DEFAULT_CONSOLE_SCREEN_WIDTH + self::CONSOLE_SCROLLBAR_OFFSET; } return $this->_screenWidth; }
php
protected function getScreenWidth() { if (!$this->_screenWidth) { $size = Console::getScreenSize(); $this->_screenWidth = $size[0] ?? self::DEFAULT_CONSOLE_SCREEN_WIDTH + self::CONSOLE_SCROLLBAR_OFFSET; } return $this->_screenWidth; }
[ "protected", "function", "getScreenWidth", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_screenWidth", ")", "{", "$", "size", "=", "Console", "::", "getScreenSize", "(", ")", ";", "$", "this", "->", "_screenWidth", "=", "$", "size", "[", "0", "...
Getting screen width. If it is not able to determine screen width, default value `123` will be set. @return int screen width
[ "Getting", "screen", "width", ".", "If", "it", "is", "not", "able", "to", "determine", "screen", "width", "default", "value", "123", "will", "be", "set", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Widgets/Table.php#L375-L383
yiisoft/yii-jquery
src/Validators/Client/BooleanValidator.php
BooleanValidator.getClientOptions
public function getClientOptions($validator, $model, $attribute) { $options = [ 'trueValue' => $validator->trueValue, 'falseValue' => $validator->falseValue, 'message' => $validator->formatMessage($validator->message, [ 'attribute' => $model->getAttributeL...
php
public function getClientOptions($validator, $model, $attribute) { $options = [ 'trueValue' => $validator->trueValue, 'falseValue' => $validator->falseValue, 'message' => $validator->formatMessage($validator->message, [ 'attribute' => $model->getAttributeL...
[ "public", "function", "getClientOptions", "(", "$", "validator", ",", "$", "model", ",", "$", "attribute", ")", "{", "$", "options", "=", "[", "'trueValue'", "=>", "$", "validator", "->", "trueValue", ",", "'falseValue'", "=>", "$", "validator", "->", "fal...
Returns the client-side validation options. @param \yii\validators\BooleanValidator $validator the server-side validator. @param \yii\base\Model $model the model being validated @param string $attribute the attribute name being validated @return array the client-side validation options
[ "Returns", "the", "client", "-", "side", "validation", "options", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/Validators/Client/BooleanValidator.php#L41-L60
yiisoft/yii-console
src/Exceptions/UnknownCommandException.php
UnknownCommandException.getSuggestedAlternatives
public function getSuggestedAlternatives() { $help = $this->application->createController('help'); if ($help === false || $this->command === '') { return []; } /** @var $helpController HelpController */ [$helpController, $actionID] = $help; $availableActi...
php
public function getSuggestedAlternatives() { $help = $this->application->createController('help'); if ($help === false || $this->command === '') { return []; } /** @var $helpController HelpController */ [$helpController, $actionID] = $help; $availableActi...
[ "public", "function", "getSuggestedAlternatives", "(", ")", "{", "$", "help", "=", "$", "this", "->", "application", "->", "createController", "(", "'help'", ")", ";", "if", "(", "$", "help", "===", "false", "||", "$", "this", "->", "command", "===", "''...
Suggest alternative commands for [[$command]] based on string similarity. Alternatives are searched using the following steps: - suggest alternatives that begin with `$command` - find typos by calculating the Levenshtein distance between the unknown command and all available commands. The Levenshtein distance is defi...
[ "Suggest", "alternative", "commands", "for", "[[", "$command", "]]", "based", "on", "string", "similarity", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Exceptions/UnknownCommandException.php#L68-L99
yiisoft/yii-console
src/Exceptions/UnknownCommandException.php
UnknownCommandException.filterBySimilarity
private function filterBySimilarity($actions, $command) { $alternatives = []; // suggest alternatives that begin with $command first foreach ($actions as $action) { if (strpos($action, $command) === 0) { $alternatives[] = $action; } } ...
php
private function filterBySimilarity($actions, $command) { $alternatives = []; // suggest alternatives that begin with $command first foreach ($actions as $action) { if (strpos($action, $command) === 0) { $alternatives[] = $action; } } ...
[ "private", "function", "filterBySimilarity", "(", "$", "actions", ",", "$", "command", ")", "{", "$", "alternatives", "=", "[", "]", ";", "// suggest alternatives that begin with $command first", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if...
Find suggest alternative commands based on string similarity. Alternatives are searched using the following steps: - suggest alternatives that begin with `$command` - find typos by calculating the Levenshtein distance between the unknown command and all available commands. The Levenshtein distance is defined as the m...
[ "Find", "suggest", "alternative", "commands", "based", "on", "string", "similarity", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Exceptions/UnknownCommandException.php#L116-L142
yiisoft/yii-console
src/Controllers/MessageController.php
MessageController.actionConfig
public function actionConfig($filePath) { $filePath = $this->app->getAlias($filePath); if (file_exists($filePath)) { if (!$this->confirm("File '{$filePath}' already exists. Do you wish to overwrite it?")) { return ExitCode::OK; } } $array = Va...
php
public function actionConfig($filePath) { $filePath = $this->app->getAlias($filePath); if (file_exists($filePath)) { if (!$this->confirm("File '{$filePath}' already exists. Do you wish to overwrite it?")) { return ExitCode::OK; } } $array = Va...
[ "public", "function", "actionConfig", "(", "$", "filePath", ")", "{", "$", "filePath", "=", "$", "this", "->", "app", "->", "getAlias", "(", "$", "filePath", ")", ";", "if", "(", "file_exists", "(", "$", "filePath", ")", ")", "{", "if", "(", "!", "...
Creates a configuration file for the "extract" command using command line options specified. The generated configuration file contains parameters required for source code messages extraction. You may use this configuration file with the "extract" command. @param string $filePath output file name or alias. @return int...
[ "Creates", "a", "configuration", "file", "for", "the", "extract", "command", "using", "command", "line", "options", "specified", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MessageController.php#L217-L250
yiisoft/yii-console
src/Controllers/MessageController.php
MessageController.saveMessagesToPHP
protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused) { foreach ($messages as $category => $msgs) { $file = str_replace('\\', '/', "$dirName/$category.php"); $path = dirname($file); FileHelper::createDirectory($path); ...
php
protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused) { foreach ($messages as $category => $msgs) { $file = str_replace('\\', '/', "$dirName/$category.php"); $path = dirname($file); FileHelper::createDirectory($path); ...
[ "protected", "function", "saveMessagesToPHP", "(", "$", "messages", ",", "$", "dirName", ",", "$", "overwrite", ",", "$", "removeUnused", ",", "$", "sort", ",", "$", "markUnused", ")", "{", "foreach", "(", "$", "messages", "as", "$", "category", "=>", "$...
Writes messages into PHP files. @param array $messages @param string $dirName name of the directory to write to @param bool $overwrite if existing file should be overwritten without backup @param bool $removeUnused if obsolete translations should be removed @param bool $sort if translations should be sorted @param boo...
[ "Writes", "messages", "into", "PHP", "files", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MessageController.php#L649-L660
yiisoft/yii-console
src/Controllers/MessageController.php
MessageController.saveMessagesCategoryToPHP
protected function saveMessagesCategoryToPHP($messages, $fileName, $overwrite, $removeUnused, $sort, $category, $markUnused) { if (is_file($fileName)) { $rawExistingMessages = require $fileName; $existingMessages = $rawExistingMessages; sort($messages); ksort(...
php
protected function saveMessagesCategoryToPHP($messages, $fileName, $overwrite, $removeUnused, $sort, $category, $markUnused) { if (is_file($fileName)) { $rawExistingMessages = require $fileName; $existingMessages = $rawExistingMessages; sort($messages); ksort(...
[ "protected", "function", "saveMessagesCategoryToPHP", "(", "$", "messages", ",", "$", "fileName", ",", "$", "overwrite", ",", "$", "removeUnused", ",", "$", "sort", ",", "$", "category", ",", "$", "markUnused", ")", "{", "if", "(", "is_file", "(", "$", "...
Writes category messages into PHP file. @param array $messages @param string $fileName name of the file to write to @param bool $overwrite if existing file should be overwritten without backup @param bool $removeUnused if obsolete translations should be removed @param bool $sort if translations should be sorted @param...
[ "Writes", "category", "messages", "into", "PHP", "file", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/MessageController.php#L674-L742
yiisoft/yii-console
src/Controllers/BaseMigrateController.php
BaseMigrateController.getNewMigrations
protected function getNewMigrations() { $applied = []; foreach ($this->getMigrationHistory(null) as $class => $time) { $applied[trim($class, '\\')] = true; } $migrationPaths = []; if (is_array($this->migrationPath)) { foreach ($this->migrationPath as ...
php
protected function getNewMigrations() { $applied = []; foreach ($this->getMigrationHistory(null) as $class => $time) { $applied[trim($class, '\\')] = true; } $migrationPaths = []; if (is_array($this->migrationPath)) { foreach ($this->migrationPath as ...
[ "protected", "function", "getNewMigrations", "(", ")", "{", "$", "applied", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getMigrationHistory", "(", "null", ")", "as", "$", "class", "=>", "$", "time", ")", "{", "$", "applied", "[", "trim", ...
Returns the migrations that are not applied. @return array list of new migrations
[ "Returns", "the", "migrations", "that", "are", "not", "applied", "." ]
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/BaseMigrateController.php#L873-L920
yiisoft/yii-console
src/Controllers/BaseMigrateController.php
BaseMigrateController.generateMigrationSourceCode
protected function generateMigrationSourceCode($params) { return $this->renderFile($this->app->getAlias($this->templateFile), $params); }
php
protected function generateMigrationSourceCode($params) { return $this->renderFile($this->app->getAlias($this->templateFile), $params); }
[ "protected", "function", "generateMigrationSourceCode", "(", "$", "params", ")", "{", "return", "$", "this", "->", "renderFile", "(", "$", "this", "->", "app", "->", "getAlias", "(", "$", "this", "->", "templateFile", ")", ",", "$", "params", ")", ";", "...
Generates new migration source PHP code. Child class may override this method, adding extra logic or variation to the process. @param array $params generation parameters, usually following parameters are present: - name: string migration base name - className: string migration class name @return string generated PHP ...
[ "Generates", "new", "migration", "source", "PHP", "code", ".", "Child", "class", "may", "override", "this", "method", "adding", "extra", "logic", "or", "variation", "to", "the", "process", ".", "@param", "array", "$params", "generation", "parameters", "usually",...
train
https://github.com/yiisoft/yii-console/blob/b9fb24f8897b4389935738f63b28d82b7e25cc41/src/Controllers/BaseMigrateController.php#L933-L936
yiisoft/yii-jquery
src/GridViewClientScript.php
GridViewClientScript.beforeRun
public function beforeRun($event) { $id = $this->owner->options['id']; $options = Json::htmlEncode($this->getClientOptions()); $view = $this->owner->getView(); GridViewAsset::register($view); $view->registerJs("jQuery('#$id').yiiGridView($options);"); }
php
public function beforeRun($event) { $id = $this->owner->options['id']; $options = Json::htmlEncode($this->getClientOptions()); $view = $this->owner->getView(); GridViewAsset::register($view); $view->registerJs("jQuery('#$id').yiiGridView($options);"); }
[ "public", "function", "beforeRun", "(", "$", "event", ")", "{", "$", "id", "=", "$", "this", "->", "owner", "->", "options", "[", "'id'", "]", ";", "$", "options", "=", "Json", "::", "htmlEncode", "(", "$", "this", "->", "getClientOptions", "(", ")",...
Handles [[Widget::EVENT_BEFORE_RUN]] event, registering related client script. @param \yii\base\Event $event event instance.
[ "Handles", "[[", "Widget", "::", "EVENT_BEFORE_RUN", "]]", "event", "registering", "related", "client", "script", "." ]
train
https://github.com/yiisoft/yii-jquery/blob/1c257928cba2b46d267e90771652abe2b0e2cfcb/src/GridViewClientScript.php#L68-L75
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.applyOnOutput
public function applyOnOutput(HttpAdapter $http = null, $mode = true) { if ($mode == true) { if ($this->applyOnOutput === null) { ob_start([$this, 'returnBuffer']); } $this->applyOnOutput = $http; } elseif ($this->apply...
php
public function applyOnOutput(HttpAdapter $http = null, $mode = true) { if ($mode == true) { if ($this->applyOnOutput === null) { ob_start([$this, 'returnBuffer']); } $this->applyOnOutput = $http; } elseif ($this->apply...
[ "public", "function", "applyOnOutput", "(", "HttpAdapter", "$", "http", "=", "null", ",", "$", "mode", "=", "true", ")", "{", "if", "(", "$", "mode", "==", "true", ")", "{", "if", "(", "$", "this", "->", "applyOnOutput", "===", "null", ")", "{", "o...
Used to enable or disable output buffering with ob_start. When enabled, the ob_start callback will be set to automatically call {@see apply} upon the first byte of output. If unconfigured, the default setting for {@see applyOnOutput} is off. @api @param HttpAdapter $http @param mixed $mode mode is the on/off setting...
[ "Used", "to", "enable", "or", "disable", "output", "buffering", "with", "ob_start", ".", "When", "enabled", "the", "ob_start", "callback", "will", "be", "set", "to", "automatically", "call", "{", "@see", "apply", "}", "upon", "the", "first", "byte", "of", ...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L243-L260
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.safeModeException
public function safeModeException($name) { Types::assert(['string' => [$name]]); $this->safeModeExceptions[strtolower($name)] = true; }
php
public function safeModeException($name) { Types::assert(['string' => [$name]]); $this->safeModeExceptions[strtolower($name)] = true; }
[ "public", "function", "safeModeException", "(", "$", "name", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "name", "]", "]", ")", ";", "$", "this", "->", "safeModeExceptions", "[", "strtolower", "(", "$", "name", ")", "]", ...
Used to add an exception to {@see safeMode}. @api @param string $name Specify the name of the header that you wish to be exempt from {@see safeMode} warnings and auto-modification. (Note that if you want to turn safe mode off for all headers, use [`->safeMode(false)`](safeMode) – safe mode is **not** on by default)....
[ "Used", "to", "add", "an", "exception", "to", "{", "@see", "safeMode", "}", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L308-L313
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.auto
public function auto($mode = self::AUTO_ALL) { Types::assert(['int' => [$mode]]); $this->automaticHeaders = $mode; }
php
public function auto($mode = self::AUTO_ALL) { Types::assert(['int' => [$mode]]); $this->automaticHeaders = $mode; }
[ "public", "function", "auto", "(", "$", "mode", "=", "self", "::", "AUTO_ALL", ")", "{", "Types", "::", "assert", "(", "[", "'int'", "=>", "[", "$", "mode", "]", "]", ")", ";", "$", "this", "->", "automaticHeaders", "=", "$", "mode", ";", "}" ]
Enable or disable certain automatically applied header functions If unconfigured, the default setting is {@see AUTO_ALL}. @api @param int $mode `auto` accepts one or more of the following constants. Multiple constants may be specified by combination using [bitwise operators](https://secure.php.net/manual/language.op...
[ "Enable", "or", "disable", "certain", "automatically", "applied", "header", "functions" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L432-L437
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.sameSiteCookies
public function sameSiteCookies($mode = null) { Types::assert(['?string' => [$mode]]); if (isset($mode)) { $mode = strtolower($mode); } if ($mode === 'lax' or $mode === 'strict') { $this->sameSiteCookies = ucfirst($mode); } el...
php
public function sameSiteCookies($mode = null) { Types::assert(['?string' => [$mode]]); if (isset($mode)) { $mode = strtolower($mode); } if ($mode === 'lax' or $mode === 'strict') { $this->sameSiteCookies = ucfirst($mode); } el...
[ "public", "function", "sameSiteCookies", "(", "$", "mode", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'?string'", "=>", "[", "$", "mode", "]", "]", ")", ";", "if", "(", "isset", "(", "$", "mode", ")", ")", "{", "$", "mode", "=", ...
Add and configure the default setting for [protected cookies](protectedCookie) that are automatically marked as `SameSite`. If this setting is unspecified the default will be `SameSite=Lax`, if this setting is given an invalid `string` setting the last setting will be honoured. If {@see strictMode} is enabled then the...
[ "Add", "and", "configure", "the", "default", "setting", "for", "[", "protected", "cookies", "]", "(", "protectedCookie", ")", "that", "are", "automatically", "marked", "as", "SameSite", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L491-L508
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.removeHeader
public function removeHeader($name) { Types::assert(['string' => [$name]]); $name = strtolower($name); $this->removedHeaders[$name] = true; }
php
public function removeHeader($name) { Types::assert(['string' => [$name]]); $name = strtolower($name); $this->removedHeaders[$name] = true; }
[ "public", "function", "removeHeader", "(", "$", "name", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "name", "]", "]", ")", ";", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "this", "->", "removedHead...
Queue a header for removal. Upon calling {@see apply} the header will be removed. This function can be used to manually prevent [automatic headers](auto) from being sent. @api @param string $name Case insensitive name of the header to remove. @return void
[ "Queue", "a", "header", "for", "removal", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L526-L532
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.protectedCookie
public function protectedCookie( $name, $mode = self::COOKIE_DEFAULT ) { Types::assert( [ 'string|array' => [$name], 'int' => [$mode] ] ); if (is_string($name)) { $name = strtolower($name); }...
php
public function protectedCookie( $name, $mode = self::COOKIE_DEFAULT ) { Types::assert( [ 'string|array' => [$name], 'int' => [$mode] ] ); if (is_string($name)) { $name = strtolower($name); }...
[ "public", "function", "protectedCookie", "(", "$", "name", ",", "$", "mode", "=", "self", "::", "COOKIE_DEFAULT", ")", "{", "Types", "::", "assert", "(", "[", "'string|array'", "=>", "[", "$", "name", "]", ",", "'int'", "=>", "[", "$", "mode", "]", "...
Configure which cookies SecureHeaders will regard as protected. SecureHeaders will consider substrings and names of cookies separately. By default, cookies that case insensitively match the following substrings or names will be regarded as protected. #### Substrings ``` sess auth login csrf xsrf token antiforgery ```...
[ "Configure", "which", "cookies", "SecureHeaders", "will", "regard", "as", "protected", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L581-L637
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.csp
public function csp() { $args = func_get_args(); Types::assert(['string|array|int|bool|NULL' => $args]); $num = count($args); # look for a bool or intgers (commonly used in place of bools) # if one is found the first of which is loosly interpreted as # the setting ...
php
public function csp() { $args = func_get_args(); Types::assert(['string|array|int|bool|NULL' => $args]); $num = count($args); # look for a bool or intgers (commonly used in place of bools) # if one is found the first of which is loosly interpreted as # the setting ...
[ "public", "function", "csp", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "Types", "::", "assert", "(", "[", "'string|array|int|bool|NULL'", "=>", "$", "args", "]", ")", ";", "$", "num", "=", "count", "(", "$", "args", ")", ";", ...
@api @ignore Polymorphic variadic function
[ "@api" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L669-L736
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspro
public function cspro() { $args = func_get_args(); Types::assert(['string|array|int|bool|NULL' => $args]); foreach ($args as $i => $arg) { if (is_bool($arg) or is_int($arg)) { unset($args[$i]); } } $args = array_v...
php
public function cspro() { $args = func_get_args(); Types::assert(['string|array|int|bool|NULL' => $args]); foreach ($args as $i => $arg) { if (is_bool($arg) or is_int($arg)) { unset($args[$i]); } } $args = array_v...
[ "public", "function", "cspro", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "Types", "::", "assert", "(", "[", "'string|array|int|bool|NULL'", "=>", "$", "args", "]", ")", ";", "foreach", "(", "$", "args", "as", "$", "i", "=>", "$...
@api @ignore Polymorphic variadic function
[ "@api" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L743-L762
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.removeCSPSource
public function removeCSPSource($directive, $source, $reportOnly = null) { Types::assert(['string' => [$directive, $source]]); $csp = &$this->getCSPObject($reportOnly); $source = strtolower($source); $directive = strtolower($directive); if ( ! isset($csp[$directive][$sourc...
php
public function removeCSPSource($directive, $source, $reportOnly = null) { Types::assert(['string' => [$directive, $source]]); $csp = &$this->getCSPObject($reportOnly); $source = strtolower($source); $directive = strtolower($directive); if ( ! isset($csp[$directive][$sourc...
[ "public", "function", "removeCSPSource", "(", "$", "directive", ",", "$", "source", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", ",", "$", "source", "]", "]", ")", ";", "$"...
Remove a previously added source from a CSP directive. @api @param string $directive The directive (case insensitive) in which the source to be removed resides. @param string $source The source (case insensitive) to remove. @param mixed $reportOnly Loosely casted as a boolean, `true` ensures the function acts on the ...
[ "Remove", "a", "previously", "added", "source", "from", "a", "CSP", "directive", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L810-L827
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.removeCSPDirective
public function removeCSPDirective($directive, $reportOnly = null) { Types::assert(['string' => [$directive]]); $csp = &$this->getCSPObject($reportOnly); $directive = strtolower($directive); if ( ! isset($csp[$directive])) { return false; } uns...
php
public function removeCSPDirective($directive, $reportOnly = null) { Types::assert(['string' => [$directive]]); $csp = &$this->getCSPObject($reportOnly); $directive = strtolower($directive); if ( ! isset($csp[$directive])) { return false; } uns...
[ "public", "function", "removeCSPDirective", "(", "$", "directive", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", "]", "]", ")", ";", "$", "csp", "=", "&", "$", "this", "->",...
Remove a previously added directive from CSP. @api @param string $directive The directive (case insensitive) to remove. @param mixed $reportOnly Loosely casted as a boolean, `true` ensures the function acts on the report only policy, `false` (the default, as `null` casts to false) ensures the function acts on the enf...
[ "Remove", "a", "previously", "added", "directive", "from", "CSP", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L843-L859
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspHash
public function cspHash( $friendlyDirective, $string, $algo = null, $isFile = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); if ( ! isset($algo) or !...
php
public function cspHash( $friendlyDirective, $string, $algo = null, $isFile = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); if ( ! isset($algo) or !...
[ "public", "function", "cspHash", "(", "$", "friendlyDirective", ",", "$", "string", ",", "$", "algo", "=", "null", ",", "$", "isFile", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[...
Generate a hash of the provided [`$string`](#string) value, and have it added to the [`$friendlyDirective`](#friendlyDirective) directive in CSP. @api @param string $friendlyDirective The (case insensitive) [friendly name](friendly_directives_and_sources#directives) that the hash should be to be added to. @param stri...
[ "Generate", "a", "hash", "of", "the", "provided", "[", "$string", "]", "(", "#string", ")", "value", "and", "have", "it", "added", "to", "the", "[", "$friendlyDirective", "]", "(", "#friendlyDirective", ")", "directive", "in", "CSP", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L908-L936
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.csproHash
public function csproHash( $friendlyDirective, $string, $algo = null, $isFile = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash( $friendlyDirective, $string...
php
public function csproHash( $friendlyDirective, $string, $algo = null, $isFile = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash( $friendlyDirective, $string...
[ "public", "function", "csproHash", "(", "$", "friendlyDirective", ",", "$", "string", ",", "$", "algo", "=", "null", ",", "$", "isFile", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", ",", "$"...
An alias for {@see cspHash} with [reportOnly](cspHash#reportOnly) set to true. @api @param string $friendlyDirective @param string $string @param ?string $algo = 'sha256' @param mixed $isFile @return string
[ "An", "alias", "for", "{", "@see", "cspHash", "}", "with", "[", "reportOnly", "]", "(", "cspHash#reportOnly", ")", "set", "to", "true", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L951-L968
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspHashFile
public function cspHashFile( $friendlyDirective, $string, $algo = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash( $friendlyDirective, $...
php
public function cspHashFile( $friendlyDirective, $string, $algo = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash( $friendlyDirective, $...
[ "public", "function", "cspHashFile", "(", "$", "friendlyDirective", ",", "$", "string", ",", "$", "algo", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", ",",...
An alias for {@see cspHash} with [isFile](cspHash#isFile) set to `true`. @api @param string $friendlyDirective @param string $string @param ?string $algo = 'sha256' @param mixed $reportOnly @return string
[ "An", "alias", "for", "{", "@see", "cspHash", "}", "with", "[", "isFile", "]", "(", "cspHash#isFile", ")", "set", "to", "true", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L982-L999
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.csproHashFile
public function csproHashFile($friendlyDirective, $string, $algo = null) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash($friendlyDirective, $string, $algo, true, true); }
php
public function csproHashFile($friendlyDirective, $string, $algo = null) { Types::assert( ['string' => [$friendlyDirective, $string], '?string' => [$algo]] ); return $this->cspHash($friendlyDirective, $string, $algo, true, true); }
[ "public", "function", "csproHashFile", "(", "$", "friendlyDirective", ",", "$", "string", ",", "$", "algo", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", ",", "$", "string", "]", ",", "'?string...
An alias for {@see cspHash} with [reportOnly](cspHash#reportOnly) set to true, and [isFile](cspHash#isFile) set to true. @api @param string $friendlyDirective @param string $string @param ?string $algo = 'sha256' @return string
[ "An", "alias", "for", "{", "@see", "cspHash", "}", "with", "[", "reportOnly", "]", "(", "cspHash#reportOnly", ")", "set", "to", "true", "and", "[", "isFile", "]", "(", "cspHash#isFile", ")", "set", "to", "true", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1013-L1020
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspNonce
public function cspNonce($friendlyDirective, $reportOnly = null) { Types::assert(['string' => [$friendlyDirective]]); $reportOnly = ($reportOnly == true); $nonceStore = &$this->cspNonces[ ($reportOnly ? 'reportOnly' : 'enforced') ]; $directive = $this->longDire...
php
public function cspNonce($friendlyDirective, $reportOnly = null) { Types::assert(['string' => [$friendlyDirective]]); $reportOnly = ($reportOnly == true); $nonceStore = &$this->cspNonces[ ($reportOnly ? 'reportOnly' : 'enforced') ]; $directive = $this->longDire...
[ "public", "function", "cspNonce", "(", "$", "friendlyDirective", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", "]", "]", ")", ";", "$", "reportOnly", "=", "(", "$", "r...
Used to securely generate a nonce value, and have it be added to the [`$friendlyDirective`](#friendlyDirective) in CSP. Note that if a nonce already exists for the specified directive, the existing value will be returned instead of generating a new one (multiple nonces in the same directive don't offer any security be...
[ "Used", "to", "securely", "generate", "a", "nonce", "value", "and", "have", "it", "be", "added", "to", "the", "[", "$friendlyDirective", "]", "(", "#friendlyDirective", ")", "in", "CSP", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1055-L1081
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.expectCT
public function expectCT( $maxAge = 31536000, $enforce = true, $reportUri = null ) { Types::assert( [ '?int|?string' => [$maxAge], '?string' => [$reportUri] ], [1, 3] ); if (isset($maxAge) or ! ...
php
public function expectCT( $maxAge = 31536000, $enforce = true, $reportUri = null ) { Types::assert( [ '?int|?string' => [$maxAge], '?string' => [$reportUri] ], [1, 3] ); if (isset($maxAge) or ! ...
[ "public", "function", "expectCT", "(", "$", "maxAge", "=", "31536000", ",", "$", "enforce", "=", "true", ",", "$", "reportUri", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'?int|?string'", "=>", "[", "$", "maxAge", "]", ",", "'?string'",...
Used to add and configure the Expect-CT header. Expect-CT makes sure that a user's browser will fill the role of ensuring that future requests, within $maxAge seconds will have certificate transparancy. If set to enforcement mode, the browser will fail the TLS connection if the certificate transparency requirement is...
[ "Used", "to", "add", "and", "configure", "the", "Expect", "-", "CT", "header", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1139-L1167
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.hsts
public function hsts( $maxAge = 31536000, $subdomains = false, $preload = false ) { Types::assert(['int|string' => [$maxAge]]); $this->hsts['max-age'] = $maxAge; $this->hsts['subdomains'] = ($subdomains == true); $this->hsts['preload'] = ($preload...
php
public function hsts( $maxAge = 31536000, $subdomains = false, $preload = false ) { Types::assert(['int|string' => [$maxAge]]); $this->hsts['max-age'] = $maxAge; $this->hsts['subdomains'] = ($subdomains == true); $this->hsts['preload'] = ($preload...
[ "public", "function", "hsts", "(", "$", "maxAge", "=", "31536000", ",", "$", "subdomains", "=", "false", ",", "$", "preload", "=", "false", ")", "{", "Types", "::", "assert", "(", "[", "'int|string'", "=>", "[", "$", "maxAge", "]", "]", ")", ";", "...
Used to add and configure the Strict-Transport-Security header. HSTS makes sure that a user's browser will fill the role of redirecting them from HTTP to HTTPS so that they need not trust an insecure response from the network. @api @param int|string $maxAge The length, in seconds either as a string, or an integer – ...
[ "Used", "to", "add", "and", "configure", "the", "Strict", "-", "Transport", "-", "Security", "header", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1202-L1212
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.hpkp
public function hpkp( $pins, $maxAge = null, $subdomains = null, $reportUri = null, $reportOnly = null ) { Types::assert( [ 'string|array' => [$pins], '?int|?string' => [$maxAge], '?string' => [$reportUri] ...
php
public function hpkp( $pins, $maxAge = null, $subdomains = null, $reportUri = null, $reportOnly = null ) { Types::assert( [ 'string|array' => [$pins], '?int|?string' => [$maxAge], '?string' => [$reportUri] ...
[ "public", "function", "hpkp", "(", "$", "pins", ",", "$", "maxAge", "=", "null", ",", "$", "subdomains", "=", "null", ",", "$", "reportUri", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string|array...
Add and configure the HTTP Public Key Pins header. @param string|array $pins Either give a valid pin as a string here, or give multiple as an array. **Note that browsers will not enforce this header unless a backup pin AND a pin that is currently deployed is specified)**. This means that at least two pins must be spec...
[ "Add", "and", "configure", "the", "HTTP", "Public", "Key", "Pins", "header", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1310-L1380
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.hpkpro
public function hpkpro( $pins, $maxAge = null, $subdomains = null, $reportUri = null ) { Types::assert( [ 'string|array' => [$pins], '?int|?string' => [$maxAge], '?string' => [$reportUri] ], [...
php
public function hpkpro( $pins, $maxAge = null, $subdomains = null, $reportUri = null ) { Types::assert( [ 'string|array' => [$pins], '?int|?string' => [$maxAge], '?string' => [$reportUri] ], [...
[ "public", "function", "hpkpro", "(", "$", "pins", ",", "$", "maxAge", "=", "null", ",", "$", "subdomains", "=", "null", ",", "$", "reportUri", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string|array'", "=>", "[", "$", "pins", "]", ...
Add and configure the HTTP Public Key Pins header in report-only mode. This is an alias for {@see hpkp} with `$reportOnly` set to `true`. @api @param string|array $pins @param ?integer|string $maxAge @param ?mixed $subdomains @param ?string $reportUri @return void
[ "Add", "and", "configure", "the", "HTTP", "Public", "Key", "Pins", "header", "in", "report", "-", "only", "mode", ".", "This", "is", "an", "alias", "for", "{", "@see", "hpkp", "}", "with", "$reportOnly", "set", "to", "true", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1395-L1411
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.hpkpSubdomains
public function hpkpSubdomains($mode = true, $reportOnly = null) { $hpkp = &$this->getHPKPObject($reportOnly); $hpkp['includesubdomains'] = ($mode == true); }
php
public function hpkpSubdomains($mode = true, $reportOnly = null) { $hpkp = &$this->getHPKPObject($reportOnly); $hpkp['includesubdomains'] = ($mode == true); }
[ "public", "function", "hpkpSubdomains", "(", "$", "mode", "=", "true", ",", "$", "reportOnly", "=", "null", ")", "{", "$", "hpkp", "=", "&", "$", "this", "->", "getHPKPObject", "(", "$", "reportOnly", ")", ";", "$", "hpkp", "[", "'includesubdomains'", ...
Add or remove the `includeSubDomains` flag from the [HPKP](hpkp) policy (note this can be done with the {@see hpkp} function too). @api @param mixed $mode Loosely casted to a boolean, `true` adds the `includeSubDomains` flag, `false` removes it. @param mixed $reportOnly Apply this setting to the report-only version o...
[ "Add", "or", "remove", "the", "includeSubDomains", "flag", "from", "the", "[", "HPKP", "]", "(", "hpkp", ")", "policy", "(", "note", "this", "can", "be", "done", "with", "the", "{", "@see", "hpkp", "}", "function", "too", ")", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1427-L1432
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.apply
public function apply(HttpAdapter $http = null) { # For ease of use, we allow calling this method without an adapter, # which will cause the headers to be sent with PHP's global methods. if (is_null($http)) { $http = new GlobalHttpAdapter(); } $headers = ...
php
public function apply(HttpAdapter $http = null) { # For ease of use, we allow calling this method without an adapter, # which will cause the headers to be sent with PHP's global methods. if (is_null($http)) { $http = new GlobalHttpAdapter(); } $headers = ...
[ "public", "function", "apply", "(", "HttpAdapter", "$", "http", "=", "null", ")", "{", "# For ease of use, we allow calling this method without an adapter,", "# which will cause the headers to be sent with PHP's global methods.", "if", "(", "is_null", "(", "$", "http", ")", "...
Calling this function will initiate the following 1. Existing headers from the HttpAdapter's source will be imported into SecureHeaders' internal list, parsed 2. [Automatic header functions](auto) will be applied 3. [Expect CT](expectCT), [CSP](csp), [HSTS](hsts), and [HPKP](hpkp) policies will be compiled and added t...
[ "Calling", "this", "function", "will", "initiate", "the", "following" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1491-L1522
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.pipeline
private function pipeline() { $operations = []; if ($this->strictMode) { $operations[] = new AddHeader( 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload' ); $operations[] = new AddHeader( ...
php
private function pipeline() { $operations = []; if ($this->strictMode) { $operations[] = new AddHeader( 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload' ); $operations[] = new AddHeader( ...
[ "private", "function", "pipeline", "(", ")", "{", "$", "operations", "=", "[", "]", ";", "if", "(", "$", "this", "->", "strictMode", ")", "{", "$", "operations", "[", "]", "=", "new", "AddHeader", "(", "'Strict-Transport-Security'", ",", "'max-age=31536000...
Return an array of header operations, depending on current configuration. These can then be applied to e.g. the current set of headers. @api @return Operation[]
[ "Return", "an", "array", "of", "header", "operations", "depending", "on", "current", "configuration", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1533-L1652
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.returnBuffer
public function returnBuffer($buffer = null) { if ($this->isBufferReturned) { return $buffer; } $this->apply($this->applyOnOutput); if (ob_get_level() and ! empty($this->errorString)) { # prepend any errors to the buffer string (any errors th...
php
public function returnBuffer($buffer = null) { if ($this->isBufferReturned) { return $buffer; } $this->apply($this->applyOnOutput); if (ob_get_level() and ! empty($this->errorString)) { # prepend any errors to the buffer string (any errors th...
[ "public", "function", "returnBuffer", "(", "$", "buffer", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isBufferReturned", ")", "{", "return", "$", "buffer", ";", "}", "$", "this", "->", "apply", "(", "$", "this", "->", "applyOnOutput", ")", ...
@ignore Method given to `ob_start` when using {@see applyOnOutput) @param string $buffer @return string
[ "@ignore" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1670-L1691
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.validateHeaders
private function validateHeaders(HeaderBag $headers) { $this->errors = array_merge( $this->errors, Validator::validate($headers) ); }
php
private function validateHeaders(HeaderBag $headers) { $this->errors = array_merge( $this->errors, Validator::validate($headers) ); }
[ "private", "function", "validateHeaders", "(", "HeaderBag", "$", "headers", ")", "{", "$", "this", "->", "errors", "=", "array_merge", "(", "$", "this", "->", "errors", ",", "Validator", "::", "validate", "(", "$", "headers", ")", ")", ";", "}" ]
Validate headers in the HeaderBag and store any errors internally. @param HeaderBag $headers @return void
[ "Validate", "headers", "in", "the", "HeaderBag", "and", "store", "any", "errors", "internally", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1705-L1711
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspAllow
private function cspAllow( $friendlyDirective, $friendlySource = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $friendlySource]] ); $directive = $this->longDirective($friendlyDirective); $source = $this->longSource...
php
private function cspAllow( $friendlyDirective, $friendlySource = null, $reportOnly = null ) { Types::assert( ['string' => [$friendlyDirective, $friendlySource]] ); $directive = $this->longDirective($friendlyDirective); $source = $this->longSource...
[ "private", "function", "cspAllow", "(", "$", "friendlyDirective", ",", "$", "friendlySource", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", ",", "$", "friendl...
Add a CSP friendly source $friendlySource to a CSP directive $friendlyDirective in either enforcement or report only mode. @param string $friendlyDirective @param string $friendlySource @param bool $reportOnly @return void
[ "Add", "a", "CSP", "friendly", "source", "$friendlySource", "to", "a", "CSP", "directive", "$friendlyDirective", "in", "either", "enforcement", "or", "report", "only", "mode", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1727-L1741
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.longDirective
private function longDirective($friendlyDirective) { Types::assert(['string' => [$friendlyDirective]]); $friendlyDirective = strtolower($friendlyDirective); if (isset($this->cspDirectiveShortcuts[$friendlyDirective])) { $directive = $this->cspDirectiveShortcuts[$friendl...
php
private function longDirective($friendlyDirective) { Types::assert(['string' => [$friendlyDirective]]); $friendlyDirective = strtolower($friendlyDirective); if (isset($this->cspDirectiveShortcuts[$friendlyDirective])) { $directive = $this->cspDirectiveShortcuts[$friendl...
[ "private", "function", "longDirective", "(", "$", "friendlyDirective", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlyDirective", "]", "]", ")", ";", "$", "friendlyDirective", "=", "strtolower", "(", "$", "friendlyDirective",...
Takes friendly directive $friendlyDirective and returns the corresponding long (proper) directive. @param string $friendlyDirective @return string
[ "Takes", "friendly", "directive", "$friendlyDirective", "and", "returns", "the", "corresponding", "long", "(", "proper", ")", "directive", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1750-L1766
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.longSource
private function longSource($friendlySource) { Types::assert(['string' => [$friendlySource]]); $lowerFriendlySource = strtolower($friendlySource); if (isset($this->cspSourceShortcuts[$lowerFriendlySource])) { $source = $this->cspSourceShortcuts[$lowerFriendlySource]; ...
php
private function longSource($friendlySource) { Types::assert(['string' => [$friendlySource]]); $lowerFriendlySource = strtolower($friendlySource); if (isset($this->cspSourceShortcuts[$lowerFriendlySource])) { $source = $this->cspSourceShortcuts[$lowerFriendlySource]; ...
[ "private", "function", "longSource", "(", "$", "friendlySource", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "friendlySource", "]", "]", ")", ";", "$", "lowerFriendlySource", "=", "strtolower", "(", "$", "friendlySource", ")", ...
Takes friendly source $friendlySource and returns the corresponding long (proper) source. @param string $friendlySource @return string
[ "Takes", "friendly", "source", "$friendlySource", "and", "returns", "the", "corresponding", "long", "(", "proper", ")", "source", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1775-L1791
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.addCSPSource
private function addCSPSource( $directive, $source = null, $reportOnly = null ) { Types::assert(['string' => [$directive], '?string' => [$source]]); $csp = &$this->getCSPObject($reportOnly); if ( ! isset($csp[$directive])) { $this->addCSPDirectiv...
php
private function addCSPSource( $directive, $source = null, $reportOnly = null ) { Types::assert(['string' => [$directive], '?string' => [$source]]); $csp = &$this->getCSPObject($reportOnly); if ( ! isset($csp[$directive])) { $this->addCSPDirectiv...
[ "private", "function", "addCSPSource", "(", "$", "directive", ",", "$", "source", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", "]", ",", "'?string'", "=>", "[", ...
Add a CSP source $source to a CSP directive $directive in either enforcement or report only mode. Both $directive and $source must be long (defined in CSP spec). Will return false on error, true on success. @param string $directive @param ?string $source @param bool $reportOnly @return bool
[ "Add", "a", "CSP", "source", "$source", "to", "a", "CSP", "directive", "$directive", "in", "either", "enforcement", "or", "report", "only", "mode", ".", "Both", "$directive", "and", "$source", "must", "be", "long", "(", "defined", "in", "CSP", "spec", ")",...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1805-L1836
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspArray
private function cspArray(array $csp, $reportOnly = false) { foreach ($csp as $friendlyDirective => $sources) { if (is_array($sources) and ! empty($sources)) { foreach ($sources as $friendlySource) { $this->cspAllow( ...
php
private function cspArray(array $csp, $reportOnly = false) { foreach ($csp as $friendlyDirective => $sources) { if (is_array($sources) and ! empty($sources)) { foreach ($sources as $friendlySource) { $this->cspAllow( ...
[ "private", "function", "cspArray", "(", "array", "$", "csp", ",", "$", "reportOnly", "=", "false", ")", "{", "foreach", "(", "$", "csp", "as", "$", "friendlyDirective", "=>", "$", "sources", ")", "{", "if", "(", "is_array", "(", "$", "sources", ")", ...
Add a CSP array $csp of friendly sources to corresponding firendly directives in either enforcement or report only mode. @param array $csp @param bool $reportOnly @return void
[ "Add", "a", "CSP", "array", "$csp", "of", "friendly", "sources", "to", "corresponding", "firendly", "directives", "in", "either", "enforcement", "or", "report", "only", "mode", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1848-L1879
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.&
private function &getCSPObject($reportOnly) { if ( ! isset($reportOnly) or ! $reportOnly) { $csp = &$this->csp; } else { $csp = &$this->cspro; } return $csp; }
php
private function &getCSPObject($reportOnly) { if ( ! isset($reportOnly) or ! $reportOnly) { $csp = &$this->csp; } else { $csp = &$this->cspro; } return $csp; }
[ "private", "function", "&", "getCSPObject", "(", "$", "reportOnly", ")", "{", "if", "(", "!", "isset", "(", "$", "reportOnly", ")", "or", "!", "$", "reportOnly", ")", "{", "$", "csp", "=", "&", "$", "this", "->", "csp", ";", "}", "else", "{", "$"...
Retrieve a reference to either the CSP enforcement, or CSP report only array. @param bool $reportOnly @return &array
[ "Retrieve", "a", "reference", "to", "either", "the", "CSP", "enforcement", "or", "CSP", "report", "only", "array", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1888-L1900
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.addCSPDirective
private function addCSPDirective( $directive, $isFlag = null, $reportOnly = null ) { Types::assert(['string' => [$directive]]); if ( ! isset($isFlag)) { $isFlag = false; } $csp = &$this->getCSPObject($reportOnly); if (isset($csp[...
php
private function addCSPDirective( $directive, $isFlag = null, $reportOnly = null ) { Types::assert(['string' => [$directive]]); if ( ! isset($isFlag)) { $isFlag = false; } $csp = &$this->getCSPObject($reportOnly); if (isset($csp[...
[ "private", "function", "addCSPDirective", "(", "$", "directive", ",", "$", "isFlag", "=", "null", ",", "$", "reportOnly", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", "]", "]", ")", ";", "if", "("...
Add a CSP directive $directive in either enforcement or report only mode. $directive must be long (defined in CSP spec). Set $isFlag to true if adding a directive that should not hold source values. Will return false on error, true on success. @param string $directive @param bool $isFlag @param bool $reportOnly @retu...
[ "Add", "a", "CSP", "directive", "$directive", "in", "either", "enforcement", "or", "report", "only", "mode", ".", "$directive", "must", "be", "long", "(", "defined", "in", "CSP", "spec", ")", ".", "Set", "$isFlag", "to", "true", "if", "adding", "a", "dir...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1914-L1943
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspDoHash
private function cspDoHash( $string, $algo = null, $isFile = null ) { Types::assert(['string' => [$string], '?string' => [$algo]]); if ( ! isset($algo)) { $algo = 'sha256'; } if ( ! isset($isFile)) { $isFile = false; ...
php
private function cspDoHash( $string, $algo = null, $isFile = null ) { Types::assert(['string' => [$string], '?string' => [$algo]]); if ( ! isset($algo)) { $algo = 'sha256'; } if ( ! isset($isFile)) { $isFile = false; ...
[ "private", "function", "cspDoHash", "(", "$", "string", ",", "$", "algo", "=", "null", ",", "$", "isFile", "=", "null", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "string", "]", ",", "'?string'", "=>", "[", "$", "algo"...
Generate a hash with algorithm $algo for insertion in a CSP either of $string, or of the contents of a file at path $string iff $isFile is truthy. @param string $string @param string $algo @param bool $isFile @return string
[ "Generate", "a", "hash", "with", "algorithm", "$algo", "for", "insertion", "in", "a", "CSP", "either", "of", "$string", "or", "of", "the", "contents", "of", "a", "file", "at", "path", "$string", "iff", "$isFile", "is", "truthy", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L1955-L1994
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.cspGenerateNonce
private function cspGenerateNonce() { $nonce = base64_encode( openssl_random_pseudo_bytes(30, $isCryptoStrong) ); if ( ! $isCryptoStrong) { $this->addError( 'OpenSSL (openssl_random_pseudo_bytes) reported that it did <strong>no...
php
private function cspGenerateNonce() { $nonce = base64_encode( openssl_random_pseudo_bytes(30, $isCryptoStrong) ); if ( ! $isCryptoStrong) { $this->addError( 'OpenSSL (openssl_random_pseudo_bytes) reported that it did <strong>no...
[ "private", "function", "cspGenerateNonce", "(", ")", "{", "$", "nonce", "=", "base64_encode", "(", "openssl_random_pseudo_bytes", "(", "30", ",", "$", "isCryptoStrong", ")", ")", ";", "if", "(", "!", "$", "isCryptoStrong", ")", "{", "$", "this", "->", "add...
Generate a nonce for insertion in a CSP. @return string
[ "Generate", "a", "nonce", "for", "insertion", "in", "a", "CSP", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2001-L2019
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.&
private function &getHPKPObject($reportOnly) { if ( ! isset($reportOnly) or ! $reportOnly) { $hpkp = &$this->hpkp; } else { $hpkp = &$this->hpkpro; } return $hpkp; }
php
private function &getHPKPObject($reportOnly) { if ( ! isset($reportOnly) or ! $reportOnly) { $hpkp = &$this->hpkp; } else { $hpkp = &$this->hpkpro; } return $hpkp; }
[ "private", "function", "&", "getHPKPObject", "(", "$", "reportOnly", ")", "{", "if", "(", "!", "isset", "(", "$", "reportOnly", ")", "or", "!", "$", "reportOnly", ")", "{", "$", "hpkp", "=", "&", "$", "this", "->", "hpkp", ";", "}", "else", "{", ...
Retrieve a reference to either the HPKP enforcement, or HPKP report only array. @param bool $reportOnly @return &array
[ "Retrieve", "a", "reference", "to", "either", "the", "HPKP", "enforcement", "or", "HPKP", "report", "only", "array", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2031-L2043
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.addError
private function addError($message, $level = E_USER_NOTICE) { Types::assert( ['string' => [$message], 'int' => [$level]] ); $this->errors[] = new Error($message, $level); }
php
private function addError($message, $level = E_USER_NOTICE) { Types::assert( ['string' => [$message], 'int' => [$level]] ); $this->errors[] = new Error($message, $level); }
[ "private", "function", "addError", "(", "$", "message", ",", "$", "level", "=", "E_USER_NOTICE", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "message", "]", ",", "'int'", "=>", "[", "$", "level", "]", "]", ")", ";", "$"...
Add and store an error internally. @param string $message @param int $level @return void
[ "Add", "and", "store", "an", "error", "internally", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2055-L2062
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.reportErrors
private function reportErrors() { if ( ! $this->errorReporting) { return; } set_error_handler([get_class(), 'errorHandler']); if ( ! empty($this->errors)) { $this->isBufferReturned = true; } foreach ($this->errors as $error) ...
php
private function reportErrors() { if ( ! $this->errorReporting) { return; } set_error_handler([get_class(), 'errorHandler']); if ( ! empty($this->errors)) { $this->isBufferReturned = true; } foreach ($this->errors as $error) ...
[ "private", "function", "reportErrors", "(", ")", "{", "if", "(", "!", "$", "this", "->", "errorReporting", ")", "{", "return", ";", "}", "set_error_handler", "(", "[", "get_class", "(", ")", ",", "'errorHandler'", "]", ")", ";", "if", "(", "!", "empty"...
Use PHPs `trigger_error` function to trigger all internally stored errors if error reporting is enabled for $this. The error handler will be temporarily set to {@see errorHandler} while errors are dispatched via `trigger_error`. @return void
[ "Use", "PHPs", "trigger_error", "function", "to", "trigger", "all", "internally", "stored", "errors", "if", "error", "reporting", "is", "enabled", "for", "$this", ".", "The", "error", "handler", "will", "be", "temporarily", "set", "to", "{", "@see", "errorHand...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2072-L2092
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.injectableSameSiteValue
private function injectableSameSiteValue() { if ( ! isset($this->sameSiteCookies) and $this->strictMode) { $sameSite = 'Strict'; } elseif ( ! isset($this->sameSiteCookies)) { $sameSite = 'Lax'; } else { $sameSite = $...
php
private function injectableSameSiteValue() { if ( ! isset($this->sameSiteCookies) and $this->strictMode) { $sameSite = 'Strict'; } elseif ( ! isset($this->sameSiteCookies)) { $sameSite = 'Lax'; } else { $sameSite = $...
[ "private", "function", "injectableSameSiteValue", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "sameSiteCookies", ")", "and", "$", "this", "->", "strictMode", ")", "{", "$", "sameSite", "=", "'Strict'", ";", "}", "elseif", "(", "!", ...
Determine the appropriate sameSite value to inject. @return string
[ "Determine", "the", "appropriate", "sameSite", "value", "to", "inject", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2099-L2115
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.errorHandler
private function errorHandler($level, $message) { Types::assert( ['int' => [$level], 'string' => [$message]] ); if (error_reporting() & $level and (strtolower(ini_get('display_errors')) === 'on' and ini_get('display_errors')) ) { if ($...
php
private function errorHandler($level, $message) { Types::assert( ['int' => [$level], 'string' => [$message]] ); if (error_reporting() & $level and (strtolower(ini_get('display_errors')) === 'on' and ini_get('display_errors')) ) { if ($...
[ "private", "function", "errorHandler", "(", "$", "level", ",", "$", "message", ")", "{", "Types", "::", "assert", "(", "[", "'int'", "=>", "[", "$", "level", "]", ",", "'string'", "=>", "[", "$", "message", "]", "]", ")", ";", "if", "(", "error_rep...
Echo an error iff PHPs settings allow error reporting, at the level of errors given, and PHPs display_errors setting is on. Will return `true` if an error is echoed, `false` otherwise. @param int $level @param string $message @return bool
[ "Echo", "an", "error", "iff", "PHPs", "settings", "allow", "error", "reporting", "at", "the", "level", "of", "errors", "given", "and", "PHPs", "display_errors", "setting", "is", "on", ".", "Will", "return", "true", "if", "an", "error", "is", "echoed", "fal...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2126-L2153
aidantwoods/SecureHeaders
src/SecureHeaders.php
SecureHeaders.reportMissingHeaders
private function reportMissingHeaders(HeaderBag $headers) { foreach ($this->reportMissingHeaders as $header) { if ( ! $headers->has($header) and empty($this->reportMissingExceptions[strtolower($header)]) ) { $this->addError( ...
php
private function reportMissingHeaders(HeaderBag $headers) { foreach ($this->reportMissingHeaders as $header) { if ( ! $headers->has($header) and empty($this->reportMissingExceptions[strtolower($header)]) ) { $this->addError( ...
[ "private", "function", "reportMissingHeaders", "(", "HeaderBag", "$", "headers", ")", "{", "foreach", "(", "$", "this", "->", "reportMissingHeaders", "as", "$", "header", ")", "{", "if", "(", "!", "$", "headers", "->", "has", "(", "$", "header", ")", "an...
If $headers is missing certain headers of security value that are not on the user-defined exception to reporting list then internally store an error warning that the header is not present. @param HeaderBag $headers @return void
[ "If", "$headers", "is", "missing", "certain", "headers", "of", "security", "value", "that", "are", "not", "on", "the", "user", "-", "defined", "exception", "to", "reporting", "list", "then", "internally", "store", "an", "error", "warning", "that", "the", "he...
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/SecureHeaders.php#L2163-L2177
aidantwoods/SecureHeaders
src/Validator.php
Validator.validate
public static function validate(HeaderBag $headers) { $errors = []; foreach (self::$delegates as $delegate => $headerList) { $class = self::VALIDATOR_NAMESPACE.'\\'.$delegate; if ( ! is_array($headerList)) { $headerList = [$headerList]; ...
php
public static function validate(HeaderBag $headers) { $errors = []; foreach (self::$delegates as $delegate => $headerList) { $class = self::VALIDATOR_NAMESPACE.'\\'.$delegate; if ( ! is_array($headerList)) { $headerList = [$headerList]; ...
[ "public", "static", "function", "validate", "(", "HeaderBag", "$", "headers", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "self", "::", "$", "delegates", "as", "$", "delegate", "=>", "$", "headerList", ")", "{", "$", "class", "=", "s...
Validate the given headers @param HeaderBag $headers @return Error[]
[ "Validate", "the", "given", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Validator.php#L28-L57
aidantwoods/SecureHeaders
src/Operations/AddHeader.php
AddHeader.modify
public function modify(HeaderBag &$headers) { if ( ! $headers->has($this->name)) { foreach ($this->value as $value) { $headers->add($this->name, $value); } } }
php
public function modify(HeaderBag &$headers) { if ( ! $headers->has($this->name)) { foreach ($this->value as $value) { $headers->add($this->name, $value); } } }
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "if", "(", "!", "$", "headers", "->", "has", "(", "$", "this", "->", "name", ")", ")", "{", "foreach", "(", "$", "this", "->", "value", "as", "$", "value", ")", "{",...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/AddHeader.php#L42-L51
aidantwoods/SecureHeaders
src/Http/Psr7Adapter.php
Psr7Adapter.sendHeaders
public function sendHeaders(HeaderBag $headers) { # First, remove all headers on the response object $headersToRemove = $this->response->getHeaders(); foreach ($headersToRemove as $name => $headerLines) { $this->response = $this->response->withoutHeader($name); } ...
php
public function sendHeaders(HeaderBag $headers) { # First, remove all headers on the response object $headersToRemove = $this->response->getHeaders(); foreach ($headersToRemove as $name => $headerLines) { $this->response = $this->response->withoutHeader($name); } ...
[ "public", "function", "sendHeaders", "(", "HeaderBag", "$", "headers", ")", "{", "# First, remove all headers on the response object", "$", "headersToRemove", "=", "$", "this", "->", "response", "->", "getHeaders", "(", ")", ";", "foreach", "(", "$", "headersToRemov...
Send the given headers, overwriting all previously send headers @api @param HeaderBag $headers @return void
[ "Send", "the", "given", "headers", "overwriting", "all", "previously", "send", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Http/Psr7Adapter.php#L31-L48
aidantwoods/SecureHeaders
src/Http/Psr7Adapter.php
Psr7Adapter.getHeaders
public function getHeaders() { $headerLines = []; foreach ($this->response->getHeaders() as $name => $lines) { foreach ($lines as $line) { $headerLines[] = "$name: $line"; } } return HeaderBag::fromHeaderLines($headerLines)...
php
public function getHeaders() { $headerLines = []; foreach ($this->response->getHeaders() as $name => $lines) { foreach ($lines as $line) { $headerLines[] = "$name: $line"; } } return HeaderBag::fromHeaderLines($headerLines)...
[ "public", "function", "getHeaders", "(", ")", "{", "$", "headerLines", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "response", "->", "getHeaders", "(", ")", "as", "$", "name", "=>", "$", "lines", ")", "{", "foreach", "(", "$", "lines", "...
Retrieve the current list of already-sent (or planned-to-be-sent) headers @api @return HeaderBag
[ "Retrieve", "the", "current", "list", "of", "already", "-", "sent", "(", "or", "planned", "-", "to", "-", "be", "-", "sent", ")", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Http/Psr7Adapter.php#L57-L69
aidantwoods/SecureHeaders
src/ValidatorDelegates/CSPBadFlags.php
CSPBadFlags.validate
public static function validate(Header $header) { $Errors = []; $Errors = array_merge( $Errors, self::validateSrcAttribute($header, 'default-src'), self::validateSrcAttribute($header, 'script-src') ); return array_values(array_filter($Errors)); ...
php
public static function validate(Header $header) { $Errors = []; $Errors = array_merge( $Errors, self::validateSrcAttribute($header, 'default-src'), self::validateSrcAttribute($header, 'script-src') ); return array_values(array_filter($Errors)); ...
[ "public", "static", "function", "validate", "(", "Header", "$", "header", ")", "{", "$", "Errors", "=", "[", "]", ";", "$", "Errors", "=", "array_merge", "(", "$", "Errors", ",", "self", "::", "validateSrcAttribute", "(", "$", "header", ",", "'default-sr...
Validate the given header @param Header $header @return Error[]
[ "Validate", "the", "given", "header" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/ValidatorDelegates/CSPBadFlags.php#L19-L30
aidantwoods/SecureHeaders
src/ValidatorDelegates/CSPBadFlags.php
CSPBadFlags.validateSrcAttribute
private static function validateSrcAttribute(Header $header, $attributeName) { Types::assert(['string' => [$attributeName]], [2]); $Errors = []; if ($header->hasAttribute($attributeName)) { $value = $header->getAttributeValue($attributeName); $badFlags = ["...
php
private static function validateSrcAttribute(Header $header, $attributeName) { Types::assert(['string' => [$attributeName]], [2]); $Errors = []; if ($header->hasAttribute($attributeName)) { $value = $header->getAttributeValue($attributeName); $badFlags = ["...
[ "private", "static", "function", "validateSrcAttribute", "(", "Header", "$", "header", ",", "$", "attributeName", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "attributeName", "]", "]", ",", "[", "2", "]", ")", ";", "$", "Er...
Find bad flags in the given attribute @param Header $header @param string $attributeName @return Error[]
[ "Find", "bad", "flags", "in", "the", "given", "attribute" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/ValidatorDelegates/CSPBadFlags.php#L40-L71
aidantwoods/SecureHeaders
src/Headers/CSPHeader.php
CSPHeader.parseAttributes
protected function parseAttributes() { $this->attributes = []; $policy = CompileCSP::deconstructCSP($this->value); foreach ($policy as $directive => $sources) { if ( ! isset($this->attributes[$directive])) { $this->attributes[$directive] = []...
php
protected function parseAttributes() { $this->attributes = []; $policy = CompileCSP::deconstructCSP($this->value); foreach ($policy as $directive => $sources) { if ( ! isset($this->attributes[$directive])) { $this->attributes[$directive] = []...
[ "protected", "function", "parseAttributes", "(", ")", "{", "$", "this", "->", "attributes", "=", "[", "]", ";", "$", "policy", "=", "CompileCSP", "::", "deconstructCSP", "(", "$", "this", "->", "value", ")", ";", "foreach", "(", "$", "policy", "as", "$...
{@inheritDoc}
[ "{" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Headers/CSPHeader.php#L14-L32
aidantwoods/SecureHeaders
src/Headers/CSPHeader.php
CSPHeader.writeAttributesToValue
protected function writeAttributesToValue() { $policies = []; foreach ($this->attributes as $attributes) { foreach ($attributes as $attrInfo) { $directive = $attrInfo['name']; $value = $attrInfo['value']; if ($value ==...
php
protected function writeAttributesToValue() { $policies = []; foreach ($this->attributes as $attributes) { foreach ($attributes as $attrInfo) { $directive = $attrInfo['name']; $value = $attrInfo['value']; if ($value ==...
[ "protected", "function", "writeAttributesToValue", "(", ")", "{", "$", "policies", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attrInfo", ")", "{",...
{@inheritDoc}
[ "{" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Headers/CSPHeader.php#L37-L70
aidantwoods/SecureHeaders
src/Headers/CSPHeader.php
CSPHeader.setAttribute
public function setAttribute($name, $value = true) { Types::assert(['string' => [$name], 'int|bool|string' => [$value]]); $key = strtolower($name); if ( ! isset($this->attributes[$key])) { $this->attributes[$key] = []; } $this->attributes[$key][] = [ ...
php
public function setAttribute($name, $value = true) { Types::assert(['string' => [$name], 'int|bool|string' => [$value]]); $key = strtolower($name); if ( ! isset($this->attributes[$key])) { $this->attributes[$key] = []; } $this->attributes[$key][] = [ ...
[ "public", "function", "setAttribute", "(", "$", "name", ",", "$", "value", "=", "true", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "name", "]", ",", "'int|bool|string'", "=>", "[", "$", "value", "]", "]", ")", ";", "$"...
{@inheritDoc}
[ "{" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Headers/CSPHeader.php#L75-L92
aidantwoods/SecureHeaders
src/Http/StringHttpAdapter.php
StringHttpAdapter.getSentHeaders
public function getSentHeaders() { $compiledHeaders = []; foreach ($this->headers as $header) { $compiledHeaders[] = (string) $header; } return implode("\n", $compiledHeaders); }
php
public function getSentHeaders() { $compiledHeaders = []; foreach ($this->headers as $header) { $compiledHeaders[] = (string) $header; } return implode("\n", $compiledHeaders); }
[ "public", "function", "getSentHeaders", "(", ")", "{", "$", "compiledHeaders", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "header", ")", "{", "$", "compiledHeaders", "[", "]", "=", "(", "string", ")", "$", "header", ...
@api @return string
[ "@api" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Http/StringHttpAdapter.php#L55-L65
aidantwoods/SecureHeaders
src/ValidatorDelegates/CSPWildcards.php
CSPWildcards.validate
public static function validate(Header $header) { $errors = []; $header->forEachAttribute( function ($directive, $sources) use ($header, &$errors) { // $sources may be bool if directive is a CSP flag if ( ! is_string($sources)) ...
php
public static function validate(Header $header) { $errors = []; $header->forEachAttribute( function ($directive, $sources) use ($header, &$errors) { // $sources may be bool if directive is a CSP flag if ( ! is_string($sources)) ...
[ "public", "static", "function", "validate", "(", "Header", "$", "header", ")", "{", "$", "errors", "=", "[", "]", ";", "$", "header", "->", "forEachAttribute", "(", "function", "(", "$", "directive", ",", "$", "sources", ")", "use", "(", "$", "header",...
Validate the given header @param Header $header @return Error[]
[ "Validate", "the", "given", "header" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/ValidatorDelegates/CSPWildcards.php#L53-L80
aidantwoods/SecureHeaders
src/ValidatorDelegates/CSPWildcards.php
CSPWildcards.enumerateWildcards
private static function enumerateWildcards( Header $header, $directive, $sources ) { Types::assert(['string' => [$directive, $sources]], [2, 3]); if (preg_match_all(self::CSP_SOURCE_WILDCARD_RE, $sources, $matches)) { if ( ! in_array($directive, self::$cs...
php
private static function enumerateWildcards( Header $header, $directive, $sources ) { Types::assert(['string' => [$directive, $sources]], [2, 3]); if (preg_match_all(self::CSP_SOURCE_WILDCARD_RE, $sources, $matches)) { if ( ! in_array($directive, self::$cs...
[ "private", "static", "function", "enumerateWildcards", "(", "Header", "$", "header", ",", "$", "directive", ",", "$", "sources", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", ",", "$", "sources", "]", "]", ",", "...
Find wildcards in CSP directives @param Header $header @param string $directive @param string $sources @return ?Error
[ "Find", "wildcards", "in", "CSP", "directives" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/ValidatorDelegates/CSPWildcards.php#L91-L130
aidantwoods/SecureHeaders
src/ValidatorDelegates/CSPWildcards.php
CSPWildcards.enumerateNonHttps
private static function enumerateNonHttps( Header $header, $directive, $sources ) { Types::assert(['string' => [$directive, $sources]], [2, 3]); if (preg_match_all('/(?:[ ]|^)\Khttp[:][^ ]*/', $sources, $matches)) { $friendlyHeader = $header->getFriendlyN...
php
private static function enumerateNonHttps( Header $header, $directive, $sources ) { Types::assert(['string' => [$directive, $sources]], [2, 3]); if (preg_match_all('/(?:[ ]|^)\Khttp[:][^ ]*/', $sources, $matches)) { $friendlyHeader = $header->getFriendlyN...
[ "private", "static", "function", "enumerateNonHttps", "(", "Header", "$", "header", ",", "$", "directive", ",", "$", "sources", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "directive", ",", "$", "sources", "]", "]", ",", "[...
Find non secure origins in CSP directives @param Header $header @param string $directive @param string $sources @return ?Error
[ "Find", "non", "secure", "origins", "in", "CSP", "directives" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/ValidatorDelegates/CSPWildcards.php#L141-L166
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.matchingFully
public static function matchingFully(array $cookieNames, $field, $value = true) { Types::assert(['string' => [$field]], [2]); return new static($cookieNames, $field, $value); }
php
public static function matchingFully(array $cookieNames, $field, $value = true) { Types::assert(['string' => [$field]], [2]); return new static($cookieNames, $field, $value); }
[ "public", "static", "function", "matchingFully", "(", "array", "$", "cookieNames", ",", "$", "field", ",", "$", "value", "=", "true", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "field", "]", "]", ",", "[", "2", "]", ")...
Create an Operation to modify cookies with names $cookieNames such that $field holds $value. @param array $cookieNames @param string $field @param $value @return Operation
[ "Create", "an", "Operation", "to", "modify", "cookies", "with", "names", "$cookieNames", "such", "that", "$field", "holds", "$value", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L43-L48
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.matchingPartially
public static function matchingPartially(array $cookieSubstrs, $field, $value = true) { Types::assert(['string' => [$field]], [2]); $instance = new static($cookieSubstrs, $field, $value); $instance->matchSubstring = true; return $instance; }
php
public static function matchingPartially(array $cookieSubstrs, $field, $value = true) { Types::assert(['string' => [$field]], [2]); $instance = new static($cookieSubstrs, $field, $value); $instance->matchSubstring = true; return $instance; }
[ "public", "static", "function", "matchingPartially", "(", "array", "$", "cookieSubstrs", ",", "$", "field", ",", "$", "value", "=", "true", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "field", "]", "]", ",", "[", "2", "]"...
Create an operation to modify cookies with name substrings matching $cookieSubstrs such that $field holds $value. @param array $cookieSubstrs @param string $field @param $value @return Operation
[ "Create", "an", "operation", "to", "modify", "cookies", "with", "name", "substrings", "matching", "$cookieSubstrs", "such", "that", "$field", "holds", "$value", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L59-L67
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.modify
public function modify(HeaderBag &$headers) { foreach ($headers->getByName('set-cookie') as $cookieHeader) { $cookieName = $cookieHeader->getFirstAttributeName(); if ( ! $cookieHeader->hasAttribute($this->field) and $this->isCandidateCookie($cookieName)) { ...
php
public function modify(HeaderBag &$headers) { foreach ($headers->getByName('set-cookie') as $cookieHeader) { $cookieName = $cookieHeader->getFirstAttributeName(); if ( ! $cookieHeader->hasAttribute($this->field) and $this->isCandidateCookie($cookieName)) { ...
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "->", "getByName", "(", "'set-cookie'", ")", "as", "$", "cookieHeader", ")", "{", "$", "cookieName", "=", "$", "cookieHeader", "->", "getFirstA...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L75-L86
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.isCandidateCookie
private function isCandidateCookie($cookieName) { Types::assert(['string' => [$cookieName]]); if ($this->matchSubstring) { return $this->matchesSubstring($cookieName); } else { return $this->matchesFully($cookieName); } }
php
private function isCandidateCookie($cookieName) { Types::assert(['string' => [$cookieName]]); if ($this->matchSubstring) { return $this->matchesSubstring($cookieName); } else { return $this->matchesFully($cookieName); } }
[ "private", "function", "isCandidateCookie", "(", "$", "cookieName", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "cookieName", "]", "]", ")", ";", "if", "(", "$", "this", "->", "matchSubstring", ")", "{", "return", "$", "thi...
Determine whether $cookieName is a candidate for modification by the current Operation @param string $cookieName @return bool
[ "Determine", "whether", "$cookieName", "is", "a", "candidate", "for", "modification", "by", "the", "current", "Operation" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L95-L107
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.matchesSubstring
private function matchesSubstring($cookieName) { Types::assert(['string' => [$cookieName]]); foreach ($this->cookieList as $forbidden) { if (strpos(strtolower($cookieName), $forbidden) !== false) { return true; } } return ...
php
private function matchesSubstring($cookieName) { Types::assert(['string' => [$cookieName]]); foreach ($this->cookieList as $forbidden) { if (strpos(strtolower($cookieName), $forbidden) !== false) { return true; } } return ...
[ "private", "function", "matchesSubstring", "(", "$", "cookieName", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "cookieName", "]", "]", ")", ";", "foreach", "(", "$", "this", "->", "cookieList", "as", "$", "forbidden", ")", ...
Determine whether $cookieName is a candidate for modification by the current Operation's internal substring list @param string $cookieName @return bool
[ "Determine", "whether", "$cookieName", "is", "a", "candidate", "for", "modification", "by", "the", "current", "Operation", "s", "internal", "substring", "list" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L116-L129
aidantwoods/SecureHeaders
src/Operations/ModifyCookies.php
ModifyCookies.matchesFully
private function matchesFully($cookieName) { Types::assert(['string' => [$cookieName]]); return in_array( strtolower($cookieName), $this->cookieList, true ); }
php
private function matchesFully($cookieName) { Types::assert(['string' => [$cookieName]]); return in_array( strtolower($cookieName), $this->cookieList, true ); }
[ "private", "function", "matchesFully", "(", "$", "cookieName", ")", "{", "Types", "::", "assert", "(", "[", "'string'", "=>", "[", "$", "cookieName", "]", "]", ")", ";", "return", "in_array", "(", "strtolower", "(", "$", "cookieName", ")", ",", "$", "t...
Determine whether $cookieName is a candidate for modification by the current Operation's internal cookie name list @param string $cookieName @return bool
[ "Determine", "whether", "$cookieName", "is", "a", "candidate", "for", "modification", "by", "the", "current", "Operation", "s", "internal", "cookie", "name", "list" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ModifyCookies.php#L138-L147
aidantwoods/SecureHeaders
src/Operations/RemoveHeaders.php
RemoveHeaders.modify
public function modify(HeaderBag &$headers) { foreach ($this->headersToRemove as $header) { $headers->remove($header); } }
php
public function modify(HeaderBag &$headers) { foreach ($this->headersToRemove as $header) { $headers->remove($header); } }
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "foreach", "(", "$", "this", "->", "headersToRemove", "as", "$", "header", ")", "{", "$", "headers", "->", "remove", "(", "$", "header", ")", ";", "}", "}" ]
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/RemoveHeaders.php#L28-L34
aidantwoods/SecureHeaders
src/Util/Types.php
Types.assert
public static function assert(array $typeList, array $argNums = null) { $i = 0; foreach ($typeList as $type => $vars) { $type = self::normalizeType($type); foreach ($vars as $var) { $allowedTypes = explode('|', $type); $nu...
php
public static function assert(array $typeList, array $argNums = null) { $i = 0; foreach ($typeList as $type => $vars) { $type = self::normalizeType($type); foreach ($vars as $var) { $allowedTypes = explode('|', $type); $nu...
[ "public", "static", "function", "assert", "(", "array", "$", "typeList", ",", "array", "$", "argNums", "=", "null", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "typeList", "as", "$", "type", "=>", "$", "vars", ")", "{", "$", "type", "...
Assert that $typeList maps expected types to an array of that type. The type NULL is permitted (assertion assumes types are nullable). Optionally provide $argNums as an ordered list of argument numbers to be displayed in the exception message if arguments are recieved out of order, not starting at one, or have gaps fr...
[ "Assert", "that", "$typeList", "maps", "expected", "types", "to", "an", "array", "of", "that", "type", ".", "The", "type", "NULL", "is", "permitted", "(", "assertion", "assumes", "types", "are", "nullable", ")", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Util/Types.php#L19-L59
aidantwoods/SecureHeaders
src/Util/Types.php
Types.generateArgNums
private static function generateArgNums(array $typeList) { $n = array_sum(array_map( function ($vars) { return count((array) $vars); }, $typeList )); return range(1, $n); }
php
private static function generateArgNums(array $typeList) { $n = array_sum(array_map( function ($vars) { return count((array) $vars); }, $typeList )); return range(1, $n); }
[ "private", "static", "function", "generateArgNums", "(", "array", "$", "typeList", ")", "{", "$", "n", "=", "array_sum", "(", "array_map", "(", "function", "(", "$", "vars", ")", "{", "return", "count", "(", "(", "array", ")", "$", "vars", ")", ";", ...
Generate sequential argument numbers for $typeList. @param array $typeList @return int[]
[ "Generate", "sequential", "argument", "numbers", "for", "$typeList", "." ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Util/Types.php#L67-L78
aidantwoods/SecureHeaders
src/Operations/ApplySafeMode.php
ApplySafeMode.modify
public function modify(HeaderBag &$headers) { foreach ($headers->get() as $header) { $headerName = $header->getName(); $isUnsafe = array_key_exists($headerName, self::$unsafeHeaders); $hasException = array_key_exists($headerName, $this->exceptions); ...
php
public function modify(HeaderBag &$headers) { foreach ($headers->get() as $header) { $headerName = $header->getName(); $isUnsafe = array_key_exists($headerName, self::$unsafeHeaders); $hasException = array_key_exists($headerName, $this->exceptions); ...
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "->", "get", "(", ")", "as", "$", "header", ")", "{", "$", "headerName", "=", "$", "header", "->", "getName", "(", ")", ";", "$", "isUn...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ApplySafeMode.php#L36-L52
aidantwoods/SecureHeaders
src/Operations/ApplySafeMode.php
ApplySafeMode.sanitizeSTS
private function sanitizeSTS(Header $header) { $origValue = $header->getValue(); # Only do these when the attribute exists! $header->ensureAttributeMaximum('max-age', 86400); $header->removeAttribute('includeSubDomains'); $header->removeAttribute('preload'); if ($he...
php
private function sanitizeSTS(Header $header) { $origValue = $header->getValue(); # Only do these when the attribute exists! $header->ensureAttributeMaximum('max-age', 86400); $header->removeAttribute('includeSubDomains'); $header->removeAttribute('preload'); if ($he...
[ "private", "function", "sanitizeSTS", "(", "Header", "$", "header", ")", "{", "$", "origValue", "=", "$", "header", "->", "getValue", "(", ")", ";", "# Only do these when the attribute exists!", "$", "header", "->", "ensureAttributeMaximum", "(", "'max-age'", ",",...
Apply safe-mode for HSTS to $header @param Header $header @return void
[ "Apply", "safe", "-", "mode", "for", "HSTS", "to", "$header" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ApplySafeMode.php#L60-L82
aidantwoods/SecureHeaders
src/Operations/ApplySafeMode.php
ApplySafeMode.sanitizeExpectCT
private function sanitizeExpectCT(Header $header) { $origValue = $header->getValue(); # Only do these when the attributes exist $header->removeAttribute('enforce'); if ($header->getValue() !== $origValue) { $this->addError( 'Some ExpectCT setting...
php
private function sanitizeExpectCT(Header $header) { $origValue = $header->getValue(); # Only do these when the attributes exist $header->removeAttribute('enforce'); if ($header->getValue() !== $origValue) { $this->addError( 'Some ExpectCT setting...
[ "private", "function", "sanitizeExpectCT", "(", "Header", "$", "header", ")", "{", "$", "origValue", "=", "$", "header", "->", "getValue", "(", ")", ";", "# Only do these when the attributes exist", "$", "header", "->", "removeAttribute", "(", "'enforce'", ")", ...
Apply safe-mode for Expect-CT to $header @param Header $header @return void
[ "Apply", "safe", "-", "mode", "for", "Expect", "-", "CT", "to", "$header" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/ApplySafeMode.php#L112-L125
aidantwoods/SecureHeaders
src/Http/GlobalHttpAdapter.php
GlobalHttpAdapter.sendHeaders
public function sendHeaders(HeaderBag $headers) { header_remove(); foreach ($headers->get() as $header) { header( (string) $header, false ); } }
php
public function sendHeaders(HeaderBag $headers) { header_remove(); foreach ($headers->get() as $header) { header( (string) $header, false ); } }
[ "public", "function", "sendHeaders", "(", "HeaderBag", "$", "headers", ")", "{", "header_remove", "(", ")", ";", "foreach", "(", "$", "headers", "->", "get", "(", ")", "as", "$", "header", ")", "{", "header", "(", "(", "string", ")", "$", "header", "...
Send the given headers, overwriting all previously send headers @api @param HeaderBag $headers @return void
[ "Send", "the", "given", "headers", "overwriting", "all", "previously", "send", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Http/GlobalHttpAdapter.php#L17-L28
aidantwoods/SecureHeaders
src/Operations/CompileHPKP.php
CompileHPKP.modify
public function modify(HeaderBag &$headers) { $hpkpHeaders = [ 'Public-Key-Pins' => $this->compilePKP(), 'Public-Key-Pins-Report-Only' => $this->compilePKPRO(), ]; foreach ($hpkpHeaders as $header => $value) { if (empty($value)) { ...
php
public function modify(HeaderBag &$headers) { $hpkpHeaders = [ 'Public-Key-Pins' => $this->compilePKP(), 'Public-Key-Pins-Report-Only' => $this->compilePKPRO(), ]; foreach ($hpkpHeaders as $header => $value) { if (empty($value)) { ...
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "$", "hpkpHeaders", "=", "[", "'Public-Key-Pins'", "=>", "$", "this", "->", "compilePKP", "(", ")", ",", "'Public-Key-Pins-Report-Only'", "=>", "$", "this", "->", "compilePKPRO", ...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileHPKP.php#L33-L49
aidantwoods/SecureHeaders
src/Operations/CompileHPKP.php
CompileHPKP.compile
private function compile(array $config) { if (empty($config) or empty($config['pins'])) { return ''; } $maxAge = isset($config['max-age']) ? $config['max-age'] : 10; $pieces = ["max-age=$maxAge"]; foreach ($config['pins'] as $pinAlg) { ...
php
private function compile(array $config) { if (empty($config) or empty($config['pins'])) { return ''; } $maxAge = isset($config['max-age']) ? $config['max-age'] : 10; $pieces = ["max-age=$maxAge"]; foreach ($config['pins'] as $pinAlg) { ...
[ "private", "function", "compile", "(", "array", "$", "config", ")", "{", "if", "(", "empty", "(", "$", "config", ")", "or", "empty", "(", "$", "config", "[", "'pins'", "]", ")", ")", "{", "return", "''", ";", "}", "$", "maxAge", "=", "isset", "("...
Compile HPKP $config into a HPKP header-value string @param array $config @return string
[ "Compile", "HPKP", "$config", "into", "a", "HPKP", "header", "-", "value", "string" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileHPKP.php#L77-L106
aidantwoods/SecureHeaders
src/Operations/RemoveCookies.php
RemoveCookies.modify
public function modify(HeaderBag &$headers) { $cookies = $headers->getByName('set-cookie'); $headers->remove('set-cookie'); foreach ($cookies as $key => $cookie) { $cookieName = $cookie->getFirstAttributeName(); if ( ! in_array(strtolower($cookieName), $thi...
php
public function modify(HeaderBag &$headers) { $cookies = $headers->getByName('set-cookie'); $headers->remove('set-cookie'); foreach ($cookies as $key => $cookie) { $cookieName = $cookie->getFirstAttributeName(); if ( ! in_array(strtolower($cookieName), $thi...
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "$", "cookies", "=", "$", "headers", "->", "getByName", "(", "'set-cookie'", ")", ";", "$", "headers", "->", "remove", "(", "'set-cookie'", ")", ";", "foreach", "(", "$", ...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/RemoveCookies.php#L28-L43
aidantwoods/SecureHeaders
src/Operations/CompileCSP.php
CompileCSP.modify
public function modify(HeaderBag &$headers) { $cspHeaders = [ 'Content-Security-Policy' => 'csp', 'Content-Security-Policy-Report-Only' => 'cspro', ]; foreach ($cspHeaders as $header => $type) { if ($this->combine) { $o...
php
public function modify(HeaderBag &$headers) { $cspHeaders = [ 'Content-Security-Policy' => 'csp', 'Content-Security-Policy-Report-Only' => 'cspro', ]; foreach ($cspHeaders as $header => $type) { if ($this->combine) { $o...
[ "public", "function", "modify", "(", "HeaderBag", "&", "$", "headers", ")", "{", "$", "cspHeaders", "=", "[", "'Content-Security-Policy'", "=>", "'csp'", ",", "'Content-Security-Policy-Report-Only'", "=>", "'cspro'", ",", "]", ";", "foreach", "(", "$", "cspHeade...
Transform the given set of headers @param HeaderBag $headers @return void
[ "Transform", "the", "given", "set", "of", "headers" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileCSP.php#L61-L99
aidantwoods/SecureHeaders
src/Operations/CompileCSP.php
CompileCSP.compileCSPRO
private function compileCSPRO() { # Filter out the blacklisted directives $filteredConfig = array_diff_key( $this->csproConfig, array_flip($this->csproBlacklist) ); return self::compile($filteredConfig); }
php
private function compileCSPRO() { # Filter out the blacklisted directives $filteredConfig = array_diff_key( $this->csproConfig, array_flip($this->csproBlacklist) ); return self::compile($filteredConfig); }
[ "private", "function", "compileCSPRO", "(", ")", "{", "# Filter out the blacklisted directives", "$", "filteredConfig", "=", "array_diff_key", "(", "$", "this", "->", "csproConfig", ",", "array_flip", "(", "$", "this", "->", "csproBlacklist", ")", ")", ";", "retur...
Compile internal CSPRO config into a CSP header-value string @return string
[ "Compile", "internal", "CSPRO", "config", "into", "a", "CSP", "header", "-", "value", "string" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileCSP.php#L116-L125
aidantwoods/SecureHeaders
src/Operations/CompileCSP.php
CompileCSP.compile
public static function compile(array $config) { $pieces = []; foreach ($config as $directive => $sources) { if (is_array($sources)) { self::removeEmptySources($sources); self::removeDuplicateSources($sources); array_un...
php
public static function compile(array $config) { $pieces = []; foreach ($config as $directive => $sources) { if (is_array($sources)) { self::removeEmptySources($sources); self::removeDuplicateSources($sources); array_un...
[ "public", "static", "function", "compile", "(", "array", "$", "config", ")", "{", "$", "pieces", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "directive", "=>", "$", "sources", ")", "{", "if", "(", "is_array", "(", "$", "sources", ...
Compile CSP $config into a CSP header-value string @param array $config @return string
[ "Compile", "CSP", "$config", "into", "a", "CSP", "header", "-", "value", "string" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileCSP.php#L133-L155
aidantwoods/SecureHeaders
src/Operations/CompileCSP.php
CompileCSP.deconstructCSP
public static function deconstructCSP($cspString) { $csp = []; $directivesAndSources = explode(';', $cspString); foreach ($directivesAndSources as $directiveAndSources) { $directiveAndSources = ltrim($directiveAndSources); $list = explode(' ', $directiveAnd...
php
public static function deconstructCSP($cspString) { $csp = []; $directivesAndSources = explode(';', $cspString); foreach ($directivesAndSources as $directiveAndSources) { $directiveAndSources = ltrim($directiveAndSources); $list = explode(' ', $directiveAnd...
[ "public", "static", "function", "deconstructCSP", "(", "$", "cspString", ")", "{", "$", "csp", "=", "[", "]", ";", "$", "directivesAndSources", "=", "explode", "(", "';'", ",", "$", "cspString", ")", ";", "foreach", "(", "$", "directivesAndSources", "as", ...
Deconstruct $cspString into a CSP config array @param string $cspString @return array
[ "Deconstruct", "$cspString", "into", "a", "CSP", "config", "array" ]
train
https://github.com/aidantwoods/SecureHeaders/blob/6037dbfbd32dcbffd2409afd25ed6293c8e3fb43/src/Operations/CompileCSP.php#L163-L199