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_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
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); } } ...
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); } } ...
Размер директории в байтах @param string $dir Путь на директорию @return int
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L359-L371
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 = ...
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 = ...
Создание пути на директорию из идентификатора @param string $id Идентификатор, который режится на имена директорий. При недостаточности длины добавляются нули. @param int $size Длина для имен директорий @param int $depth Вложенность директорий @return string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L380-L391
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]; ...
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]; ...
Создание виртуального диска в Windows, для увеличения лимита на длину пути к файлам @param $dir @param bool $mkdir @return mixed|string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L399-L419
Boolive/Core
file/File.php
File.deleteVirtualDir
static function deleteVirtualDir($vdir) { if (self::$IS_WIN && mb_substr($vdir,0,1) == self::VIRT_DISK){ system('subst '.self::VIRT_DISK.': /d'); } }
php
static function deleteVirtualDir($vdir) { if (self::$IS_WIN && mb_substr($vdir,0,1) == self::VIRT_DISK){ system('subst '.self::VIRT_DISK.': /d'); } }
Удаление виртуального диска в Windows @param string $vdir Директория с виртуальным диском
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/file/File.php#L425-L430
asbamboo/http
Client.php
Client.setBodyCurlOpt
private function setBodyCurlOpt(RequestInterface $Request) : void { /* * Some HTTP methods cannot have payload: * * - GET — cURL will automatically change method to PUT or POST if we set CURLOPT_UPLOAD or * CURLOPT_POSTFIELDS. * - HEAD — cURL treats HEAD as GE...
php
private function setBodyCurlOpt(RequestInterface $Request) : void { /* * Some HTTP methods cannot have payload: * * - GET — cURL will automatically change method to PUT or POST if we set CURLOPT_UPLOAD or * CURLOPT_POSTFIELDS. * - HEAD — cURL treats HEAD as GE...
设置body相关的curl option @param RequestInterface $Request
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L122-L162
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...
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...
返回curl option CURLOPT_HTTPHEADER @param RequestInterface $Request @return array
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L170-L191
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_HT...
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_HT...
返回curl option CURLOPT_HTTP_VERSION @param RequestInterface $Request @return int
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L199-L210
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; ...
php
private function getCurloptHeaderFunction() : callable { return function($ch, $data){ $str = trim($data); if('' !== $str){ if(strpos(strtolower($str), 'http/') === 0){ $status_line = $str; ...
返回curl option CURLOPT_HEADERFUNCTION @return callable
https://github.com/asbamboo/http/blob/721156e29227854b787a1232eaa995ab2ccd4f25/Client.php#L217-L235
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(); }
Renders tab. @return string
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php#L63-L74
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(); }
Renders panel. @return string
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Bridges/NetteTracy/ConnectionPanel.php#L80-L92
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->GetSc...
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->GetSc...
Insert a \MvcCore\View in each helper constructing @param \MvcCore\View|\MvcCore\IView $view @return \MvcCore\Ext\Views\Helpers\AbstractHelper
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L150-L184
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']; } }
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
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L195-L200
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); } }
Returns file modification imprint by global settings - by `md5_file()` or by `filemtime()` - always as a string @param string $fullPath @return string
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L231-L238
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=' ...
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=' ...
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, tha...
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L268-L279
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\...
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\...
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 be...
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L301-L311
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 & $...
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 & $...
Look for every item to render if there is any 'doNotMinify' record to render item separately @param array $items @return array[] $itemsToRenderMinimized $itemsToRenderSeparately
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L326-L354
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(sel...
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(sel...
Add to href URL file modification param by original file @param string $url @param string $path @return string
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L362-L377
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 $indentS...
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 $indentS...
Get indent string @param string|int $indent @return string
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L384-L399
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); } ...
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); } ...
Return and store application document root from controller view request object @throws \Exception @return string
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L414-L431
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); }
Save atomically file content in full path by 1 MB to not overflow any memory limits @param string $fullPath @param string $fileContent @return void
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L439-L443
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); } }
Log any render messages with optional log file name @param string $msg @param string $logType @return void
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L451-L455
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); } }
Throw exception with given message with actual helper class name before @param string $msg @return void
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L474-L478
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 ]); }
Complete items group tmp directory file name by group source files info @param array $filesGroupInfo @param boolean $minify @return string
https://github.com/mvccore/ext-view-helper-assets/blob/5672575aca6d63f2340c912f9b9754bbb896d97b/src/MvcCore/Ext/Views/Helpers/Assets.php#L497-L504
nilportugues/php-todo-finder
src/TodoFinder/Finder/FileParser.php
FileParser.validateFileStructure
private function validateFileStructure(array &$file) { if (false === array_key_exists(self::TODO_FINDER, $file)) { throw new FileParserException( sprintf( 'Provided YAML file does not compile with the required format. ' .'Expected \'%s\' ke...
php
private function validateFileStructure(array &$file) { if (false === array_key_exists(self::TODO_FINDER, $file)) { throw new FileParserException( sprintf( 'Provided YAML file does not compile with the required format. ' .'Expected \'%s\' ke...
@param array $file @throws FileParserException
https://github.com/nilportugues/php-todo-finder/blob/eea3e63714633744e6e576bf0ca4b8e1d7c20be5/src/TodoFinder/Finder/FileParser.php#L42-L56
nilportugues/php-todo-finder
src/TodoFinder/Finder/FileParser.php
FileParser.assertYamlKey
private function assertYamlKey(array &$file, $key) { if (false === array_key_exists($key, $file)) { throw new FileParserException( sprintf( 'Provided YAML file does not compile with the required format. ' .'Expected \'%s\' key under \'%s\' ...
php
private function assertYamlKey(array &$file, $key) { if (false === array_key_exists($key, $file)) { throw new FileParserException( sprintf( 'Provided YAML file does not compile with the required format. ' .'Expected \'%s\' key under \'%s\' ...
@param array $file @param string $key @throws FileParserException
https://github.com/nilportugues/php-todo-finder/blob/eea3e63714633744e6e576bf0ca4b8e1d7c20be5/src/TodoFinder/Finder/FileParser.php#L64-L76
schpill/thin
src/Multithread.php
Multithread.run
public function run($jobs) { $lenTab = count($jobs); for ($i = 0 ; $i < $lenTab ; $i++) { $jobID = rand(0, 100); while (count($this->currentJobs) >= $this->maxProcesses) { sleep($this->sleepTime); } $lau...
php
public function run($jobs) { $lenTab = count($jobs); for ($i = 0 ; $i < $lenTab ; $i++) { $jobID = rand(0, 100); while (count($this->currentJobs) >= $this->maxProcesses) { sleep($this->sleepTime); } $lau...
Run the Daemon
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Multithread.php#L24-L39
schpill/thin
src/Multithread.php
Multithread.launchJob
protected function launchJob($jobID) { $pid = pcntl_fork(); if ($pid == -1) { error_log('Could not launch new job, exiting'); echo 'Could not launch new job, exiting'; return false; } else if ($pid) { $this->curr...
php
protected function launchJob($jobID) { $pid = pcntl_fork(); if ($pid == -1) { error_log('Could not launch new job, exiting'); echo 'Could not launch new job, exiting'; return false; } else if ($pid) { $this->curr...
Launch a job from the job queue
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Multithread.php#L83-L101
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_...
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_...
Return table and view names form the database. @throws DatabaseEx @return array
https://github.com/rzajac/php-test-helper/blob/37280e9ff639b25cf9413909cc080c5d8deb311c/src/Database/Driver/MySQL.php#L164-L175
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']); }
Index method @return \Cake\Http\Response|void
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L28-L33
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))...
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))...
Add method @return \Cake\Http\Response|void|null Redirects on successful add, renders view otherwise.
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L40-L56
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-...
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-...
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.
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Controller/LanguagesController.php#L65-L76
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_E...
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_E...
@param TokenStoreInterface $tokenStore @return State The default starting state
https://github.com/graze/csv-token/blob/ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8/src/Tokeniser/StateBuilder.php#L26-L52
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; }
Get a dirname with one and only trailing slash @param string $dirname @return string
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L43-L49
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)); }
Test if a path seems to be a git clone @param string $path @return bool
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L57-L64
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)); }
Test if a filename seems to have a dot as first character @param string $path @return bool
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L72-L78
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( n...
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( n...
Try to remove a path @param string $path @param bool $parent @return bool
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L117-L144
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; }
Read and parse a INI content file @param $path @return array|bool
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L152-L161
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; } ...
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; } ...
Read and parse a JSON content file @param $path @return bool|mixed
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Filesystem/Helper.php#L169-L181
PhoxPHP/Glider
src/Console/Command/Migration.php
Migration.run
public function run(Array $argumentsList, int $argumentsCount) { $command = $argumentsList[0]; unset($argumentsList[0]); $arguments = array_values($argumentsList); $this->migrator->createMigrationsTable(); switch ($command) { case 'create': return $this->create(); break; case 'run...
php
public function run(Array $argumentsList, int $argumentsCount) { $command = $argumentsList[0]; unset($argumentsList[0]); $arguments = array_values($argumentsList); $this->migrator->createMigrationsTable(); switch ($command) { case 'create': return $this->create(); break; case 'run...
{@inheritDoc}
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Migration.php#L90-L112
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'; i...
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'; i...
Creates a migration. @param $arguments <Array> @access protected @return <void>
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Migration.php#L145-L177
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 ) ); ...
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 ) ); ...
Processes a specific migration. @param $arguments <Array> @access protected @return <void>
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Migration.php#L199-L218
iwyg/xmlconf
src/Thapp/XmlConf/Cache/Cache.php
Cache.isNew
public function isNew($file) { list($filemtime, $lastmodified) = $this->getCacheModificationDate($file); return $filemtime > $lastmodified; }
php
public function isNew($file) { list($filemtime, $lastmodified) = $this->getCacheModificationDate($file); return $filemtime > $lastmodified; }
{@inheritDoc}
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/Cache/Cache.php#L64-L68
iwyg/xmlconf
src/Thapp/XmlConf/Cache/Cache.php
Cache.write
public function write($data) { $this->storage->forget($this->getStorageKey() . '.lasmodified'); $this->storage->forget($this->getStorageKey()); $this->storage->forever($this->getStorageKey() . '.lasmodified', time()); $this->storage->forever($this->getStorageKey(), $data); }
php
public function write($data) { $this->storage->forget($this->getStorageKey() . '.lasmodified'); $this->storage->forget($this->getStorageKey()); $this->storage->forever($this->getStorageKey() . '.lasmodified', time()); $this->storage->forever($this->getStorageKey(), $data); }
{@inheritDoc}
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/Cache/Cache.php#L81-L88
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, $lastmodifie...
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, $lastmodifie...
Returns the modification date of a given file and the the date of the last cache write. @access protected @return array
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/Cache/Cache.php#L97-L104
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; }
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()`. Ideall...
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L72-L82
crodas/ConcurrentFileWriter
src/ConcurrentFileWriter/ConcurrentFileWriter.php
ConcurrentFileWriter.createTemporaryFolder
protected function createTemporaryFolder() { Util::mkdir($this->blocks); Util::mkdir(dirname($this->file)); file_put_contents($this->tmp . '.lock', '', LOCK_EX); }
php
protected function createTemporaryFolder() { Util::mkdir($this->blocks); Util::mkdir(dirname($this->file)); file_put_contents($this->tmp . '.lock', '', LOCK_EX); }
Creates the needed temporary files and folders in prepartion for the file writer.
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L88-L93
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();...
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();...
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...
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L122-L132
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)) { ...
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)) { ...
Returns all the wrote blocks of files. All the blocks are sorted by their offset. @return array
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L139-L161
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']); } ...
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']); } ...
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
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L172-L191
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-...
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-...
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 f...
https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/ConcurrentFileWriter.php#L203-L238
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->d...
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->d...
Выполним действие @param string $user_email Адрес электронной почты @param string $user_pass Пароль пользователя @return array @version 22.04.2017 @author Дмитрий Щербаков <atomcms@ya.ru>
https://github.com/DimNS/MFLPHP/blob/8da06f3f9aabf1da5796f9a3cea97425b30af201/src/Pages/User/ActionLogin.php#L26-L62
rackberg/para
src/Command/ListAvailablePluginsCommand.php
ListAvailablePluginsCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $plugins = $this->pluginManager->fetchPluginsAvailable(); if (!$plugins) { $output->writeln('No available plugins could be found at the moment!'); return; } $rows = []; forea...
php
protected function execute(InputInterface $input, OutputInterface $output) { $plugins = $this->pluginManager->fetchPluginsAvailable(); if (!$plugins) { $output->writeln('No available plugins could be found at the moment!'); return; } $rows = []; forea...
{@inheritdoc}
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/Command/ListAvailablePluginsCommand.php#L62-L83
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...
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...
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
https://github.com/nyeholt/silverstripe-performant/blob/2c9d2570ddf4a43ced38487184da4de453a4863c/code/model/DataObjectNode.php#L70-L84