Search is not available for this dataset
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
sequence
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequence
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
parameters
sequence
question
stringlengths
9
114
answer
sequence
Boolive/Core
file/File.php
File.upload
static function upload($from, $to) { $result = false; if(is_uploaded_file($from)){ $to = self::makeVirtualDir($to); // Если папки нет, то создаем её $dir = dirname($to); if(!is_dir($dir)){ mkdir($dir, 0775, true); } if (is_file($to)){ unlink($to); } //Перемещаем файл если он загружен через POST $result = move_uploaded_file($from, $to); self::deleteVirtualDir($to); } return $result; }
php
static function upload($from, $to) { $result = false; if(is_uploaded_file($from)){ $to = self::makeVirtualDir($to); // Если папки нет, то создаем её $dir = dirname($to); if(!is_dir($dir)){ mkdir($dir, 0775, true); } if (is_file($to)){ unlink($to); } //Перемещаем файл если он загружен через POST $result = move_uploaded_file($from, $to); self::deleteVirtualDir($to); } return $result; }
[ "static", "function", "upload", "(", "$", "from", ",", "$", "to", ")", "{", "$", "result", "=", "false", ";", "if", "(", "is_uploaded_file", "(", "$", "from", ")", ")", "{", "$", "to", "=", "self", "::", "makeVirtualDir", "(", "$", "to", ")", ";", "// Если папки нет, то создаем её", "$", "dir", "=", "dirname", "(", "$", "to", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "if", "(", "is_file", "(", "$", "to", ")", ")", "{", "unlink", "(", "$", "to", ")", ";", "}", "//Перемещаем файл если он загружен через POST", "$", "result", "=", "move_uploaded_file", "(", "$", "from", ",", "$", "to", ")", ";", "self", "::", "deleteVirtualDir", "(", "$", "to", ")", ";", "}", "return", "$", "result", ";", "}" ]
Перемешщение загруженного файла по указанному пути @param string $from Путь к загружаемому файлу @param string $to Путь, куда файл копировать. Путь должен содерджать имя файла @return bool Признак, загружен файл или нет
[ "Перемешщение", "загруженного", "файла", "по", "указанному", "пути" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L54-L72
[ "from", "to" ]
What does this function return?
[ "bool", "Признак,", "загружен", "файл", "или", "нет" ]
Boolive/Core
file/File.php
File.copy
static function copy($from, $to) { $result = false; if (file_exists($from)){ $to = self::makeVirtualDir($to); // Если папки нет, то создаем её $dir = dirname($to); if(!is_dir($dir)){ mkdir($dir, 0775, true); } if (is_file($to)){ unlink($to); } $result = copy($from, $to); self::deleteVirtualDir($to); } return $result; }
php
static function copy($from, $to) { $result = false; if (file_exists($from)){ $to = self::makeVirtualDir($to); // Если папки нет, то создаем её $dir = dirname($to); if(!is_dir($dir)){ mkdir($dir, 0775, true); } if (is_file($to)){ unlink($to); } $result = copy($from, $to); self::deleteVirtualDir($to); } return $result; }
[ "static", "function", "copy", "(", "$", "from", ",", "$", "to", ")", "{", "$", "result", "=", "false", ";", "if", "(", "file_exists", "(", "$", "from", ")", ")", "{", "$", "to", "=", "self", "::", "makeVirtualDir", "(", "$", "to", ")", ";", "// Если папки нет, то создаем её", "$", "dir", "=", "dirname", "(", "$", "to", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "if", "(", "is_file", "(", "$", "to", ")", ")", "{", "unlink", "(", "$", "to", ")", ";", "}", "$", "result", "=", "copy", "(", "$", "from", ",", "$", "to", ")", ";", "self", "::", "deleteVirtualDir", "(", "$", "to", ")", ";", "}", "return", "$", "result", ";", "}" ]
Копирование файла @param string $from Путь к копируемому файлу @param string $to Путь, куда файл копировать. Путь должен содерджать имя файла @return bool Признак, скопирован файл или нет
[ "Копирование", "файла" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L80-L97
[ "from", "to" ]
What does this function return?
[ "bool", "Признак,", "скопирован", "файл", "или", "нет" ]
Boolive/Core
file/File.php
File.rename
static function rename($from, $to) { $result = false; if (file_exists($from)){ $to = self::makeVirtualDir($to); $dir = dirname($to); if (!is_dir($dir)) mkdir($dir, true); if (mb_strtoupper($from) != mb_strtoupper($to)){ if (is_dir($to)){ self::clear_dir($to, true); }else if (is_file($to)){ unlink($to); } } $result = rename($from, $to); self::deleteVirtualDir($to); } return $result; }
php
static function rename($from, $to) { $result = false; if (file_exists($from)){ $to = self::makeVirtualDir($to); $dir = dirname($to); if (!is_dir($dir)) mkdir($dir, true); if (mb_strtoupper($from) != mb_strtoupper($to)){ if (is_dir($to)){ self::clear_dir($to, true); }else if (is_file($to)){ unlink($to); } } $result = rename($from, $to); self::deleteVirtualDir($to); } return $result; }
[ "static", "function", "rename", "(", "$", "from", ",", "$", "to", ")", "{", "$", "result", "=", "false", ";", "if", "(", "file_exists", "(", "$", "from", ")", ")", "{", "$", "to", "=", "self", "::", "makeVirtualDir", "(", "$", "to", ")", ";", "$", "dir", "=", "dirname", "(", "$", "to", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "mkdir", "(", "$", "dir", ",", "true", ")", ";", "if", "(", "mb_strtoupper", "(", "$", "from", ")", "!=", "mb_strtoupper", "(", "$", "to", ")", ")", "{", "if", "(", "is_dir", "(", "$", "to", ")", ")", "{", "self", "::", "clear_dir", "(", "$", "to", ",", "true", ")", ";", "}", "else", "if", "(", "is_file", "(", "$", "to", ")", ")", "{", "unlink", "(", "$", "to", ")", ";", "}", "}", "$", "result", "=", "rename", "(", "$", "from", ",", "$", "to", ")", ";", "self", "::", "deleteVirtualDir", "(", "$", "to", ")", ";", "}", "return", "$", "result", ";", "}" ]
Переименование или перемещение файла @param string $from Путь к переименовываемому файлу @param string $to Путь с новым именем @return bool Признак, переименован файл или нет
[ "Переименование", "или", "перемещение", "файла" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L105-L124
[ "from", "to" ]
What does this function return?
[ "bool", "Признак,", "переименован", "файл", "или", "нет" ]
Boolive/Core
file/File.php
File.delete
static function delete($from) { $from = self::makeVirtualDir($from, false); $result = false; if (is_file($from)){ @unlink($from); $result = true; } self::deleteVirtualDir($from); return $result; }
php
static function delete($from) { $from = self::makeVirtualDir($from, false); $result = false; if (is_file($from)){ @unlink($from); $result = true; } self::deleteVirtualDir($from); return $result; }
[ "static", "function", "delete", "(", "$", "from", ")", "{", "$", "from", "=", "self", "::", "makeVirtualDir", "(", "$", "from", ",", "false", ")", ";", "$", "result", "=", "false", ";", "if", "(", "is_file", "(", "$", "from", ")", ")", "{", "@", "unlink", "(", "$", "from", ")", ";", "$", "result", "=", "true", ";", "}", "self", "::", "deleteVirtualDir", "(", "$", "from", ")", ";", "return", "$", "result", ";", "}" ]
Удаление файла @param string $from Путь к удаляемому файлу @return bool
[ "Удаление", "файла" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L131-L141
[ "from" ]
What does this function return?
[ "bool" ]
Boolive/Core
file/File.php
File.delete_empty_dir
static function delete_empty_dir($dir) { $dir = self::makeVirtualDir($dir, false); if (is_dir($dir) && sizeof(scandir($dir)) == 2){ return @rmdir($dir); } self::deleteVirtualDir($dir); return false; }
php
static function delete_empty_dir($dir) { $dir = self::makeVirtualDir($dir, false); if (is_dir($dir) && sizeof(scandir($dir)) == 2){ return @rmdir($dir); } self::deleteVirtualDir($dir); return false; }
[ "static", "function", "delete_empty_dir", "(", "$", "dir", ")", "{", "$", "dir", "=", "self", "::", "makeVirtualDir", "(", "$", "dir", ",", "false", ")", ";", "if", "(", "is_dir", "(", "$", "dir", ")", "&&", "sizeof", "(", "scandir", "(", "$", "dir", ")", ")", "==", "2", ")", "{", "return", "@", "rmdir", "(", "$", "dir", ")", ";", "}", "self", "::", "deleteVirtualDir", "(", "$", "dir", ")", ";", "return", "false", ";", "}" ]
Удаление пустой директории @param $dir @return bool
[ "Удаление", "пустой", "директории" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L148-L156
[ "dir" ]
What does this function return?
[ "bool" ]
Boolive/Core
file/File.php
File.clear_dir
static function clear_dir($dir, $delete_me = false) { $dir = self::makeVirtualDir($dir, false); $result = false; if (is_file($dir)){ $result = @unlink($dir); }else if (is_dir($dir)){ $scan = glob(rtrim($dir, '/').'/*'); foreach ($scan as $path){ self::clear_dir($path, true); } $result = $delete_me?@rmdir($dir):true; } self::deleteVirtualDir($dir); return $result; }
php
static function clear_dir($dir, $delete_me = false) { $dir = self::makeVirtualDir($dir, false); $result = false; if (is_file($dir)){ $result = @unlink($dir); }else if (is_dir($dir)){ $scan = glob(rtrim($dir, '/').'/*'); foreach ($scan as $path){ self::clear_dir($path, true); } $result = $delete_me?@rmdir($dir):true; } self::deleteVirtualDir($dir); return $result; }
[ "static", "function", "clear_dir", "(", "$", "dir", ",", "$", "delete_me", "=", "false", ")", "{", "$", "dir", "=", "self", "::", "makeVirtualDir", "(", "$", "dir", ",", "false", ")", ";", "$", "result", "=", "false", ";", "if", "(", "is_file", "(", "$", "dir", ")", ")", "{", "$", "result", "=", "@", "unlink", "(", "$", "dir", ")", ";", "}", "else", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "scan", "=", "glob", "(", "rtrim", "(", "$", "dir", ",", "'/'", ")", ".", "'/*'", ")", ";", "foreach", "(", "$", "scan", "as", "$", "path", ")", "{", "self", "::", "clear_dir", "(", "$", "path", ",", "true", ")", ";", "}", "$", "result", "=", "$", "delete_me", "?", "@", "rmdir", "(", "$", "dir", ")", ":", "true", ";", "}", "self", "::", "deleteVirtualDir", "(", "$", "dir", ")", ";", "return", "$", "result", ";", "}" ]
Удаление всех файлов и поддиректорий в указанной директории @param string $dir Путь на очищаемому директорию @param bool $delete_me Удалить указанную директорию (true) или только её содержимое (false)? @return bool Признак, выполнено ли удаление
[ "Удаление", "всех", "файлов", "и", "поддиректорий", "в", "указанной", "директории" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L164-L180
[ "dir", "delete_me" ]
What does this function return?
[ "bool", "Признак,", "выполнено", "ли", "удаление" ]
Boolive/Core
file/File.php
File.fileInfo
static function fileInfo($path, $key = null) { $path = str_replace('\\','/',$path); $list = F::explode('/', $path, -2); if (sizeof($list)<2){ array_unshift($list, ''); } $info = array('dir'=>$list[0], 'name'=>$list[1], 'base'=> '', 'ext'=>'', 'back'=>false); if (($len = mb_strlen($list[0]))>1 && mb_substr($list[0], $len-2)=='..'){ $info['back'] = true; } $list = F::explode('.', $info['name'], -2); // Если $list имеет один элемент, то это не расширение if (sizeof($list)>1){ $info['ext'] = strtolower($list[1]); }else{ $info['ext'] = ''; } $info['base'] = $list[0]; if ($key){ return $info[$key]; } return $info; }
php
static function fileInfo($path, $key = null) { $path = str_replace('\\','/',$path); $list = F::explode('/', $path, -2); if (sizeof($list)<2){ array_unshift($list, ''); } $info = array('dir'=>$list[0], 'name'=>$list[1], 'base'=> '', 'ext'=>'', 'back'=>false); if (($len = mb_strlen($list[0]))>1 && mb_substr($list[0], $len-2)=='..'){ $info['back'] = true; } $list = F::explode('.', $info['name'], -2); // Если $list имеет один элемент, то это не расширение if (sizeof($list)>1){ $info['ext'] = strtolower($list[1]); }else{ $info['ext'] = ''; } $info['base'] = $list[0]; if ($key){ return $info[$key]; } return $info; }
[ "static", "function", "fileInfo", "(", "$", "path", ",", "$", "key", "=", "null", ")", "{", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ";", "$", "list", "=", "F", "::", "explode", "(", "'/'", ",", "$", "path", ",", "-", "2", ")", ";", "if", "(", "sizeof", "(", "$", "list", ")", "<", "2", ")", "{", "array_unshift", "(", "$", "list", ",", "''", ")", ";", "}", "$", "info", "=", "array", "(", "'dir'", "=>", "$", "list", "[", "0", "]", ",", "'name'", "=>", "$", "list", "[", "1", "]", ",", "'base'", "=>", "''", ",", "'ext'", "=>", "''", ",", "'back'", "=>", "false", ")", ";", "if", "(", "(", "$", "len", "=", "mb_strlen", "(", "$", "list", "[", "0", "]", ")", ")", ">", "1", "&&", "mb_substr", "(", "$", "list", "[", "0", "]", ",", "$", "len", "-", "2", ")", "==", "'..'", ")", "{", "$", "info", "[", "'back'", "]", "=", "true", ";", "}", "$", "list", "=", "F", "::", "explode", "(", "'.'", ",", "$", "info", "[", "'name'", "]", ",", "-", "2", ")", ";", "// Если $list имеет один элемент, то это не расширение", "if", "(", "sizeof", "(", "$", "list", ")", ">", "1", ")", "{", "$", "info", "[", "'ext'", "]", "=", "strtolower", "(", "$", "list", "[", "1", "]", ")", ";", "}", "else", "{", "$", "info", "[", "'ext'", "]", "=", "''", ";", "}", "$", "info", "[", "'base'", "]", "=", "$", "list", "[", "0", "]", ";", "if", "(", "$", "key", ")", "{", "return", "$", "info", "[", "$", "key", "]", ";", "}", "return", "$", "info", ";", "}" ]
Возвращает имя и расширение файла из его пути Путь может быть относительным. Файл может отсутствовать @param string $path Путь к файлу @param null $key Какую информацию о файле возвратить? dir, name, base, ext. Если null, то возвращается всё в виде массива @return array|string Имя без расширения, расширение, полное имя файла и директория
[ "Возвращает", "имя", "и", "расширение", "файла", "из", "его", "пути", "Путь", "может", "быть", "относительным", ".", "Файл", "может", "отсутствовать" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L189-L212
[ "path", "key" ]
What does this function return?
[ "array|string", "Имя", "без", "расширения,", "расширение,", "полное", "имя", "файла", "и", "директория" ]
Boolive/Core
file/File.php
File.changeExtention
static function changeExtention($path, $ext) { $dir = dirname($path).'/'; $f = self::fileInfo($path); return $dir.$f['base'].'.'.$ext; }
php
static function changeExtention($path, $ext) { $dir = dirname($path).'/'; $f = self::fileInfo($path); return $dir.$f['base'].'.'.$ext; }
[ "static", "function", "changeExtention", "(", "$", "path", ",", "$", "ext", ")", "{", "$", "dir", "=", "dirname", "(", "$", "path", ")", ".", "'/'", ";", "$", "f", "=", "self", "::", "fileInfo", "(", "$", "path", ")", ";", "return", "$", "dir", ".", "$", "f", "[", "'base'", "]", ".", "'.'", ".", "$", "ext", ";", "}" ]
Смена расширения в имени файла. Смена имени не касается самого файла! @param string $path Путь к файлу @param string $ext Новое расширение файла @return string Новое имя файла
[ "Смена", "расширения", "в", "имени", "файла", ".", "Смена", "имени", "не", "касается", "самого", "файла!" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L221-L226
[ "path", "ext" ]
What does this function return?
[ "string", "Новое", "имя", "файла" ]
Boolive/Core
file/File.php
File.changeName
static function changeName($path, $name) { $f = self::fileInfo($path); return $f['dir'].$name.'.'.$f['ext']; }
php
static function changeName($path, $name) { $f = self::fileInfo($path); return $f['dir'].$name.'.'.$f['ext']; }
[ "static", "function", "changeName", "(", "$", "path", ",", "$", "name", ")", "{", "$", "f", "=", "self", "::", "fileInfo", "(", "$", "path", ")", ";", "return", "$", "f", "[", "'dir'", "]", ".", "$", "name", ".", "'.'", ".", "$", "f", "[", "'ext'", "]", ";", "}" ]
Смена имени файла не меняя расширения. Смена имени не касается самого файла! @param string $path Путь к файлу @param string $name Новое имя файла без расширения @return string Новое имя файла
[ "Смена", "имени", "файла", "не", "меняя", "расширения", ".", "Смена", "имени", "не", "касается", "самого", "файла!" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L235-L239
[ "path", "name" ]
What does this function return?
[ "string", "Новое", "имя", "файла" ]
Boolive/Core
file/File.php
File.fileExtention
static function fileExtention($path) { $list = F::explode('.', $path, -2); if (sizeof($list)>1){ return strtolower($list[1]); }else{ return ''; } }
php
static function fileExtention($path) { $list = F::explode('.', $path, -2); if (sizeof($list)>1){ return strtolower($list[1]); }else{ return ''; } }
[ "static", "function", "fileExtention", "(", "$", "path", ")", "{", "$", "list", "=", "F", "::", "explode", "(", "'.'", ",", "$", "path", ",", "-", "2", ")", ";", "if", "(", "sizeof", "(", "$", "list", ")", ">", "1", ")", "{", "return", "strtolower", "(", "$", "list", "[", "1", "]", ")", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Расширение файла @param $path @return mixed
[ "Расширение", "файла" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L257-L265
[ "path" ]
What does this function return?
[ "mixed" ]
Boolive/Core
file/File.php
File.makeUniqueName
static function makeUniqueName($dir, $name, $ext, $start = 1) { self::makeVirtualDir($dir); $i = 0; $to = $dir.$name.$ext; while (file_exists($to) && $i<100){ $to = $dir.$name.(++$i+$start).$ext; } $result = ($i < 100+$start)? false : $to; self::deleteVirtualDir($dir); return $result; }
php
static function makeUniqueName($dir, $name, $ext, $start = 1) { self::makeVirtualDir($dir); $i = 0; $to = $dir.$name.$ext; while (file_exists($to) && $i<100){ $to = $dir.$name.(++$i+$start).$ext; } $result = ($i < 100+$start)? false : $to; self::deleteVirtualDir($dir); return $result; }
[ "static", "function", "makeUniqueName", "(", "$", "dir", ",", "$", "name", ",", "$", "ext", ",", "$", "start", "=", "1", ")", "{", "self", "::", "makeVirtualDir", "(", "$", "dir", ")", ";", "$", "i", "=", "0", ";", "$", "to", "=", "$", "dir", ".", "$", "name", ".", "$", "ext", ";", "while", "(", "file_exists", "(", "$", "to", ")", "&&", "$", "i", "<", "100", ")", "{", "$", "to", "=", "$", "dir", ".", "$", "name", ".", "(", "++", "$", "i", "+", "$", "start", ")", ".", "$", "ext", ";", "}", "$", "result", "=", "(", "$", "i", "<", "100", "+", "$", "start", ")", "?", "false", ":", "$", "to", ";", "self", "::", "deleteVirtualDir", "(", "$", "dir", ")", ";", "return", "$", "result", ";", "}" ]
Создание уникального имени для файла или директории @param string $dir Директория со слэшем на конце, в которой подобрать уникальное имя @param string $name Базовое имя, к которому будут добавляться числовые префиксы для уникальности @param string $ext Расширение с точкой, присваиваемое к имени после подбора @param int $start Начальное значение для префикса @return string|bool Уникальное имя вместе с путём или false, если не удалось подобрать
[ "Создание", "уникального", "имени", "для", "файла", "или", "директории" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L275-L286
[ "dir", "name", "ext", "start" ]
What does this function return?
[ "string|bool", "Уникальное", "имя", "вместе", "с", "путём", "или", "false,", "если", "не", "удалось", "подобрать" ]
Boolive/Core
file/File.php
File.makeUniqueDir
static function makeUniqueDir($dir, $name, $start = 1, $find = true) { self::makeVirtualDir($dir); $max = $start + 1000; $i = $start; $path = $dir.$name; do { try{ if ($result = mkdir($path, 0775, true)){ $result = $path; } }catch (\Exception $e){ $result = false; } $path = $dir . $name . $i; $i++; }while($find && !$result && $i < $max); self::deleteVirtualDir($dir); return $result; }
php
static function makeUniqueDir($dir, $name, $start = 1, $find = true) { self::makeVirtualDir($dir); $max = $start + 1000; $i = $start; $path = $dir.$name; do { try{ if ($result = mkdir($path, 0775, true)){ $result = $path; } }catch (\Exception $e){ $result = false; } $path = $dir . $name . $i; $i++; }while($find && !$result && $i < $max); self::deleteVirtualDir($dir); return $result; }
[ "static", "function", "makeUniqueDir", "(", "$", "dir", ",", "$", "name", ",", "$", "start", "=", "1", ",", "$", "find", "=", "true", ")", "{", "self", "::", "makeVirtualDir", "(", "$", "dir", ")", ";", "$", "max", "=", "$", "start", "+", "1000", ";", "$", "i", "=", "$", "start", ";", "$", "path", "=", "$", "dir", ".", "$", "name", ";", "do", "{", "try", "{", "if", "(", "$", "result", "=", "mkdir", "(", "$", "path", ",", "0775", ",", "true", ")", ")", "{", "$", "result", "=", "$", "path", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "result", "=", "false", ";", "}", "$", "path", "=", "$", "dir", ".", "$", "name", ".", "$", "i", ";", "$", "i", "++", ";", "}", "while", "(", "$", "find", "&&", "!", "$", "result", "&&", "$", "i", "<", "$", "max", ")", ";", "self", "::", "deleteVirtualDir", "(", "$", "dir", ")", ";", "return", "$", "result", ";", "}" ]
Создание уникальной директории @param string $dir Директория со слэшем на конце, в которой подобрать уникальное имя @param string $name Базовое имя, к которому будут добавляться числовые префиксы для уникальности @param int $start Начальное значение для префикса @param bool $find Признак подбирать уникальное имя @return string|bool Уникальное имя вместе с путём или false, если не удалось подобрать
[ "Создание", "уникальной", "директории" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L296-L315
[ "dir", "name", "start", "find" ]
What does this function return?
[ "string|bool", "Уникальное", "имя", "вместе", "с", "путём", "или", "false,", "если", "не", "удалось", "подобрать" ]
Boolive/Core
file/File.php
File.uploadErrorMmessage
static function uploadErrorMmessage($error_code) { switch ($error_code) { case UPLOAD_ERR_INI_SIZE: return 'Превышен максимально допустимый размер файла'; case UPLOAD_ERR_FORM_SIZE: return 'Превышен максимально допустимый размер, указанный в html форме'; case UPLOAD_ERR_PARTIAL: return 'Файл загружен не полностью'; case UPLOAD_ERR_NO_TMP_DIR: return 'Файл не сохранен во временной директории'; case UPLOAD_ERR_CANT_WRITE: return 'Ошибка записи файла на диск'; case UPLOAD_ERR_EXTENSION: return 'Загрузка файла прервана сервером'; case UPLOAD_ERR_NO_FILE: default: return 'Файл не загружен'; } }
php
static function uploadErrorMmessage($error_code) { switch ($error_code) { case UPLOAD_ERR_INI_SIZE: return 'Превышен максимально допустимый размер файла'; case UPLOAD_ERR_FORM_SIZE: return 'Превышен максимально допустимый размер, указанный в html форме'; case UPLOAD_ERR_PARTIAL: return 'Файл загружен не полностью'; case UPLOAD_ERR_NO_TMP_DIR: return 'Файл не сохранен во временной директории'; case UPLOAD_ERR_CANT_WRITE: return 'Ошибка записи файла на диск'; case UPLOAD_ERR_EXTENSION: return 'Загрузка файла прервана сервером'; case UPLOAD_ERR_NO_FILE: default: return 'Файл не загружен'; } }
[ "static", "function", "uploadErrorMmessage", "(", "$", "error_code", ")", "{", "switch", "(", "$", "error_code", ")", "{", "case", "UPLOAD_ERR_INI_SIZE", ":", "return", "'Превышен максимально допустимый размер файла';", "", "case", "UPLOAD_ERR_FORM_SIZE", ":", "return", "'Превышен максимально допустимый размер, указанный в html форме';", "", "case", "UPLOAD_ERR_PARTIAL", ":", "return", "'Файл загружен не полностью';", "", "case", "UPLOAD_ERR_NO_TMP_DIR", ":", "return", "'Файл не сохранен во временной директории';", "", "case", "UPLOAD_ERR_CANT_WRITE", ":", "return", "'Ошибка записи файла на диск';", "", "case", "UPLOAD_ERR_EXTENSION", ":", "return", "'Загрузка файла прервана сервером';", "", "case", "UPLOAD_ERR_NO_FILE", ":", "default", ":", "return", "'Файл не загружен';", "", "}", "}" ]
Текст ошибки загрзки файла @param int $error_code Код ошибки @return string
[ "Текст", "ошибки", "загрзки", "файла" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L322-L341
[ "error_code" ]
What does this function return?
[ "string" ]
Boolive/Core
file/File.php
File.getDirSize
static function getDirSize($dir) { $size = 0; $dirs = array_diff(scandir($dir), array('.', '..')); foreach ($dirs as $d){ $d = $dir.'/'.$d; $size+= filesize($d); if (is_dir($d)){ $size+= self::getDirSize($d); } } return $size; }
php
static function getDirSize($dir) { $size = 0; $dirs = array_diff(scandir($dir), array('.', '..')); foreach ($dirs as $d){ $d = $dir.'/'.$d; $size+= filesize($d); if (is_dir($d)){ $size+= self::getDirSize($d); } } return $size; }
[ "static", "function", "getDirSize", "(", "$", "dir", ")", "{", "$", "size", "=", "0", ";", "$", "dirs", "=", "array_diff", "(", "scandir", "(", "$", "dir", ")", ",", "array", "(", "'.'", ",", "'..'", ")", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "d", ")", "{", "$", "d", "=", "$", "dir", ".", "'/'", ".", "$", "d", ";", "$", "size", "+=", "filesize", "(", "$", "d", ")", ";", "if", "(", "is_dir", "(", "$", "d", ")", ")", "{", "$", "size", "+=", "self", "::", "getDirSize", "(", "$", "d", ")", ";", "}", "}", "return", "$", "size", ";", "}" ]
Размер директории в байтах @param string $dir Путь на директорию @return int
[ "Размер", "директории", "в", "байтах" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L359-L371
[ "dir" ]
What does this function return?
[ "int" ]
Boolive/Core
file/File.php
File.makeDirName
static function makeDirName($id, $size=3, $depth=3) { $size = intval(max(1, $size)); $depth = intval(max(1,$depth)); $id = self::clearFileName($id); $id = str_repeat('0',max(0, $size*$depth-strlen($id))).$id; $dir = ''; for ($i=1; $i<$depth; $i++){ $dir = substr($id,-$size*$i, $size).'/'.$dir; } return (substr($id,0, -$size*($i-1))).'/'.$dir; }
php
static function makeDirName($id, $size=3, $depth=3) { $size = intval(max(1, $size)); $depth = intval(max(1,$depth)); $id = self::clearFileName($id); $id = str_repeat('0',max(0, $size*$depth-strlen($id))).$id; $dir = ''; for ($i=1; $i<$depth; $i++){ $dir = substr($id,-$size*$i, $size).'/'.$dir; } return (substr($id,0, -$size*($i-1))).'/'.$dir; }
[ "static", "function", "makeDirName", "(", "$", "id", ",", "$", "size", "=", "3", ",", "$", "depth", "=", "3", ")", "{", "$", "size", "=", "intval", "(", "max", "(", "1", ",", "$", "size", ")", ")", ";", "$", "depth", "=", "intval", "(", "max", "(", "1", ",", "$", "depth", ")", ")", ";", "$", "id", "=", "self", "::", "clearFileName", "(", "$", "id", ")", ";", "$", "id", "=", "str_repeat", "(", "'0'", ",", "max", "(", "0", ",", "$", "size", "*", "$", "depth", "-", "strlen", "(", "$", "id", ")", ")", ")", ".", "$", "id", ";", "$", "dir", "=", "''", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "depth", ";", "$", "i", "++", ")", "{", "$", "dir", "=", "substr", "(", "$", "id", ",", "-", "$", "size", "*", "$", "i", ",", "$", "size", ")", ".", "'/'", ".", "$", "dir", ";", "}", "return", "(", "substr", "(", "$", "id", ",", "0", ",", "-", "$", "size", "*", "(", "$", "i", "-", "1", ")", ")", ")", ".", "'/'", ".", "$", "dir", ";", "}" ]
Создание пути на директорию из идентификатора @param string $id Идентификатор, который режится на имена директорий. При недостаточности длины добавляются нули. @param int $size Длина для имен директорий @param int $depth Вложенность директорий @return string
[ "Создание", "пути", "на", "директорию", "из", "идентификатора" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L380-L391
[ "id", "size", "depth" ]
What does this function return?
[ "string" ]
Boolive/Core
file/File.php
File.makeVirtualDir
static function makeVirtualDir($dir, $mkdir = true) { if (self::$IS_WIN && mb_strlen($dir) > 248){ $dir = preg_replace('/\\\\/u','/', $dir); $vdir = mb_substr($dir, 0, 248); $vdir = F::splitRight('/', $vdir); if ($vdir[0]){ $vdir = $vdir[0]; if (!is_dir($vdir)){ if ($mkdir){ mkdir($vdir, 0775, true); }else{ return $dir; } } $dir = self::VIRT_DISK.':/'.mb_substr($dir, mb_strlen($vdir)+1); system('subst '.self::VIRT_DISK.': '.$vdir); } } return $dir; }
php
static function makeVirtualDir($dir, $mkdir = true) { if (self::$IS_WIN && mb_strlen($dir) > 248){ $dir = preg_replace('/\\\\/u','/', $dir); $vdir = mb_substr($dir, 0, 248); $vdir = F::splitRight('/', $vdir); if ($vdir[0]){ $vdir = $vdir[0]; if (!is_dir($vdir)){ if ($mkdir){ mkdir($vdir, 0775, true); }else{ return $dir; } } $dir = self::VIRT_DISK.':/'.mb_substr($dir, mb_strlen($vdir)+1); system('subst '.self::VIRT_DISK.': '.$vdir); } } return $dir; }
[ "static", "function", "makeVirtualDir", "(", "$", "dir", ",", "$", "mkdir", "=", "true", ")", "{", "if", "(", "self", "::", "$", "IS_WIN", "&&", "mb_strlen", "(", "$", "dir", ")", ">", "248", ")", "{", "$", "dir", "=", "preg_replace", "(", "'/\\\\\\\\/u'", ",", "'/'", ",", "$", "dir", ")", ";", "$", "vdir", "=", "mb_substr", "(", "$", "dir", ",", "0", ",", "248", ")", ";", "$", "vdir", "=", "F", "::", "splitRight", "(", "'/'", ",", "$", "vdir", ")", ";", "if", "(", "$", "vdir", "[", "0", "]", ")", "{", "$", "vdir", "=", "$", "vdir", "[", "0", "]", ";", "if", "(", "!", "is_dir", "(", "$", "vdir", ")", ")", "{", "if", "(", "$", "mkdir", ")", "{", "mkdir", "(", "$", "vdir", ",", "0775", ",", "true", ")", ";", "}", "else", "{", "return", "$", "dir", ";", "}", "}", "$", "dir", "=", "self", "::", "VIRT_DISK", ".", "':/'", ".", "mb_substr", "(", "$", "dir", ",", "mb_strlen", "(", "$", "vdir", ")", "+", "1", ")", ";", "system", "(", "'subst '", ".", "self", "::", "VIRT_DISK", ".", "': '", ".", "$", "vdir", ")", ";", "}", "}", "return", "$", "dir", ";", "}" ]
Создание виртуального диска в Windows, для увеличения лимита на длину пути к файлам @param $dir @param bool $mkdir @return mixed|string
[ "Создание", "виртуального", "диска", "в", "Windows", "для", "увеличения", "лимита", "на", "длину", "пути", "к", "файлам" ]
train
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L399-L419
[ "dir", "mkdir" ]
What does this function return?
[ "mixed|string" ]
asbamboo/http
Client.php
Client.getCurloptHttpHeader
private function getCurloptHttpHeader(RequestInterface $Request) : array { $options = []; $headers = $Request->getHeaders(); foreach ($headers as $name => $values) { $header = strtolower($name); if ('expect' === $header) { // curl-client does not support "Expect-Continue", so dropping "expect" headers continue; } foreach ($values as $value) { $options[] = $name . ': ' . $value; } } /* * curl-client does not support "Expect-Continue", but cURL adds "Expect" header by default. * We can not suppress it, but we can set it to empty. */ $options[] = 'Expect:'; return $options; }
php
private function getCurloptHttpHeader(RequestInterface $Request) : array { $options = []; $headers = $Request->getHeaders(); foreach ($headers as $name => $values) { $header = strtolower($name); if ('expect' === $header) { // curl-client does not support "Expect-Continue", so dropping "expect" headers continue; } foreach ($values as $value) { $options[] = $name . ': ' . $value; } } /* * curl-client does not support "Expect-Continue", but cURL adds "Expect" header by default. * We can not suppress it, but we can set it to empty. */ $options[] = 'Expect:'; return $options; }
[ "private", "function", "getCurloptHttpHeader", "(", "RequestInterface", "$", "Request", ")", ":", "array", "{", "$", "options", "=", "[", "]", ";", "$", "headers", "=", "$", "Request", "->", "getHeaders", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "values", ")", "{", "$", "header", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "'expect'", "===", "$", "header", ")", "{", "// curl-client does not support \"Expect-Continue\", so dropping \"expect\" headers", "continue", ";", "}", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "options", "[", "]", "=", "$", "name", ".", "': '", ".", "$", "value", ";", "}", "}", "/*\n * curl-client does not support \"Expect-Continue\", but cURL adds \"Expect\" header by default.\n * We can not suppress it, but we can set it to empty.\n */", "$", "options", "[", "]", "=", "'Expect:'", ";", "return", "$", "options", ";", "}" ]
返回curl option CURLOPT_HTTPHEADER @param RequestInterface $Request @return array
[ "返回curl", "option", "CURLOPT_HTTPHEADER" ]
train
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L170-L191
[ "RequestInterface" ]
What does this function return?
[ "array" ]
asbamboo/http
Client.php
Client.getCurloptHttpVersion
private function getCurloptHttpVersion(RequestInterface $Request) : int { switch($Request->getProtocolVersion()){ case '1.0': return CURL_HTTP_VERSION_1_0; case '1.1': return CURL_HTTP_VERSION_1_1; case '2.0': return CURL_HTTP_VERSION_2_0; } return CURL_HTTP_VERSION_NONE; }
php
private function getCurloptHttpVersion(RequestInterface $Request) : int { switch($Request->getProtocolVersion()){ case '1.0': return CURL_HTTP_VERSION_1_0; case '1.1': return CURL_HTTP_VERSION_1_1; case '2.0': return CURL_HTTP_VERSION_2_0; } return CURL_HTTP_VERSION_NONE; }
[ "private", "function", "getCurloptHttpVersion", "(", "RequestInterface", "$", "Request", ")", ":", "int", "{", "switch", "(", "$", "Request", "->", "getProtocolVersion", "(", ")", ")", "{", "case", "'1.0'", ":", "return", "CURL_HTTP_VERSION_1_0", ";", "case", "'1.1'", ":", "return", "CURL_HTTP_VERSION_1_1", ";", "case", "'2.0'", ":", "return", "CURL_HTTP_VERSION_2_0", ";", "}", "return", "CURL_HTTP_VERSION_NONE", ";", "}" ]
返回curl option CURLOPT_HTTP_VERSION @param RequestInterface $Request @return int
[ "返回curl", "option", "CURLOPT_HTTP_VERSION" ]
train
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L199-L210
[ "RequestInterface" ]
What does this function return?
[ "int" ]
asbamboo/http
Client.php
Client.getCurloptHeaderFunction
private function getCurloptHeaderFunction() : callable { return function($ch, $data){ $str = trim($data); if('' !== $str){ if(strpos(strtolower($str), 'http/') === 0){ $status_line = $str; @list($http_version, $http_code, $reason_phrase) = explode(' ', $status_line, 3); $this->Response = $this->Response->withStatus((int) $http_code, (string) $reason_phrase); $this->Response = $this->Response->withProtocolVersion((string) $http_version); }else{ $header_line = $str; @list($name, $value) = explode(':', $header_line, 2); $this->Response = $this->Response->withAddedHeader(trim((string) $name), trim((string) $value)); } } return strlen($data); }; }
php
private function getCurloptHeaderFunction() : callable { return function($ch, $data){ $str = trim($data); if('' !== $str){ if(strpos(strtolower($str), 'http/') === 0){ $status_line = $str; @list($http_version, $http_code, $reason_phrase) = explode(' ', $status_line, 3); $this->Response = $this->Response->withStatus((int) $http_code, (string) $reason_phrase); $this->Response = $this->Response->withProtocolVersion((string) $http_version); }else{ $header_line = $str; @list($name, $value) = explode(':', $header_line, 2); $this->Response = $this->Response->withAddedHeader(trim((string) $name), trim((string) $value)); } } return strlen($data); }; }
[ "private", "function", "getCurloptHeaderFunction", "(", ")", ":", "callable", "{", "return", "function", "(", "$", "ch", ",", "$", "data", ")", "{", "$", "str", "=", "trim", "(", "$", "data", ")", ";", "if", "(", "''", "!==", "$", "str", ")", "{", "if", "(", "strpos", "(", "strtolower", "(", "$", "str", ")", ",", "'http/'", ")", "===", "0", ")", "{", "$", "status_line", "=", "$", "str", ";", "@", "list", "(", "$", "http_version", ",", "$", "http_code", ",", "$", "reason_phrase", ")", "=", "explode", "(", "' '", ",", "$", "status_line", ",", "3", ")", ";", "$", "this", "->", "Response", "=", "$", "this", "->", "Response", "->", "withStatus", "(", "(", "int", ")", "$", "http_code", ",", "(", "string", ")", "$", "reason_phrase", ")", ";", "$", "this", "->", "Response", "=", "$", "this", "->", "Response", "->", "withProtocolVersion", "(", "(", "string", ")", "$", "http_version", ")", ";", "}", "else", "{", "$", "header_line", "=", "$", "str", ";", "@", "list", "(", "$", "name", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "header_line", ",", "2", ")", ";", "$", "this", "->", "Response", "=", "$", "this", "->", "Response", "->", "withAddedHeader", "(", "trim", "(", "(", "string", ")", "$", "name", ")", ",", "trim", "(", "(", "string", ")", "$", "value", ")", ")", ";", "}", "}", "return", "strlen", "(", "$", "data", ")", ";", "}", ";", "}" ]
返回curl option CURLOPT_HEADERFUNCTION @return callable
[ "返回curl", "option", "CURLOPT_HEADERFUNCTION" ]
train
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L217-L235
[]
What does this function return?
[ "callable" ]
Vyki/mva-dbm
src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php
ConnectionPanel.getTab
public function getTab() { if (headers_sent() && !session_id()) { return; } ob_start(); $count = $this->count; $queries = $this->queries; require __DIR__ . '/templates/ConnectionPanel.tab.phtml'; return ob_get_clean(); }
php
public function getTab() { if (headers_sent() && !session_id()) { return; } ob_start(); $count = $this->count; $queries = $this->queries; require __DIR__ . '/templates/ConnectionPanel.tab.phtml'; return ob_get_clean(); }
[ "public", "function", "getTab", "(", ")", "{", "if", "(", "headers_sent", "(", ")", "&&", "!", "session_id", "(", ")", ")", "{", "return", ";", "}", "ob_start", "(", ")", ";", "$", "count", "=", "$", "this", "->", "count", ";", "$", "queries", "=", "$", "this", "->", "queries", ";", "require", "__DIR__", ".", "'/templates/ConnectionPanel.tab.phtml'", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Renders tab. @return string
[ "Renders", "tab", "." ]
train
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php#L63-L74
[]
What does this function return?
[ "string" ]
Vyki/mva-dbm
src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php
ConnectionPanel.getPanel
public function getPanel() { ob_start(); if (!$this->count) { return; } $count = $this->count; $queries = $this->queries; require __DIR__ . '/templates/ConnectionPanel.panel.phtml'; return ob_get_clean(); }
php
public function getPanel() { ob_start(); if (!$this->count) { return; } $count = $this->count; $queries = $this->queries; require __DIR__ . '/templates/ConnectionPanel.panel.phtml'; return ob_get_clean(); }
[ "public", "function", "getPanel", "(", ")", "{", "ob_start", "(", ")", ";", "if", "(", "!", "$", "this", "->", "count", ")", "{", "return", ";", "}", "$", "count", "=", "$", "this", "->", "count", ";", "$", "queries", "=", "$", "this", "->", "queries", ";", "require", "__DIR__", ".", "'/templates/ConnectionPanel.panel.phtml'", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Renders panel. @return string
[ "Renders", "panel", "." ]
train
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php#L80-L92
[]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.&
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); if (self::$appRoot === NULL) self::$appRoot = $this->request->GetAppRoot(); if (self::$basePath === NULL) self::$basePath = $this->request->GetBasePath(); if (self::$scriptName === NULL) self::$scriptName = ltrim($this->request->GetScriptName(), '/.'); $app = $view->GetController()->GetApplication(); $configClass =$app->GetConfigClass(); self::$loggingAndExceptions = $configClass::IsDevelopment(TRUE); $mvcCoreCompiledMode = $app->GetCompiled(); self::$ctrlActionKey = $this->request->GetControllerName() . '/' . $this->request->GetActionName(); // file checking is true only for classic development mode, not for single file mode if (!$mvcCoreCompiledMode) self::$fileChecking = TRUE; // file rendering is true for classic development state, SFU app mode if (!$mvcCoreCompiledMode || $mvcCoreCompiledMode == 'SFU') { self::$fileRendering = TRUE; } if (is_null(self::$assetsUrlCompletion)) { // set URL addresses completion to true by default for: // - all package modes outside PHP_STRICT_HDD and outside development if ($mvcCoreCompiledMode && $mvcCoreCompiledMode != 'PHP_STRICT_HDD') { self::$assetsUrlCompletion = TRUE; } else { self::$assetsUrlCompletion = FALSE; } } self::$systemConfigHash = md5(json_encode(self::$globalOptions)); return $this; }
php
public function & SetView (\MvcCore\IView & $view) { parent::SetView($view); if (self::$appRoot === NULL) self::$appRoot = $this->request->GetAppRoot(); if (self::$basePath === NULL) self::$basePath = $this->request->GetBasePath(); if (self::$scriptName === NULL) self::$scriptName = ltrim($this->request->GetScriptName(), '/.'); $app = $view->GetController()->GetApplication(); $configClass =$app->GetConfigClass(); self::$loggingAndExceptions = $configClass::IsDevelopment(TRUE); $mvcCoreCompiledMode = $app->GetCompiled(); self::$ctrlActionKey = $this->request->GetControllerName() . '/' . $this->request->GetActionName(); // file checking is true only for classic development mode, not for single file mode if (!$mvcCoreCompiledMode) self::$fileChecking = TRUE; // file rendering is true for classic development state, SFU app mode if (!$mvcCoreCompiledMode || $mvcCoreCompiledMode == 'SFU') { self::$fileRendering = TRUE; } if (is_null(self::$assetsUrlCompletion)) { // set URL addresses completion to true by default for: // - all package modes outside PHP_STRICT_HDD and outside development if ($mvcCoreCompiledMode && $mvcCoreCompiledMode != 'PHP_STRICT_HDD') { self::$assetsUrlCompletion = TRUE; } else { self::$assetsUrlCompletion = FALSE; } } self::$systemConfigHash = md5(json_encode(self::$globalOptions)); return $this; }
[ "public", "function", "&", "SetView", "(", "\\", "MvcCore", "\\", "IView", "&", "$", "view", ")", "{", "parent", "::", "SetView", "(", "$", "view", ")", ";", "if", "(", "self", "::", "$", "appRoot", "===", "NULL", ")", "self", "::", "$", "appRoot", "=", "$", "this", "->", "request", "->", "GetAppRoot", "(", ")", ";", "if", "(", "self", "::", "$", "basePath", "===", "NULL", ")", "self", "::", "$", "basePath", "=", "$", "this", "->", "request", "->", "GetBasePath", "(", ")", ";", "if", "(", "self", "::", "$", "scriptName", "===", "NULL", ")", "self", "::", "$", "scriptName", "=", "ltrim", "(", "$", "this", "->", "request", "->", "GetScriptName", "(", ")", ",", "'/.'", ")", ";", "$", "app", "=", "$", "view", "->", "GetController", "(", ")", "->", "GetApplication", "(", ")", ";", "$", "configClass", "=", "$", "app", "->", "GetConfigClass", "(", ")", ";", "self", "::", "$", "loggingAndExceptions", "=", "$", "configClass", "::", "IsDevelopment", "(", "TRUE", ")", ";", "$", "mvcCoreCompiledMode", "=", "$", "app", "->", "GetCompiled", "(", ")", ";", "self", "::", "$", "ctrlActionKey", "=", "$", "this", "->", "request", "->", "GetControllerName", "(", ")", ".", "'/'", ".", "$", "this", "->", "request", "->", "GetActionName", "(", ")", ";", "// file checking is true only for classic development mode, not for single file mode", "if", "(", "!", "$", "mvcCoreCompiledMode", ")", "self", "::", "$", "fileChecking", "=", "TRUE", ";", "// file rendering is true for classic development state, SFU app mode", "if", "(", "!", "$", "mvcCoreCompiledMode", "||", "$", "mvcCoreCompiledMode", "==", "'SFU'", ")", "{", "self", "::", "$", "fileRendering", "=", "TRUE", ";", "}", "if", "(", "is_null", "(", "self", "::", "$", "assetsUrlCompletion", ")", ")", "{", "// set URL addresses completion to true by default for:", "// - all package modes outside PHP_STRICT_HDD and outside development", "if", "(", "$", "mvcCoreCompiledMode", "&&", "$", "mvcCoreCompiledMode", "!=", "'PHP_STRICT_HDD'", ")", "{", "self", "::", "$", "assetsUrlCompletion", "=", "TRUE", ";", "}", "else", "{", "self", "::", "$", "assetsUrlCompletion", "=", "FALSE", ";", "}", "}", "self", "::", "$", "systemConfigHash", "=", "md5", "(", "json_encode", "(", "self", "::", "$", "globalOptions", ")", ")", ";", "return", "$", "this", ";", "}" ]
Insert a \MvcCore\View in each helper constructing @param \MvcCore\View|\MvcCore\IView $view @return \MvcCore\Ext\Views\Helpers\AbstractHelper
[ "Insert", "a", "\\", "MvcCore", "\\", "View", "in", "each", "helper", "constructing" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L150-L184
[ "MvcCoreIView" ]
What does this function return?
[ "\\MvcCore\\Ext\\Views\\Helpers\\AbstractHelper" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.SetGlobalOptions
public static function SetGlobalOptions ($options = []) { self::$globalOptions = array_merge(self::$globalOptions, (array) $options); if (isset($options['assetsUrl']) && !is_null($options['assetsUrl'])) { self::$assetsUrlCompletion = (bool) $options['assetsUrl']; } }
php
public static function SetGlobalOptions ($options = []) { self::$globalOptions = array_merge(self::$globalOptions, (array) $options); if (isset($options['assetsUrl']) && !is_null($options['assetsUrl'])) { self::$assetsUrlCompletion = (bool) $options['assetsUrl']; } }
[ "public", "static", "function", "SetGlobalOptions", "(", "$", "options", "=", "[", "]", ")", "{", "self", "::", "$", "globalOptions", "=", "array_merge", "(", "self", "::", "$", "globalOptions", ",", "(", "array", ")", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'assetsUrl'", "]", ")", "&&", "!", "is_null", "(", "$", "options", "[", "'assetsUrl'", "]", ")", ")", "{", "self", "::", "$", "assetsUrlCompletion", "=", "(", "bool", ")", "$", "options", "[", "'assetsUrl'", "]", ";", "}", "}" ]
Set global static options about minifying and joining together which can bee overwritten by single settings throw calling for example: append() method as another param. @see \MvcCore\Ext\Views\Helpers\Assets::$globalOptions @param array $options whether or not to auto escape output @return void
[ "Set", "global", "static", "options", "about", "minifying", "and", "joining", "together", "which", "can", "bee", "overwritten", "by", "single", "settings", "throw", "calling", "for", "example", ":", "append", "()", "method", "as", "another", "param", "." ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L195-L200
[ "options" ]
What does this function return?
[ "void" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.getFileImprint
protected static function getFileImprint ($fullPath) { $fileChecking = self::$globalOptions['fileChecking']; if ($fileChecking == 'filemtime') { return filemtime($fullPath); } else { return (string) call_user_func($fileChecking, $fullPath); } }
php
protected static function getFileImprint ($fullPath) { $fileChecking = self::$globalOptions['fileChecking']; if ($fileChecking == 'filemtime') { return filemtime($fullPath); } else { return (string) call_user_func($fileChecking, $fullPath); } }
[ "protected", "static", "function", "getFileImprint", "(", "$", "fullPath", ")", "{", "$", "fileChecking", "=", "self", "::", "$", "globalOptions", "[", "'fileChecking'", "]", ";", "if", "(", "$", "fileChecking", "==", "'filemtime'", ")", "{", "return", "filemtime", "(", "$", "fullPath", ")", ";", "}", "else", "{", "return", "(", "string", ")", "call_user_func", "(", "$", "fileChecking", ",", "$", "fullPath", ")", ";", "}", "}" ]
Returns file modification imprint by global settings - by `md5_file()` or by `filemtime()` - always as a string @param string $fullPath @return string
[ "Returns", "file", "modification", "imprint", "by", "global", "settings", "-", "by", "md5_file", "()", "or", "by", "filemtime", "()", "-", "always", "as", "a", "string" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L231-L238
[ "fullPath" ]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.AssetUrl
public function AssetUrl ($path = '') { $result = ''; if (self::$assetsUrlCompletion) { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD' $result = self::$scriptName . '?controller=controller&action=asset&path=' . $path; } else { // for \MvcCore\Application::GetInstance()->GetCompiled(), by default equal to: '' (development), 'PHP_STRICT_HDD' //$result = self::$basePath . $path; $result = '__RELATIVE_BASE_PATH__' . $path; } return $result; }
php
public function AssetUrl ($path = '') { $result = ''; if (self::$assetsUrlCompletion) { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD' $result = self::$scriptName . '?controller=controller&action=asset&path=' . $path; } else { // for \MvcCore\Application::GetInstance()->GetCompiled(), by default equal to: '' (development), 'PHP_STRICT_HDD' //$result = self::$basePath . $path; $result = '__RELATIVE_BASE_PATH__' . $path; } return $result; }
[ "public", "function", "AssetUrl", "(", "$", "path", "=", "''", ")", "{", "$", "result", "=", "''", ";", "if", "(", "self", "::", "$", "assetsUrlCompletion", ")", "{", "// for \\MvcCore\\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD'", "$", "result", "=", "self", "::", "$", "scriptName", ".", "'?controller=controller&action=asset&path='", ".", "$", "path", ";", "}", "else", "{", "// for \\MvcCore\\Application::GetInstance()->GetCompiled(), by default equal to: '' (development), 'PHP_STRICT_HDD'", "//$result = self::$basePath . $path;", "$", "result", "=", "'__RELATIVE_BASE_PATH__'", ".", "$", "path", ";", "}", "return", "$", "result", ";", "}" ]
Completes font or image file URL inside CSS/JS file content. If application compile mode is in development state or packed in strict HDD mode, there is generated standard URL with \MvcCore\Request::$BasePath (current app location) plus called $path param. Because those application compile modes presume by default, that those files are placed beside php code on hard drive. If application compile mode is in php preserve package, php preserve HDD, php strict package or in single file URL mode, there is generated URL by \MvcCore in form: '?controller=controller&action=asset&path=...'. Feel free to change this css/js file URL completion to any custom way. There could be typically only: "$result = self::$basePath . $path;", but if you want to complete URL for assets on hard drive or to any other CDN place, use \MvcCore\Ext\Views\Helpers\Assets::SetBasePath($cdnBasePath); @param string $path relative path from application document root with slash in begin @return string
[ "Completes", "font", "or", "image", "file", "URL", "inside", "CSS", "/", "JS", "file", "content", "." ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L268-L279
[ "path" ]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.CssJsFileUrl
public function CssJsFileUrl ($path = '') { $result = ''; if (self::$assetsUrlCompletion) { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD' $result = $this->view->AssetUrl($path); } else { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: '' (development), 'PHP_STRICT_HDD' $result = self::$basePath . $path; } return $result; }
php
public function CssJsFileUrl ($path = '') { $result = ''; if (self::$assetsUrlCompletion) { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD' $result = $this->view->AssetUrl($path); } else { // for \MvcCore\Application::GetInstance()->GetCompiled() equal to: '' (development), 'PHP_STRICT_HDD' $result = self::$basePath . $path; } return $result; }
[ "public", "function", "CssJsFileUrl", "(", "$", "path", "=", "''", ")", "{", "$", "result", "=", "''", ";", "if", "(", "self", "::", "$", "assetsUrlCompletion", ")", "{", "// for \\MvcCore\\Application::GetInstance()->GetCompiled() equal to: 'PHAR', 'SFU', 'PHP_STRICT_PACKAGE', 'PHP_PRESERVE_PACKAGE', 'PHP_PRESERVE_HDD'", "$", "result", "=", "$", "this", "->", "view", "->", "AssetUrl", "(", "$", "path", ")", ";", "}", "else", "{", "// for \\MvcCore\\Application::GetInstance()->GetCompiled() equal to: '' (development), 'PHP_STRICT_HDD'", "$", "result", "=", "self", "::", "$", "basePath", ".", "$", "path", ";", "}", "return", "$", "result", ";", "}" ]
Completes CSS or JS file url. If application compile mode is in development state or packed in strict HDD mode, there is generated standard URL with \MvcCore\Request->GetBasePath() (current app location) plus called $path param. Because those application compile modes presume by default, that those files are placed beside php code on hard drive. If application compile mode is in php preserve package, php preserve HDD, php strict package or in single file URL mode, there is generated URL by \MvcCore in form: 'index.php?controller=controller&action=asset&path=...'. Feel free to change this css/js file URL completion to any custom way. There could be typically only: "$result = self::$basePath . $path;", but if you want to complete URL for assets on hard drive or to any other CDN place, use \MvcCore\Ext\Views\Helpers\Assets::SetBasePath($cdnBasePath); @param string $path relative path from application document root with slash in begin @return string
[ "Completes", "CSS", "or", "JS", "file", "url", "." ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L301-L311
[ "path" ]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems
protected function filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems ($items) { $itemsToRenderMinimized = []; $itemsToRenderSeparately = []; // some configurations is not possible to render together and minimized // go for every item to complete existing combinations in attributes foreach ($items as & $item) { $itemArr = array_merge((array) $item, []); unset($itemArr['path']); if (isset($itemArr['render'])) unset($itemArr['render']); if (isset($itemArr['external'])) unset($itemArr['external']); $renderArrayKey = md5(json_encode($itemArr)); if ($itemArr['doNotMinify']) { if (isset($itemsToRenderSeparately[$renderArrayKey])) { $itemsToRenderSeparately[$renderArrayKey][] = $item; } else { $itemsToRenderSeparately[$renderArrayKey] = [$item]; } } else { if (isset($itemsToRenderMinimized[$renderArrayKey])) { $itemsToRenderMinimized[$renderArrayKey][] = $item; } else { $itemsToRenderMinimized[$renderArrayKey] = [$item]; } } } return [ $itemsToRenderMinimized, $itemsToRenderSeparately, ]; }
php
protected function filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems ($items) { $itemsToRenderMinimized = []; $itemsToRenderSeparately = []; // some configurations is not possible to render together and minimized // go for every item to complete existing combinations in attributes foreach ($items as & $item) { $itemArr = array_merge((array) $item, []); unset($itemArr['path']); if (isset($itemArr['render'])) unset($itemArr['render']); if (isset($itemArr['external'])) unset($itemArr['external']); $renderArrayKey = md5(json_encode($itemArr)); if ($itemArr['doNotMinify']) { if (isset($itemsToRenderSeparately[$renderArrayKey])) { $itemsToRenderSeparately[$renderArrayKey][] = $item; } else { $itemsToRenderSeparately[$renderArrayKey] = [$item]; } } else { if (isset($itemsToRenderMinimized[$renderArrayKey])) { $itemsToRenderMinimized[$renderArrayKey][] = $item; } else { $itemsToRenderMinimized[$renderArrayKey] = [$item]; } } } return [ $itemsToRenderMinimized, $itemsToRenderSeparately, ]; }
[ "protected", "function", "filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems", "(", "$", "items", ")", "{", "$", "itemsToRenderMinimized", "=", "[", "]", ";", "$", "itemsToRenderSeparately", "=", "[", "]", ";", "// some configurations is not possible to render together and minimized", "// go for every item to complete existing combinations in attributes", "foreach", "(", "$", "items", "as", "&", "$", "item", ")", "{", "$", "itemArr", "=", "array_merge", "(", "(", "array", ")", "$", "item", ",", "[", "]", ")", ";", "unset", "(", "$", "itemArr", "[", "'path'", "]", ")", ";", "if", "(", "isset", "(", "$", "itemArr", "[", "'render'", "]", ")", ")", "unset", "(", "$", "itemArr", "[", "'render'", "]", ")", ";", "if", "(", "isset", "(", "$", "itemArr", "[", "'external'", "]", ")", ")", "unset", "(", "$", "itemArr", "[", "'external'", "]", ")", ";", "$", "renderArrayKey", "=", "md5", "(", "json_encode", "(", "$", "itemArr", ")", ")", ";", "if", "(", "$", "itemArr", "[", "'doNotMinify'", "]", ")", "{", "if", "(", "isset", "(", "$", "itemsToRenderSeparately", "[", "$", "renderArrayKey", "]", ")", ")", "{", "$", "itemsToRenderSeparately", "[", "$", "renderArrayKey", "]", "[", "]", "=", "$", "item", ";", "}", "else", "{", "$", "itemsToRenderSeparately", "[", "$", "renderArrayKey", "]", "=", "[", "$", "item", "]", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "itemsToRenderMinimized", "[", "$", "renderArrayKey", "]", ")", ")", "{", "$", "itemsToRenderMinimized", "[", "$", "renderArrayKey", "]", "[", "]", "=", "$", "item", ";", "}", "else", "{", "$", "itemsToRenderMinimized", "[", "$", "renderArrayKey", "]", "=", "[", "$", "item", "]", ";", "}", "}", "}", "return", "[", "$", "itemsToRenderMinimized", ",", "$", "itemsToRenderSeparately", ",", "]", ";", "}" ]
Look for every item to render if there is any 'doNotMinify' record to render item separately @param array $items @return array[] $itemsToRenderMinimized $itemsToRenderSeparately
[ "Look", "for", "every", "item", "to", "render", "if", "there", "is", "any", "doNotMinify", "record", "to", "render", "item", "separately" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L326-L354
[ "items" ]
What does this function return?
[ "array[]", "$itemsToRenderMinimized", "$itemsToRenderSeparately" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.addFileModificationImprintToHrefUrl
protected function addFileModificationImprintToHrefUrl ($url, $path) { $questionMarkPos = strpos($url, '?'); $separator = ($questionMarkPos === FALSE) ? '?' : '&'; $strippedUrl = $questionMarkPos !== FALSE ? substr($url, $questionMarkPos) : $url ; $srcPath = $this->getAppRoot() . substr($strippedUrl, strlen(self::$basePath)); if (self::$globalOptions['fileChecking'] == 'filemtime') { $fileMTime = self::getFileImprint($srcPath); $url .= $separator . '_fmt=' . date( self::FILE_MODIFICATION_DATE_FORMAT, (int)$fileMTime ); } else { $url .= $separator . '_md5=' . self::getFileImprint($srcPath); } return $url; }
php
protected function addFileModificationImprintToHrefUrl ($url, $path) { $questionMarkPos = strpos($url, '?'); $separator = ($questionMarkPos === FALSE) ? '?' : '&'; $strippedUrl = $questionMarkPos !== FALSE ? substr($url, $questionMarkPos) : $url ; $srcPath = $this->getAppRoot() . substr($strippedUrl, strlen(self::$basePath)); if (self::$globalOptions['fileChecking'] == 'filemtime') { $fileMTime = self::getFileImprint($srcPath); $url .= $separator . '_fmt=' . date( self::FILE_MODIFICATION_DATE_FORMAT, (int)$fileMTime ); } else { $url .= $separator . '_md5=' . self::getFileImprint($srcPath); } return $url; }
[ "protected", "function", "addFileModificationImprintToHrefUrl", "(", "$", "url", ",", "$", "path", ")", "{", "$", "questionMarkPos", "=", "strpos", "(", "$", "url", ",", "'?'", ")", ";", "$", "separator", "=", "(", "$", "questionMarkPos", "===", "FALSE", ")", "?", "'?'", ":", "'&'", ";", "$", "strippedUrl", "=", "$", "questionMarkPos", "!==", "FALSE", "?", "substr", "(", "$", "url", ",", "$", "questionMarkPos", ")", ":", "$", "url", ";", "$", "srcPath", "=", "$", "this", "->", "getAppRoot", "(", ")", ".", "substr", "(", "$", "strippedUrl", ",", "strlen", "(", "self", "::", "$", "basePath", ")", ")", ";", "if", "(", "self", "::", "$", "globalOptions", "[", "'fileChecking'", "]", "==", "'filemtime'", ")", "{", "$", "fileMTime", "=", "self", "::", "getFileImprint", "(", "$", "srcPath", ")", ";", "$", "url", ".=", "$", "separator", ".", "'_fmt='", ".", "date", "(", "self", "::", "FILE_MODIFICATION_DATE_FORMAT", ",", "(", "int", ")", "$", "fileMTime", ")", ";", "}", "else", "{", "$", "url", ".=", "$", "separator", ".", "'_md5='", ".", "self", "::", "getFileImprint", "(", "$", "srcPath", ")", ";", "}", "return", "$", "url", ";", "}" ]
Add to href URL file modification param by original file @param string $url @param string $path @return string
[ "Add", "to", "href", "URL", "file", "modification", "param", "by", "original", "file" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L362-L377
[ "url", "path" ]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.getIndentString
protected function getIndentString($indent = 0) { $indentStr = ''; if (is_numeric($indent)) { $indInt = intval($indent); if ($indInt > 0) { $i = 0; while ($i < $indInt) { $indentStr .= "\t"; $i += 1; } } } else if (is_string($indent)) { $indentStr = $indent; } return $indentStr; }
php
protected function getIndentString($indent = 0) { $indentStr = ''; if (is_numeric($indent)) { $indInt = intval($indent); if ($indInt > 0) { $i = 0; while ($i < $indInt) { $indentStr .= "\t"; $i += 1; } } } else if (is_string($indent)) { $indentStr = $indent; } return $indentStr; }
[ "protected", "function", "getIndentString", "(", "$", "indent", "=", "0", ")", "{", "$", "indentStr", "=", "''", ";", "if", "(", "is_numeric", "(", "$", "indent", ")", ")", "{", "$", "indInt", "=", "intval", "(", "$", "indent", ")", ";", "if", "(", "$", "indInt", ">", "0", ")", "{", "$", "i", "=", "0", ";", "while", "(", "$", "i", "<", "$", "indInt", ")", "{", "$", "indentStr", ".=", "\"\\t\"", ";", "$", "i", "+=", "1", ";", "}", "}", "}", "else", "if", "(", "is_string", "(", "$", "indent", ")", ")", "{", "$", "indentStr", "=", "$", "indent", ";", "}", "return", "$", "indentStr", ";", "}" ]
Get indent string @param string|int $indent @return string
[ "Get", "indent", "string" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L384-L399
[ "indent" ]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.getTmpDir
protected function getTmpDir() { if (!self::$tmpDir) { $tmpDir = $this->getAppRoot() . self::$globalOptions['tmpDir']; if (!\MvcCore\Application::GetInstance()->GetCompiled()) { if (!is_dir($tmpDir)) mkdir($tmpDir, 0777, TRUE); if (!is_writable($tmpDir)) { try { @chmod($tmpDir, 0777); } catch (\Exception $e) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \Exception('['.$selfClass.'] ' . $e->getMessage()); } } } self::$tmpDir = $tmpDir; } return self::$tmpDir; }
php
protected function getTmpDir() { if (!self::$tmpDir) { $tmpDir = $this->getAppRoot() . self::$globalOptions['tmpDir']; if (!\MvcCore\Application::GetInstance()->GetCompiled()) { if (!is_dir($tmpDir)) mkdir($tmpDir, 0777, TRUE); if (!is_writable($tmpDir)) { try { @chmod($tmpDir, 0777); } catch (\Exception $e) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \Exception('['.$selfClass.'] ' . $e->getMessage()); } } } self::$tmpDir = $tmpDir; } return self::$tmpDir; }
[ "protected", "function", "getTmpDir", "(", ")", "{", "if", "(", "!", "self", "::", "$", "tmpDir", ")", "{", "$", "tmpDir", "=", "$", "this", "->", "getAppRoot", "(", ")", ".", "self", "::", "$", "globalOptions", "[", "'tmpDir'", "]", ";", "if", "(", "!", "\\", "MvcCore", "\\", "Application", "::", "GetInstance", "(", ")", "->", "GetCompiled", "(", ")", ")", "{", "if", "(", "!", "is_dir", "(", "$", "tmpDir", ")", ")", "mkdir", "(", "$", "tmpDir", ",", "0777", ",", "TRUE", ")", ";", "if", "(", "!", "is_writable", "(", "$", "tmpDir", ")", ")", "{", "try", "{", "@", "chmod", "(", "$", "tmpDir", ",", "0777", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "throw", "new", "\\", "Exception", "(", "'['", ".", "$", "selfClass", ".", "'] '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "}", "self", "::", "$", "tmpDir", "=", "$", "tmpDir", ";", "}", "return", "self", "::", "$", "tmpDir", ";", "}" ]
Return and store application document root from controller view request object @throws \Exception @return string
[ "Return", "and", "store", "application", "document", "root", "from", "controller", "view", "request", "object" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L414-L431
[]
What does this function return?
[ "string" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.saveFileContent
protected function saveFileContent ($fullPath = '', & $fileContent = '') { $toolClass = \MvcCore\Application::GetInstance()->GetToolClass(); $toolClass::SingleProcessWrite($fullPath, $fileContent); @chmod($fullPath, 0766); }
php
protected function saveFileContent ($fullPath = '', & $fileContent = '') { $toolClass = \MvcCore\Application::GetInstance()->GetToolClass(); $toolClass::SingleProcessWrite($fullPath, $fileContent); @chmod($fullPath, 0766); }
[ "protected", "function", "saveFileContent", "(", "$", "fullPath", "=", "''", ",", "&", "$", "fileContent", "=", "''", ")", "{", "$", "toolClass", "=", "\\", "MvcCore", "\\", "Application", "::", "GetInstance", "(", ")", "->", "GetToolClass", "(", ")", ";", "$", "toolClass", "::", "SingleProcessWrite", "(", "$", "fullPath", ",", "$", "fileContent", ")", ";", "@", "chmod", "(", "$", "fullPath", ",", "0766", ")", ";", "}" ]
Save atomically file content in full path by 1 MB to not overflow any memory limits @param string $fullPath @param string $fileContent @return void
[ "Save", "atomically", "file", "content", "in", "full", "path", "by", "1", "MB", "to", "not", "overflow", "any", "memory", "limits" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L439-L443
[ "fullPath", "" ]
What does this function return?
[ "void" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.log
protected function log ($msg = '', $logType = 'debug') { if (self::$loggingAndExceptions) { \MvcCore\Debug::Log($msg, $logType); } }
php
protected function log ($msg = '', $logType = 'debug') { if (self::$loggingAndExceptions) { \MvcCore\Debug::Log($msg, $logType); } }
[ "protected", "function", "log", "(", "$", "msg", "=", "''", ",", "$", "logType", "=", "'debug'", ")", "{", "if", "(", "self", "::", "$", "loggingAndExceptions", ")", "{", "\\", "MvcCore", "\\", "Debug", "::", "Log", "(", "$", "msg", ",", "$", "logType", ")", ";", "}", "}" ]
Log any render messages with optional log file name @param string $msg @param string $logType @return void
[ "Log", "any", "render", "messages", "with", "optional", "log", "file", "name" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L451-L455
[ "msg", "logType" ]
What does this function return?
[ "void" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.warning
protected function warning ($msg) { if (self::$loggingAndExceptions) { \MvcCore\Debug::BarDump('[' . get_class($this) . '] ' . $msg, \MvcCore\IDebug::DEBUG); } }
php
protected function warning ($msg) { if (self::$loggingAndExceptions) { \MvcCore\Debug::BarDump('[' . get_class($this) . '] ' . $msg, \MvcCore\IDebug::DEBUG); } }
[ "protected", "function", "warning", "(", "$", "msg", ")", "{", "if", "(", "self", "::", "$", "loggingAndExceptions", ")", "{", "\\", "MvcCore", "\\", "Debug", "::", "BarDump", "(", "'['", ".", "get_class", "(", "$", "this", ")", ".", "'] '", ".", "$", "msg", ",", "\\", "MvcCore", "\\", "IDebug", "::", "DEBUG", ")", ";", "}", "}" ]
Throw exception with given message with actual helper class name before @param string $msg @return void
[ "Throw", "exception", "with", "given", "message", "with", "actual", "helper", "class", "name", "before" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L474-L478
[ "msg" ]
What does this function return?
[ "void" ]
mvccore/ext-view-helper-assets
src/MvcCore/Ext/Views/Helpers/Assets.php
Assets.getTmpFileFullPathByPartFilesInfo
protected function getTmpFileFullPathByPartFilesInfo ($filesGroupInfo = [], $minify = FALSE, $extension = '') { return implode('', [ $this->getTmpDir(), '/' . ($minify ? 'minified' : 'rendered') . '_' . $extension . '_', md5(implode(',', $filesGroupInfo) . '_' . $minify), '.' . $extension ]); }
php
protected function getTmpFileFullPathByPartFilesInfo ($filesGroupInfo = [], $minify = FALSE, $extension = '') { return implode('', [ $this->getTmpDir(), '/' . ($minify ? 'minified' : 'rendered') . '_' . $extension . '_', md5(implode(',', $filesGroupInfo) . '_' . $minify), '.' . $extension ]); }
[ "protected", "function", "getTmpFileFullPathByPartFilesInfo", "(", "$", "filesGroupInfo", "=", "[", "]", ",", "$", "minify", "=", "FALSE", ",", "$", "extension", "=", "''", ")", "{", "return", "implode", "(", "''", ",", "[", "$", "this", "->", "getTmpDir", "(", ")", ",", "'/'", ".", "(", "$", "minify", "?", "'minified'", ":", "'rendered'", ")", ".", "'_'", ".", "$", "extension", ".", "'_'", ",", "md5", "(", "implode", "(", "','", ",", "$", "filesGroupInfo", ")", ".", "'_'", ".", "$", "minify", ")", ",", "'.'", ".", "$", "extension", "]", ")", ";", "}" ]
Complete items group tmp directory file name by group source files info @param array $filesGroupInfo @param boolean $minify @return string
[ "Complete", "items", "group", "tmp", "directory", "file", "name", "by", "group", "source", "files", "info" ]
train
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L497-L504
[ "filesGroupInfo", "minify", "extension" ]
What does this function return?
[ "string" ]
rzajac/php-test-helper
src/Database/Driver/MySQL.php
MySQL.getTableNames
protected function getTableNames(): array { $dbName = $this->config[DbItf::DB_CFG_DATABASE]; $resp = $this->dbRunQuery(sprintf('SHOW FULL TABLES FROM `%s`', $dbName)); $tableAndViewNames = []; while ($row = $resp->fetch_assoc()) { $tableAndViewNames[] = array_change_key_case($row); } return $tableAndViewNames; }
php
protected function getTableNames(): array { $dbName = $this->config[DbItf::DB_CFG_DATABASE]; $resp = $this->dbRunQuery(sprintf('SHOW FULL TABLES FROM `%s`', $dbName)); $tableAndViewNames = []; while ($row = $resp->fetch_assoc()) { $tableAndViewNames[] = array_change_key_case($row); } return $tableAndViewNames; }
[ "protected", "function", "getTableNames", "(", ")", ":", "array", "{", "$", "dbName", "=", "$", "this", "->", "config", "[", "DbItf", "::", "DB_CFG_DATABASE", "]", ";", "$", "resp", "=", "$", "this", "->", "dbRunQuery", "(", "sprintf", "(", "'SHOW FULL TABLES FROM `%s`'", ",", "$", "dbName", ")", ")", ";", "$", "tableAndViewNames", "=", "[", "]", ";", "while", "(", "$", "row", "=", "$", "resp", "->", "fetch_assoc", "(", ")", ")", "{", "$", "tableAndViewNames", "[", "]", "=", "array_change_key_case", "(", "$", "row", ")", ";", "}", "return", "$", "tableAndViewNames", ";", "}" ]
Return table and view names form the database. @throws DatabaseEx @return array
[ "Return", "table", "and", "view", "names", "form", "the", "database", "." ]
train
https://github.com/rzajac/php-test-helper/blob/37280e9ff639b25cf9413909cc080c5d8deb311c/src/Database/Driver/MySQL.php#L164-L175
[]
What does this function return?
[ "array" ]
QoboLtd/cakephp-translations
src/Controller/LanguagesController.php
LanguagesController.index
public function index() { $languages = $this->Languages->find('all'); $this->set(compact('languages')); $this->set('_serialize', ['languages']); }
php
public function index() { $languages = $this->Languages->find('all'); $this->set(compact('languages')); $this->set('_serialize', ['languages']); }
[ "public", "function", "index", "(", ")", "{", "$", "languages", "=", "$", "this", "->", "Languages", "->", "find", "(", "'all'", ")", ";", "$", "this", "->", "set", "(", "compact", "(", "'languages'", ")", ")", ";", "$", "this", "->", "set", "(", "'_serialize'", ",", "[", "'languages'", "]", ")", ";", "}" ]
Index method @return \Cake\Http\Response|void
[ "Index", "method" ]
train
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L28-L33
[]
What does this function return?
[ "\\Cake\\Http\\Response|void" ]
QoboLtd/cakephp-translations
src/Controller/LanguagesController.php
LanguagesController.add
public function add() { $language = $this->Languages->newEntity(); if ($this->request->is('post')) { $data = is_array($this->request->getData()) ? $this->request->getData() : []; $languageEntity = $this->Languages->addOrRestore($data); if (!empty($languageEntity)) { $this->Flash->success((string)__('The language has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error((string)__('The language could not be saved. Please, try again.')); } $languages = $this->Languages->getAvailable(); $this->set(compact('language', 'languages')); $this->set('_serialize', ['language']); }
php
public function add() { $language = $this->Languages->newEntity(); if ($this->request->is('post')) { $data = is_array($this->request->getData()) ? $this->request->getData() : []; $languageEntity = $this->Languages->addOrRestore($data); if (!empty($languageEntity)) { $this->Flash->success((string)__('The language has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error((string)__('The language could not be saved. Please, try again.')); } $languages = $this->Languages->getAvailable(); $this->set(compact('language', 'languages')); $this->set('_serialize', ['language']); }
[ "public", "function", "add", "(", ")", "{", "$", "language", "=", "$", "this", "->", "Languages", "->", "newEntity", "(", ")", ";", "if", "(", "$", "this", "->", "request", "->", "is", "(", "'post'", ")", ")", "{", "$", "data", "=", "is_array", "(", "$", "this", "->", "request", "->", "getData", "(", ")", ")", "?", "$", "this", "->", "request", "->", "getData", "(", ")", ":", "[", "]", ";", "$", "languageEntity", "=", "$", "this", "->", "Languages", "->", "addOrRestore", "(", "$", "data", ")", ";", "if", "(", "!", "empty", "(", "$", "languageEntity", ")", ")", "{", "$", "this", "->", "Flash", "->", "success", "(", "(", "string", ")", "__", "(", "'The language has been saved.'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'action'", "=>", "'index'", "]", ")", ";", "}", "$", "this", "->", "Flash", "->", "error", "(", "(", "string", ")", "__", "(", "'The language could not be saved. Please, try again.'", ")", ")", ";", "}", "$", "languages", "=", "$", "this", "->", "Languages", "->", "getAvailable", "(", ")", ";", "$", "this", "->", "set", "(", "compact", "(", "'language'", ",", "'languages'", ")", ")", ";", "$", "this", "->", "set", "(", "'_serialize'", ",", "[", "'language'", "]", ")", ";", "}" ]
Add method @return \Cake\Http\Response|void|null Redirects on successful add, renders view otherwise.
[ "Add", "method" ]
train
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L40-L56
[]
What does this function return?
[ "\\Cake\\Http\\Response|void|null", "Redirects", "on", "successful", "add,", "renders", "view", "otherwise." ]
QoboLtd/cakephp-translations
src/Controller/LanguagesController.php
LanguagesController.delete
public function delete(string $id = null) { $this->request->allowMethod(['post', 'delete']); $language = $this->Languages->get($id); if ($this->Languages->delete($language)) { $this->Flash->success((string)__('The language has been deleted.')); } else { $this->Flash->error((string)__('The language could not be deleted. Please, try again.')); } return $this->redirect(['action' => 'index']); }
php
public function delete(string $id = null) { $this->request->allowMethod(['post', 'delete']); $language = $this->Languages->get($id); if ($this->Languages->delete($language)) { $this->Flash->success((string)__('The language has been deleted.')); } else { $this->Flash->error((string)__('The language could not be deleted. Please, try again.')); } return $this->redirect(['action' => 'index']); }
[ "public", "function", "delete", "(", "string", "$", "id", "=", "null", ")", "{", "$", "this", "->", "request", "->", "allowMethod", "(", "[", "'post'", ",", "'delete'", "]", ")", ";", "$", "language", "=", "$", "this", "->", "Languages", "->", "get", "(", "$", "id", ")", ";", "if", "(", "$", "this", "->", "Languages", "->", "delete", "(", "$", "language", ")", ")", "{", "$", "this", "->", "Flash", "->", "success", "(", "(", "string", ")", "__", "(", "'The language has been deleted.'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "Flash", "->", "error", "(", "(", "string", ")", "__", "(", "'The language could not be deleted. Please, try again.'", ")", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "[", "'action'", "=>", "'index'", "]", ")", ";", "}" ]
Delete method @param string|null $id Language id. @return \Cake\Http\Response|void|null Redirects to index. @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
[ "Delete", "method" ]
train
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L65-L76
[ "string" ]
What does this function return?
[ "\\Cake\\Http\\Response|void|null", "Redirects", "to", "index.", "@throws", "\\Cake\\Datasource\\Exception\\RecordNotFoundException", "When", "record", "not", "found." ]
graze/csv-token
src/Tokeniser/StateBuilder.php
StateBuilder.buildStates
public function buildStates(TokenStoreInterface $tokenStore) { $initial = new State($tokenStore, State::S_INITIAL_TOKENS); $any = new State($tokenStore, State::S_ANY_TOKENS); $inQuote = new State($tokenStore, State::S_IN_QUOTE_TOKENS); $inEscape = new State($tokenStore, State::S_IN_ESCAPE_TOKENS); $inQuoteEscape = new State($tokenStore, State::S_IN_QUOTE_ESCAPE_TOKENS); $initial->addStateTarget(Token::T_ANY & ~Token::T_QUOTE & ~Token::T_ESCAPE, $any); $initial->addStateTarget(Token::T_QUOTE, $inQuote); $initial->addStateTarget(Token::T_ESCAPE, $inEscape); // generate state mapping $any->addStateTarget(Token::T_ANY & ~Token::T_QUOTE & ~Token::T_ESCAPE, $any); $any->addStateTarget(Token::T_QUOTE, $inQuote); $any->addStateTarget(Token::T_ESCAPE, $inEscape); $inQuote->addStateTarget(Token::T_CONTENT | Token::T_DOUBLE_QUOTE, $inQuote); $inQuote->addStateTarget(Token::T_QUOTE, $any); $inQuote->addStateTarget(Token::T_ESCAPE, $inQuoteEscape); $inEscape->addStateTarget(Token::T_CONTENT, $any); $inQuoteEscape->addStateTarget(Token::T_CONTENT, $inQuote); return $initial; }
php
public function buildStates(TokenStoreInterface $tokenStore) { $initial = new State($tokenStore, State::S_INITIAL_TOKENS); $any = new State($tokenStore, State::S_ANY_TOKENS); $inQuote = new State($tokenStore, State::S_IN_QUOTE_TOKENS); $inEscape = new State($tokenStore, State::S_IN_ESCAPE_TOKENS); $inQuoteEscape = new State($tokenStore, State::S_IN_QUOTE_ESCAPE_TOKENS); $initial->addStateTarget(Token::T_ANY & ~Token::T_QUOTE & ~Token::T_ESCAPE, $any); $initial->addStateTarget(Token::T_QUOTE, $inQuote); $initial->addStateTarget(Token::T_ESCAPE, $inEscape); // generate state mapping $any->addStateTarget(Token::T_ANY & ~Token::T_QUOTE & ~Token::T_ESCAPE, $any); $any->addStateTarget(Token::T_QUOTE, $inQuote); $any->addStateTarget(Token::T_ESCAPE, $inEscape); $inQuote->addStateTarget(Token::T_CONTENT | Token::T_DOUBLE_QUOTE, $inQuote); $inQuote->addStateTarget(Token::T_QUOTE, $any); $inQuote->addStateTarget(Token::T_ESCAPE, $inQuoteEscape); $inEscape->addStateTarget(Token::T_CONTENT, $any); $inQuoteEscape->addStateTarget(Token::T_CONTENT, $inQuote); return $initial; }
[ "public", "function", "buildStates", "(", "TokenStoreInterface", "$", "tokenStore", ")", "{", "$", "initial", "=", "new", "State", "(", "$", "tokenStore", ",", "State", "::", "S_INITIAL_TOKENS", ")", ";", "$", "any", "=", "new", "State", "(", "$", "tokenStore", ",", "State", "::", "S_ANY_TOKENS", ")", ";", "$", "inQuote", "=", "new", "State", "(", "$", "tokenStore", ",", "State", "::", "S_IN_QUOTE_TOKENS", ")", ";", "$", "inEscape", "=", "new", "State", "(", "$", "tokenStore", ",", "State", "::", "S_IN_ESCAPE_TOKENS", ")", ";", "$", "inQuoteEscape", "=", "new", "State", "(", "$", "tokenStore", ",", "State", "::", "S_IN_QUOTE_ESCAPE_TOKENS", ")", ";", "$", "initial", "->", "addStateTarget", "(", "Token", "::", "T_ANY", "&", "~", "Token", "::", "T_QUOTE", "&", "~", "Token", "::", "T_ESCAPE", ",", "$", "any", ")", ";", "$", "initial", "->", "addStateTarget", "(", "Token", "::", "T_QUOTE", ",", "$", "inQuote", ")", ";", "$", "initial", "->", "addStateTarget", "(", "Token", "::", "T_ESCAPE", ",", "$", "inEscape", ")", ";", "// generate state mapping", "$", "any", "->", "addStateTarget", "(", "Token", "::", "T_ANY", "&", "~", "Token", "::", "T_QUOTE", "&", "~", "Token", "::", "T_ESCAPE", ",", "$", "any", ")", ";", "$", "any", "->", "addStateTarget", "(", "Token", "::", "T_QUOTE", ",", "$", "inQuote", ")", ";", "$", "any", "->", "addStateTarget", "(", "Token", "::", "T_ESCAPE", ",", "$", "inEscape", ")", ";", "$", "inQuote", "->", "addStateTarget", "(", "Token", "::", "T_CONTENT", "|", "Token", "::", "T_DOUBLE_QUOTE", ",", "$", "inQuote", ")", ";", "$", "inQuote", "->", "addStateTarget", "(", "Token", "::", "T_QUOTE", ",", "$", "any", ")", ";", "$", "inQuote", "->", "addStateTarget", "(", "Token", "::", "T_ESCAPE", ",", "$", "inQuoteEscape", ")", ";", "$", "inEscape", "->", "addStateTarget", "(", "Token", "::", "T_CONTENT", ",", "$", "any", ")", ";", "$", "inQuoteEscape", "->", "addStateTarget", "(", "Token", "::", "T_CONTENT", ",", "$", "inQuote", ")", ";", "return", "$", "initial", ";", "}" ]
@param TokenStoreInterface $tokenStore @return State The default starting state
[ "@param", "TokenStoreInterface", "$tokenStore" ]
train
https://github.com/graze/csv-token/blob/ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8/src/Tokeniser/StateBuilder.php#L26-L52
[ "TokenStoreInterface" ]
What does this function return?
[ "State", "The", "default", "starting", "state" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.slashDirname
public static function slashDirname($dirname = null) { if (is_null($dirname) || empty($dirname)) { return ''; } return rtrim($dirname, '/ '.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; }
php
public static function slashDirname($dirname = null) { if (is_null($dirname) || empty($dirname)) { return ''; } return rtrim($dirname, '/ '.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; }
[ "public", "static", "function", "slashDirname", "(", "$", "dirname", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "dirname", ")", "||", "empty", "(", "$", "dirname", ")", ")", "{", "return", "''", ";", "}", "return", "rtrim", "(", "$", "dirname", ",", "'/ '", ".", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "}" ]
Get a dirname with one and only trailing slash @param string $dirname @return string
[ "Get", "a", "dirname", "with", "one", "and", "only", "trailing", "slash" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L43-L49
[ "dirname" ]
What does this function return?
[ "", "string" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.isGitClone
public static function isGitClone($path = null) { if (is_null($path) || empty($path)) { return false; } $dir_path = self::slashDirname($path).'.git'; return (bool) (file_exists($dir_path) && is_dir($dir_path)); }
php
public static function isGitClone($path = null) { if (is_null($path) || empty($path)) { return false; } $dir_path = self::slashDirname($path).'.git'; return (bool) (file_exists($dir_path) && is_dir($dir_path)); }
[ "public", "static", "function", "isGitClone", "(", "$", "path", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "path", ")", "||", "empty", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "$", "dir_path", "=", "self", "::", "slashDirname", "(", "$", "path", ")", ".", "'.git'", ";", "return", "(", "bool", ")", "(", "file_exists", "(", "$", "dir_path", ")", "&&", "is_dir", "(", "$", "dir_path", ")", ")", ";", "}" ]
Test if a path seems to be a git clone @param string $path @return bool
[ "Test", "if", "a", "path", "seems", "to", "be", "a", "git", "clone" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L57-L64
[ "path" ]
What does this function return?
[ "", "bool" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.isDotPath
public static function isDotPath($path = null) { if (is_null($path) || empty($path)) { return false; } return (bool) ('.'===substr(basename($path), 0, 1)); }
php
public static function isDotPath($path = null) { if (is_null($path) || empty($path)) { return false; } return (bool) ('.'===substr(basename($path), 0, 1)); }
[ "public", "static", "function", "isDotPath", "(", "$", "path", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "path", ")", "||", "empty", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "return", "(", "bool", ")", "(", "'.'", "===", "substr", "(", "basename", "(", "$", "path", ")", ",", "0", ",", "1", ")", ")", ";", "}" ]
Test if a filename seems to have a dot as first character @param string $path @return bool
[ "Test", "if", "a", "filename", "seems", "to", "have", "a", "dot", "as", "first", "character" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L72-L78
[ "path" ]
What does this function return?
[ "", "bool" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.remove
public static function remove($path, $parent = true) { $ok = true; if (true===self::ensureExists($path)) { if (false===@is_dir($path) || true===is_link($path)) { return @unlink($path); } $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS ); foreach($iterator as $item) { if (in_array($item->getFilename(), array('.', '..'))) { continue; } if ($item->isDir()) { $ok = self::remove($item); } else { $ok = @unlink($item); } } if ($ok && $parent) { @rmdir($path); } @clearstatcache(); } return $ok; }
php
public static function remove($path, $parent = true) { $ok = true; if (true===self::ensureExists($path)) { if (false===@is_dir($path) || true===is_link($path)) { return @unlink($path); } $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS ); foreach($iterator as $item) { if (in_array($item->getFilename(), array('.', '..'))) { continue; } if ($item->isDir()) { $ok = self::remove($item); } else { $ok = @unlink($item); } } if ($ok && $parent) { @rmdir($path); } @clearstatcache(); } return $ok; }
[ "public", "static", "function", "remove", "(", "$", "path", ",", "$", "parent", "=", "true", ")", "{", "$", "ok", "=", "true", ";", "if", "(", "true", "===", "self", "::", "ensureExists", "(", "$", "path", ")", ")", "{", "if", "(", "false", "===", "@", "is_dir", "(", "$", "path", ")", "||", "true", "===", "is_link", "(", "$", "path", ")", ")", "{", "return", "@", "unlink", "(", "$", "path", ")", ";", "}", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "path", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", "|", "\\", "FilesystemIterator", "::", "CURRENT_AS_FILEINFO", "|", "\\", "FilesystemIterator", "::", "SKIP_DOTS", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "item", ")", "{", "if", "(", "in_array", "(", "$", "item", "->", "getFilename", "(", ")", ",", "array", "(", "'.'", ",", "'..'", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "item", "->", "isDir", "(", ")", ")", "{", "$", "ok", "=", "self", "::", "remove", "(", "$", "item", ")", ";", "}", "else", "{", "$", "ok", "=", "@", "unlink", "(", "$", "item", ")", ";", "}", "}", "if", "(", "$", "ok", "&&", "$", "parent", ")", "{", "@", "rmdir", "(", "$", "path", ")", ";", "}", "@", "clearstatcache", "(", ")", ";", "}", "return", "$", "ok", ";", "}" ]
Try to remove a path @param string $path @param bool $parent @return bool
[ "Try", "to", "remove", "a", "path" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L117-L144
[ "path", "parent" ]
What does this function return?
[ "", "bool" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.parseIni
public static function parseIni($path) { if (true===@file_exists($path)) { $data = parse_ini_file($path, true); if ($data && !empty($data)) { return $data; } } return false; }
php
public static function parseIni($path) { if (true===@file_exists($path)) { $data = parse_ini_file($path, true); if ($data && !empty($data)) { return $data; } } return false; }
[ "public", "static", "function", "parseIni", "(", "$", "path", ")", "{", "if", "(", "true", "===", "@", "file_exists", "(", "$", "path", ")", ")", "{", "$", "data", "=", "parse_ini_file", "(", "$", "path", ",", "true", ")", ";", "if", "(", "$", "data", "&&", "!", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "}", "return", "false", ";", "}" ]
Read and parse a INI content file @param $path @return array|bool
[ "Read", "and", "parse", "a", "INI", "content", "file" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L152-L161
[ "path" ]
What does this function return?
[ "array|bool" ]
wdbo/webdocbook
src/WebDocBook/Filesystem/Helper.php
Helper.parseJson
public static function parseJson($path) { if (true===@file_exists($path)) { $ctt = file_get_contents($path); if ($ctt!==false) { $data = json_decode($ctt, true); if ($data && !empty($data)) { return $data; } } } return false; }
php
public static function parseJson($path) { if (true===@file_exists($path)) { $ctt = file_get_contents($path); if ($ctt!==false) { $data = json_decode($ctt, true); if ($data && !empty($data)) { return $data; } } } return false; }
[ "public", "static", "function", "parseJson", "(", "$", "path", ")", "{", "if", "(", "true", "===", "@", "file_exists", "(", "$", "path", ")", ")", "{", "$", "ctt", "=", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "$", "ctt", "!==", "false", ")", "{", "$", "data", "=", "json_decode", "(", "$", "ctt", ",", "true", ")", ";", "if", "(", "$", "data", "&&", "!", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "}", "}", "return", "false", ";", "}" ]
Read and parse a JSON content file @param $path @return bool|mixed
[ "Read", "and", "parse", "a", "JSON", "content", "file" ]
train
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L169-L181
[ "path" ]
What does this function return?
[ "bool|mixed" ]
PhoxPHP/Glider
src/Console/Command/Migration.php
Migration.create
protected function create(Array $arguments=[]) { $migrationsDirectory = $this->cmd->getConfigOpt('migrations_storage'); $templateTags = []; $migrationName = $this->cmd->question('Migration filename?'); $filename = trim($migrationName); $path = $migrationsDirectory . '/' . $filename . '.php'; if (file_exists($path)) { throw new MigrationFileInvalidException( sprintf( 'Migration file [%s] exists.', $filename ) ); } $templateTags['phx:class'] = Helper::getQualifiedClassName($filename); $builder = new TemplateBuilder($this->cmd, $this->env); $builder->createClassTemplate('migration', $filename, $migrationsDirectory, $templateTags); // After migration class has been created, the record needs to go to the database and be set to pending. $model = new Model(); $model->class_name = $templateTags['phx:class']; $model->status = Attribute::STATUS_PENDING; $model->path = $path; $model->save(); $this->env->sendOutput('Created migration is now pending', 'green'); }
php
protected function create(Array $arguments=[]) { $migrationsDirectory = $this->cmd->getConfigOpt('migrations_storage'); $templateTags = []; $migrationName = $this->cmd->question('Migration filename?'); $filename = trim($migrationName); $path = $migrationsDirectory . '/' . $filename . '.php'; if (file_exists($path)) { throw new MigrationFileInvalidException( sprintf( 'Migration file [%s] exists.', $filename ) ); } $templateTags['phx:class'] = Helper::getQualifiedClassName($filename); $builder = new TemplateBuilder($this->cmd, $this->env); $builder->createClassTemplate('migration', $filename, $migrationsDirectory, $templateTags); // After migration class has been created, the record needs to go to the database and be set to pending. $model = new Model(); $model->class_name = $templateTags['phx:class']; $model->status = Attribute::STATUS_PENDING; $model->path = $path; $model->save(); $this->env->sendOutput('Created migration is now pending', 'green'); }
[ "protected", "function", "create", "(", "Array", "$", "arguments", "=", "[", "]", ")", "{", "$", "migrationsDirectory", "=", "$", "this", "->", "cmd", "->", "getConfigOpt", "(", "'migrations_storage'", ")", ";", "$", "templateTags", "=", "[", "]", ";", "$", "migrationName", "=", "$", "this", "->", "cmd", "->", "question", "(", "'Migration filename?'", ")", ";", "$", "filename", "=", "trim", "(", "$", "migrationName", ")", ";", "$", "path", "=", "$", "migrationsDirectory", ".", "'/'", ".", "$", "filename", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "MigrationFileInvalidException", "(", "sprintf", "(", "'Migration file [%s] exists.'", ",", "$", "filename", ")", ")", ";", "}", "$", "templateTags", "[", "'phx:class'", "]", "=", "Helper", "::", "getQualifiedClassName", "(", "$", "filename", ")", ";", "$", "builder", "=", "new", "TemplateBuilder", "(", "$", "this", "->", "cmd", ",", "$", "this", "->", "env", ")", ";", "$", "builder", "->", "createClassTemplate", "(", "'migration'", ",", "$", "filename", ",", "$", "migrationsDirectory", ",", "$", "templateTags", ")", ";", "// After migration class has been created, the record needs to go to the database and be set to pending.\r", "$", "model", "=", "new", "Model", "(", ")", ";", "$", "model", "->", "class_name", "=", "$", "templateTags", "[", "'phx:class'", "]", ";", "$", "model", "->", "status", "=", "Attribute", "::", "STATUS_PENDING", ";", "$", "model", "->", "path", "=", "$", "path", ";", "$", "model", "->", "save", "(", ")", ";", "$", "this", "->", "env", "->", "sendOutput", "(", "'Created migration is now pending'", ",", "'green'", ")", ";", "}" ]
Creates a migration. @param $arguments <Array> @access protected @return <void>
[ "Creates", "a", "migration", "." ]
train
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Migration.php#L145-L177
[ "Array" ]
What does this function return?
[ "\t<void>" ]
PhoxPHP/Glider
src/Console/Command/Migration.php
Migration.processMigration
protected function processMigration(Array $arguments) { $migrationClass = $arguments[0]; $migration = Model::findByclass_name($migrationClass); if (!$migration) { throw new MigrationClassNotFoundException( sprintf( 'Migration class [%s] does not exist', $migrationClass ) ); } if (isset($arguments[1]) && $arguments[1] == '--down') { self::$migrationType = Attribute::DOWNGRADE; } $this->migrator->runSingleMigration($migration); }
php
protected function processMigration(Array $arguments) { $migrationClass = $arguments[0]; $migration = Model::findByclass_name($migrationClass); if (!$migration) { throw new MigrationClassNotFoundException( sprintf( 'Migration class [%s] does not exist', $migrationClass ) ); } if (isset($arguments[1]) && $arguments[1] == '--down') { self::$migrationType = Attribute::DOWNGRADE; } $this->migrator->runSingleMigration($migration); }
[ "protected", "function", "processMigration", "(", "Array", "$", "arguments", ")", "{", "$", "migrationClass", "=", "$", "arguments", "[", "0", "]", ";", "$", "migration", "=", "Model", "::", "findByclass_name", "(", "$", "migrationClass", ")", ";", "if", "(", "!", "$", "migration", ")", "{", "throw", "new", "MigrationClassNotFoundException", "(", "sprintf", "(", "'Migration class [%s] does not exist'", ",", "$", "migrationClass", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "1", "]", ")", "&&", "$", "arguments", "[", "1", "]", "==", "'--down'", ")", "{", "self", "::", "$", "migrationType", "=", "Attribute", "::", "DOWNGRADE", ";", "}", "$", "this", "->", "migrator", "->", "runSingleMigration", "(", "$", "migration", ")", ";", "}" ]
Processes a specific migration. @param $arguments <Array> @access protected @return <void>
[ "Processes", "a", "specific", "migration", "." ]
train
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Migration.php#L199-L218
[ "Array" ]
What does this function return?
[ "\t<void>" ]
iwyg/xmlconf
src/Thapp/XmlConf/Cache/Cache.php
Cache.getCacheModificationDate
protected function getCacheModificationDate($file) { $storageKey = $this->getStorageKey() . '.lasmodified'; $filemtime = filemtime($file); $lastmodified = $this->storage->has($storageKey) ? $this->storage->get($storageKey) : $filemtime - 1; return array($filemtime, $lastmodified); }
php
protected function getCacheModificationDate($file) { $storageKey = $this->getStorageKey() . '.lasmodified'; $filemtime = filemtime($file); $lastmodified = $this->storage->has($storageKey) ? $this->storage->get($storageKey) : $filemtime - 1; return array($filemtime, $lastmodified); }
[ "protected", "function", "getCacheModificationDate", "(", "$", "file", ")", "{", "$", "storageKey", "=", "$", "this", "->", "getStorageKey", "(", ")", ".", "'.lasmodified'", ";", "$", "filemtime", "=", "filemtime", "(", "$", "file", ")", ";", "$", "lastmodified", "=", "$", "this", "->", "storage", "->", "has", "(", "$", "storageKey", ")", "?", "$", "this", "->", "storage", "->", "get", "(", "$", "storageKey", ")", ":", "$", "filemtime", "-", "1", ";", "return", "array", "(", "$", "filemtime", ",", "$", "lastmodified", ")", ";", "}" ]
Returns the modification date of a given file and the the date of the last cache write. @access protected @return array
[ "Returns", "the", "modification", "date", "of", "a", "given", "file", "and", "the", "the", "date", "of", "the", "last", "cache", "write", "." ]
train
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/Cache/Cache.php#L97-L104
[ "file" ]
What does this function return?
[ "array" ]
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.create
public function create(array $metadata = array()) { if (is_file($this->file)) { return false; } $this->createTemporaryFolder(); file_put_contents($this->file, $this->placeholderContent($metadata), LOCK_EX); return true; }
php
public function create(array $metadata = array()) { if (is_file($this->file)) { return false; } $this->createTemporaryFolder(); file_put_contents($this->file, $this->placeholderContent($metadata), LOCK_EX); return true; }
[ "public", "function", "create", "(", "array", "$", "metadata", "=", "array", "(", ")", ")", "{", "if", "(", "is_file", "(", "$", "this", "->", "file", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "createTemporaryFolder", "(", ")", ";", "file_put_contents", "(", "$", "this", "->", "file", ",", "$", "this", "->", "placeholderContent", "(", "$", "metadata", ")", ",", "LOCK_EX", ")", ";", "return", "true", ";", "}" ]
Creates the file. It creates a placeholder file with some metadata on it and will create all the temporary files and folders. Writing without creating first will throw an exception. Creating twice will not throw an exception but will return false. That means it is OK to call `create()` before calling `write()`. Ideally it should be called once when the writing of the file is initialized. @param array $metadata @return bool
[ "Creates", "the", "file", ".", "It", "creates", "a", "placeholder", "file", "with", "some", "metadata", "on", "it", "and", "will", "create", "all", "the", "temporary", "files", "and", "folders", "." ]
train
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L72-L82
[ "array" ]
What does this function return?
[ "bool" ]
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.write
public function write($offset, $input, $limit = -1) { if (!is_dir($this->blocks)) { throw new RuntimeException("Cannot write into the file"); } $block = new BlockWriter($this->blocks . $offset, $this->tmp); $wrote = $block->write($input, $limit); $block->commit(); return $block; }
php
public function write($offset, $input, $limit = -1) { if (!is_dir($this->blocks)) { throw new RuntimeException("Cannot write into the file"); } $block = new BlockWriter($this->blocks . $offset, $this->tmp); $wrote = $block->write($input, $limit); $block->commit(); return $block; }
[ "public", "function", "write", "(", "$", "offset", ",", "$", "input", ",", "$", "limit", "=", "-", "1", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "blocks", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Cannot write into the file\"", ")", ";", "}", "$", "block", "=", "new", "BlockWriter", "(", "$", "this", "->", "blocks", ".", "$", "offset", ",", "$", "this", "->", "tmp", ")", ";", "$", "wrote", "=", "$", "block", "->", "write", "(", "$", "input", ",", "$", "limit", ")", ";", "$", "block", "->", "commit", "(", ")", ";", "return", "$", "block", ";", "}" ]
Writes content to this file. This writer must provide the $offset where this data is going to be written. The $content maybe a stream (the output of `fopen()`) or a string. Both type of `$content` can have a `$limit` to limit the number of bytes that are written. @param int $offset @param string|stream $content @param int $limit @return BlockWriter Return the BlockWriter object.
[ "Writes", "content", "to", "this", "file", ".", "This", "writer", "must", "provide", "the", "$offset", "where", "this", "data", "is", "going", "to", "be", "written", ".", "The", "$content", "maybe", "a", "stream", "(", "the", "output", "of", "fopen", "()", ")", "or", "a", "string", ".", "Both", "type", "of", "$content", "can", "have", "a", "$limit", "to", "limit", "the", "number", "of", "bytes", "that", "are", "written", "." ]
train
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L122-L132
[ "offset", "input", "limit" ]
What does this function return?
[ "BlockWriter", "Return", "the", "BlockWriter", "object." ]
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.getWroteBlocks
public function getWroteBlocks() { if (!is_dir($this->blocks)) { throw new RuntimeException("cannot obtain the blocks ({$this->blocks})"); } $files = array_filter(array_map(function($file) { $basename = basename($file); if (!is_numeric($basename)) { return false; } return [ 'offset' => (int)$basename, 'file' => $file, 'size' => filesize($file) ]; }, glob($this->blocks . "*"))); uasort($files, function($a, $b) { return $a['offset'] - $b['offset']; }); return $files; }
php
public function getWroteBlocks() { if (!is_dir($this->blocks)) { throw new RuntimeException("cannot obtain the blocks ({$this->blocks})"); } $files = array_filter(array_map(function($file) { $basename = basename($file); if (!is_numeric($basename)) { return false; } return [ 'offset' => (int)$basename, 'file' => $file, 'size' => filesize($file) ]; }, glob($this->blocks . "*"))); uasort($files, function($a, $b) { return $a['offset'] - $b['offset']; }); return $files; }
[ "public", "function", "getWroteBlocks", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "blocks", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"cannot obtain the blocks ({$this->blocks})\"", ")", ";", "}", "$", "files", "=", "array_filter", "(", "array_map", "(", "function", "(", "$", "file", ")", "{", "$", "basename", "=", "basename", "(", "$", "file", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "basename", ")", ")", "{", "return", "false", ";", "}", "return", "[", "'offset'", "=>", "(", "int", ")", "$", "basename", ",", "'file'", "=>", "$", "file", ",", "'size'", "=>", "filesize", "(", "$", "file", ")", "]", ";", "}", ",", "glob", "(", "$", "this", "->", "blocks", ".", "\"*\"", ")", ")", ")", ";", "uasort", "(", "$", "files", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "[", "'offset'", "]", "-", "$", "b", "[", "'offset'", "]", ";", "}", ")", ";", "return", "$", "files", ";", "}" ]
Returns all the wrote blocks of files. All the blocks are sorted by their offset. @return array
[ "Returns", "all", "the", "wrote", "blocks", "of", "files", ".", "All", "the", "blocks", "are", "sorted", "by", "their", "offset", "." ]
train
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L139-L161
[]
What does this function return?
[ "array" ]
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.getMissingBlocks
public function getMissingBlocks(Array $blocks = array()) { $missing = array(); $blocks = $blocks ? $blocks : $this->getWroteBlocks(); $last = array_shift($blocks); if ($last['offset'] !== 0) { $missing[] = array('offset' => 0, 'size' => $last['offset']); } foreach ($blocks as $block) { if ($block['offset'] !== $last['offset'] + $last['size']) { $offset = $last['offset'] + $last['size']; $missing[] = array('offset' => $offset, 'size' => $block['offset'] - $offset); } $last = $block; } return $missing; }
php
public function getMissingBlocks(Array $blocks = array()) { $missing = array(); $blocks = $blocks ? $blocks : $this->getWroteBlocks(); $last = array_shift($blocks); if ($last['offset'] !== 0) { $missing[] = array('offset' => 0, 'size' => $last['offset']); } foreach ($blocks as $block) { if ($block['offset'] !== $last['offset'] + $last['size']) { $offset = $last['offset'] + $last['size']; $missing[] = array('offset' => $offset, 'size' => $block['offset'] - $offset); } $last = $block; } return $missing; }
[ "public", "function", "getMissingBlocks", "(", "Array", "$", "blocks", "=", "array", "(", ")", ")", "{", "$", "missing", "=", "array", "(", ")", ";", "$", "blocks", "=", "$", "blocks", "?", "$", "blocks", ":", "$", "this", "->", "getWroteBlocks", "(", ")", ";", "$", "last", "=", "array_shift", "(", "$", "blocks", ")", ";", "if", "(", "$", "last", "[", "'offset'", "]", "!==", "0", ")", "{", "$", "missing", "[", "]", "=", "array", "(", "'offset'", "=>", "0", ",", "'size'", "=>", "$", "last", "[", "'offset'", "]", ")", ";", "}", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "if", "(", "$", "block", "[", "'offset'", "]", "!==", "$", "last", "[", "'offset'", "]", "+", "$", "last", "[", "'size'", "]", ")", "{", "$", "offset", "=", "$", "last", "[", "'offset'", "]", "+", "$", "last", "[", "'size'", "]", ";", "$", "missing", "[", "]", "=", "array", "(", "'offset'", "=>", "$", "offset", ",", "'size'", "=>", "$", "block", "[", "'offset'", "]", "-", "$", "offset", ")", ";", "}", "$", "last", "=", "$", "block", ";", "}", "return", "$", "missing", ";", "}" ]
Returns the empty blocks in a file, if any gap is missing `finalize()` will fail and will throw an exception. @param $blocks Provides the list of blocks, otherwise `getWroteBlocks()` will be called. @return array
[ "Returns", "the", "empty", "blocks", "in", "a", "file", "if", "any", "gap", "is", "missing", "finalize", "()", "will", "fail", "and", "will", "throw", "an", "exception", "." ]
train
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L172-L191
[ "Array" ]
What does this function return?
[ "array" ]
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.finalize
public function finalize() { if (!is_file($this->tmp . '.lock')) { throw new RuntimeException("File is already completed"); } $lock = fopen($this->tmp . '.lock', 'r+'); if (!flock($lock, LOCK_EX | LOCK_NB)) { return false; } $blocks = $this->getWroteBlocks(); $missing = $this->getMissingBlocks($blocks); if (!empty($missing)) { flock($lock, LOCK_UN); fclose($lock); throw new RuntimeException("File is incomplete, cannot finalize it"); } $file = new BlockWriter($this->file, $this->tmp); $fp = $file->getStream(); foreach ($blocks as $block) { $tmp = fopen($block['file'], 'r'); fseek($fp, $block['offset']); stream_copy_to_stream($tmp, $fp); fclose($tmp); } $file->commit(); Util::delete($this->tmp); flock($lock, LOCK_UN); fclose($lock); // We do not release the lock on porpuse. return true; }
php
public function finalize() { if (!is_file($this->tmp . '.lock')) { throw new RuntimeException("File is already completed"); } $lock = fopen($this->tmp . '.lock', 'r+'); if (!flock($lock, LOCK_EX | LOCK_NB)) { return false; } $blocks = $this->getWroteBlocks(); $missing = $this->getMissingBlocks($blocks); if (!empty($missing)) { flock($lock, LOCK_UN); fclose($lock); throw new RuntimeException("File is incomplete, cannot finalize it"); } $file = new BlockWriter($this->file, $this->tmp); $fp = $file->getStream(); foreach ($blocks as $block) { $tmp = fopen($block['file'], 'r'); fseek($fp, $block['offset']); stream_copy_to_stream($tmp, $fp); fclose($tmp); } $file->commit(); Util::delete($this->tmp); flock($lock, LOCK_UN); fclose($lock); // We do not release the lock on porpuse. return true; }
[ "public", "function", "finalize", "(", ")", "{", "if", "(", "!", "is_file", "(", "$", "this", "->", "tmp", ".", "'.lock'", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"File is already completed\"", ")", ";", "}", "$", "lock", "=", "fopen", "(", "$", "this", "->", "tmp", ".", "'.lock'", ",", "'r+'", ")", ";", "if", "(", "!", "flock", "(", "$", "lock", ",", "LOCK_EX", "|", "LOCK_NB", ")", ")", "{", "return", "false", ";", "}", "$", "blocks", "=", "$", "this", "->", "getWroteBlocks", "(", ")", ";", "$", "missing", "=", "$", "this", "->", "getMissingBlocks", "(", "$", "blocks", ")", ";", "if", "(", "!", "empty", "(", "$", "missing", ")", ")", "{", "flock", "(", "$", "lock", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "lock", ")", ";", "throw", "new", "RuntimeException", "(", "\"File is incomplete, cannot finalize it\"", ")", ";", "}", "$", "file", "=", "new", "BlockWriter", "(", "$", "this", "->", "file", ",", "$", "this", "->", "tmp", ")", ";", "$", "fp", "=", "$", "file", "->", "getStream", "(", ")", ";", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "$", "tmp", "=", "fopen", "(", "$", "block", "[", "'file'", "]", ",", "'r'", ")", ";", "fseek", "(", "$", "fp", ",", "$", "block", "[", "'offset'", "]", ")", ";", "stream_copy_to_stream", "(", "$", "tmp", ",", "$", "fp", ")", ";", "fclose", "(", "$", "tmp", ")", ";", "}", "$", "file", "->", "commit", "(", ")", ";", "Util", "::", "delete", "(", "$", "this", "->", "tmp", ")", ";", "flock", "(", "$", "lock", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "lock", ")", ";", "// We do not release the lock on porpuse.", "return", "true", ";", "}" ]
Finalizes writing a file. The finalization of a file means check that there are no gap or missing block in a file, lock the file (so no other write may happen or another `finalize()`). In here, after locking, all the blocks are merged into a single file. When the merging is ready, we rename the temporary file as the filename we expected. When that process is done, all the blocks files are deleted and the file is ready. @return bool
[ "Finalizes", "writing", "a", "file", ".", "The", "finalization", "of", "a", "file", "means", "check", "that", "there", "are", "no", "gap", "or", "missing", "block", "in", "a", "file", "lock", "the", "file", "(", "so", "no", "other", "write", "may", "happen", "or", "another", "finalize", "()", ")", "." ]
train
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L203-L238
[]
What does this function return?
[ "bool" ]
DimNS/MFLPHP
src/Pages/User/ActionLogin.php
ActionLogin.run
public function run($user_email, $user_pass) { $result = [ 'error' => true, 'message' => 'Неизвестная ошибка.', ]; $loginResult = $this->di->auth->login($user_email, $user_pass, false); if ($loginResult['error'] === false) { $user_id = $this->di->auth->getUID($user_email); if ($user_id !== false) { $user_info = \ORM::for_table('users_info') ->where_equal('uid', $user_id) ->find_one(); if (is_object($user_info)) { $user_info->last_login = $this->di->carbon->toDateTimeString(); $user_info->save(); setcookie($this->di->auth->config->cookie_name, $loginResult['hash'], $loginResult['expire'], $this->di->auth->config->cookie_path, $this->di->auth->config->cookie_domain, $this->di->auth->config->cookie_secure, $this->di->auth->config->cookie_http); return [ 'error' => false, 'message' => 'Добро пожаловать!', ]; } else { $result['message'] = 'Произошла ошибка при изменении данных. Попробуйте войти ещё раз.'; } } else { $result['message'] = 'Данные пользователя не найдены. Попробуйте войти ещё раз.'; } } else { $result['message'] = $loginResult['message']; } return $result; }
php
public function run($user_email, $user_pass) { $result = [ 'error' => true, 'message' => 'Неизвестная ошибка.', ]; $loginResult = $this->di->auth->login($user_email, $user_pass, false); if ($loginResult['error'] === false) { $user_id = $this->di->auth->getUID($user_email); if ($user_id !== false) { $user_info = \ORM::for_table('users_info') ->where_equal('uid', $user_id) ->find_one(); if (is_object($user_info)) { $user_info->last_login = $this->di->carbon->toDateTimeString(); $user_info->save(); setcookie($this->di->auth->config->cookie_name, $loginResult['hash'], $loginResult['expire'], $this->di->auth->config->cookie_path, $this->di->auth->config->cookie_domain, $this->di->auth->config->cookie_secure, $this->di->auth->config->cookie_http); return [ 'error' => false, 'message' => 'Добро пожаловать!', ]; } else { $result['message'] = 'Произошла ошибка при изменении данных. Попробуйте войти ещё раз.'; } } else { $result['message'] = 'Данные пользователя не найдены. Попробуйте войти ещё раз.'; } } else { $result['message'] = $loginResult['message']; } return $result; }
[ "public", "function", "run", "(", "$", "user_email", ",", "$", "user_pass", ")", "{", "$", "result", "=", "[", "'error'", "=>", "true", ",", "'message'", "=>", "'Неизвестная ошибка.',", "", "]", ";", "$", "loginResult", "=", "$", "this", "->", "di", "->", "auth", "->", "login", "(", "$", "user_email", ",", "$", "user_pass", ",", "false", ")", ";", "if", "(", "$", "loginResult", "[", "'error'", "]", "===", "false", ")", "{", "$", "user_id", "=", "$", "this", "->", "di", "->", "auth", "->", "getUID", "(", "$", "user_email", ")", ";", "if", "(", "$", "user_id", "!==", "false", ")", "{", "$", "user_info", "=", "\\", "ORM", "::", "for_table", "(", "'users_info'", ")", "->", "where_equal", "(", "'uid'", ",", "$", "user_id", ")", "->", "find_one", "(", ")", ";", "if", "(", "is_object", "(", "$", "user_info", ")", ")", "{", "$", "user_info", "->", "last_login", "=", "$", "this", "->", "di", "->", "carbon", "->", "toDateTimeString", "(", ")", ";", "$", "user_info", "->", "save", "(", ")", ";", "setcookie", "(", "$", "this", "->", "di", "->", "auth", "->", "config", "->", "cookie_name", ",", "$", "loginResult", "[", "'hash'", "]", ",", "$", "loginResult", "[", "'expire'", "]", ",", "$", "this", "->", "di", "->", "auth", "->", "config", "->", "cookie_path", ",", "$", "this", "->", "di", "->", "auth", "->", "config", "->", "cookie_domain", ",", "$", "this", "->", "di", "->", "auth", "->", "config", "->", "cookie_secure", ",", "$", "this", "->", "di", "->", "auth", "->", "config", "->", "cookie_http", ")", ";", "return", "[", "'error'", "=>", "false", ",", "'message'", "=>", "'Добро пожаловать!',", "", "]", ";", "}", "else", "{", "$", "result", "[", "'message'", "]", "=", "'Произошла ошибка при изменении данных. Попробуйте войти ещё раз.';", "", "}", "}", "else", "{", "$", "result", "[", "'message'", "]", "=", "'Данные пользователя не найдены. Попробуйте войти ещё раз.';", "", "}", "}", "else", "{", "$", "result", "[", "'message'", "]", "=", "$", "loginResult", "[", "'message'", "]", ";", "}", "return", "$", "result", ";", "}" ]
Выполним действие @param string $user_email Адрес электронной почты @param string $user_pass Пароль пользователя @return array @version 22.04.2017 @author Дмитрий Щербаков <atomcms@ya.ru>
[ "Выполним", "действие" ]
train
https://github.com/DimNS/MFLPHP/blob/8da06f3f9aabf1da5796f9a3cea97425b30af201/src/Pages/User/ActionLogin.php#L26-L62
[ "user_email", "user_pass" ]
What does this function return?
[ "array", "", "@version", "22.04.2017", "@author", "", "Дмитрий", "Щербаков", "<atomcms@ya.ru>" ]
nyeholt/silverstripe-performant
code/model/DataObjectNode.php
DataObjectNode.isSection
public function isSection() { if ($this->isCurrent()) { return true; } $ancestors = $this->getAncestors(); if (Director::get_current_page() instanceof Page) { $node = Director::get_current_page()->asMenuItem(); if ($node) { $ancestors = $node->getAncestors(); return $ancestors && in_array($this->ID, $node->getAncestors()->column()); } } return false; }
php
public function isSection() { if ($this->isCurrent()) { return true; } $ancestors = $this->getAncestors(); if (Director::get_current_page() instanceof Page) { $node = Director::get_current_page()->asMenuItem(); if ($node) { $ancestors = $node->getAncestors(); return $ancestors && in_array($this->ID, $node->getAncestors()->column()); } } return false; }
[ "public", "function", "isSection", "(", ")", "{", "if", "(", "$", "this", "->", "isCurrent", "(", ")", ")", "{", "return", "true", ";", "}", "$", "ancestors", "=", "$", "this", "->", "getAncestors", "(", ")", ";", "if", "(", "Director", "::", "get_current_page", "(", ")", "instanceof", "Page", ")", "{", "$", "node", "=", "Director", "::", "get_current_page", "(", ")", "->", "asMenuItem", "(", ")", ";", "if", "(", "$", "node", ")", "{", "$", "ancestors", "=", "$", "node", "->", "getAncestors", "(", ")", ";", "return", "$", "ancestors", "&&", "in_array", "(", "$", "this", "->", "ID", ",", "$", "node", "->", "getAncestors", "(", ")", "->", "column", "(", ")", ")", ";", "}", "}", "return", "false", ";", "}" ]
Check if this page is in the currently active section (e.g. it is either current or one of its children is currently being viewed). @return bool
[ "Check", "if", "this", "page", "is", "in", "the", "currently", "active", "section", "(", "e", ".", "g", ".", "it", "is", "either", "current", "or", "one", "of", "its", "children", "is", "currently", "being", "viewed", ")", "." ]
train
https://github.com/nyeholt/silverstripe-performant/blob/2c9d2570ddf4a43ced38487184da4de453a4863c/code/model/DataObjectNode.php#L70-L84
[]
What does this function return?
[ "bool" ]