_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q267600
Uri.param
test
public function param($key) { return isset($this->params[$key])
php
{ "resource": "" }
q267601
Uri.rebase
test
public function rebase($base) { return new static([ 'scheme' => $this->scheme, 'user' => $this->user, 'pass' => $this->password, 'host' => $this->host, 'port' => $this->port,
php
{ "resource": "" }
q267602
RouteCollection.addRoute
test
public function addRoute(Route $route): void { $key = md5(\json_encode((array) $route)); $this->routes[$key] = $route; foreach ($route->getRequestMethods() as $requestMethod) { // If this is a dynamic route if ($route->isDynamic()) { // Set the route's regex and path in the dynamic routes list $this->dynamicRoutes[$requestMethod][$route->getRegex()] = $key; } // Otherwise set it in the static routes array else {
php
{ "resource": "" }
q267603
RouteCollection.staticRoute
test
public function staticRoute(string $method, string $path): ? Route {
php
{ "resource": "" }
q267604
RouteCollection.issetStaticRoute
test
public function issetStaticRoute(string $method, string $path):
php
{ "resource": "" }
q267605
RouteCollection.dynamicRoute
test
public function dynamicRoute(string $method, string $regex): ? Route {
php
{ "resource": "" }
q267606
RouteCollection.issetDynamicRoute
test
public function issetDynamicRoute(string $method, string $regex): bool
php
{ "resource": "" }
q267607
RouteCollection.namedRoute
test
public function namedRoute(string $name): ? Route {
php
{ "resource": "" }
q267608
CrudView.createSubLeaves
test
protected function createSubLeaves() { parent::createSubLeaves(); $this->registerSubLeaf(new Button("Save", "Save", function(){ $this->model->savePressedEvent->raise(); })); $this->registerSubLeaf(new Button("Delete", "Delete", function(){ $this->model->deletePressedEvent->raise();
php
{ "resource": "" }
q267609
Locator.locate
test
public static function locate($filename) { if (@file_exists($filename)) return $filename; $_f = CarteBlanche::getPath('carte_blanche_core').$filename; if (!empty($_f) && @file_exists($_f)) return $_f; $include_paths = explode(PATH_SEPARATOR,get_include_path()); foreach($include_paths as $_inc) { $_f = DirectoryHelper::slashDirname($_inc).$filename;
php
{ "resource": "" }
q267610
Number.convert
test
public function convert(NumberSystem $newSystem) { $newDigits = []; $decimalValue = gmp_init($this->decimalValue()); do { $divisionResult = gmp_div_qr($decimalValue, $newSystem->getBase()); $remainder = gmp_strval($divisionResult[1]); $decimalValue = $divisionResult[0];
php
{ "resource": "" }
q267611
Number.equals
test
public function equals(Number $comparedNumber) { if ($this->value() !== $comparedNumber->value() ||
php
{ "resource": "" }
q267612
Number.decimalValue
test
protected function decimalValue() { $base = $this->numberSystem->getBase(); $result = 0; foreach (array_reverse($this->getDigits()) as $position => $value) { $numberSystemPosition
php
{ "resource": "" }
q267613
Number.add
test
public function add(Number $addend) { $resultDecimalValue = $this->decimalValue() + $addend->decimalValue();
php
{ "resource": "" }
q267614
Number.subtract
test
public function subtract(Number $subtractor) { $resultDecimalValue = $this->decimalValue() - $subtractor->decimalValue();
php
{ "resource": "" }
q267615
Number.multiply
test
public function multiply(Number $multiplicator) { $resultDecimalValue = $this->decimalValue() * $multiplicator->decimalValue();
php
{ "resource": "" }
q267616
Number.divide
test
public function divide(Number $multiplicator) { $resultDecimalValue = round($this->decimalValue() /
php
{ "resource": "" }
q267617
Mysqli.getAdapter
test
public static function getAdapter(\Mysqli $mysqli) { $driver = new Driver\Mysqli\Mysqli($mysqli);
php
{ "resource": "" }
q267618
CloneModel.aliasList
test
public static function aliasList() { $result = []; foreach (\Yii::$aliases as $alias => $data) { if (is_array($data)) { $result = array_merge($result, array_keys($data)); } else {
php
{ "resource": "" }
q267619
CloneModel.findAliases
test
public static function findAliases($query) { $query = '@' . str_replace('@', '',
php
{ "resource": "" }
q267620
CloneModel.replace
test
private function replace() { $destination = Yii::getAlias($this->destination); $destinationModuleName = $this->getDestinationModuleName(); foreach (FileHelper::findFiles($destination) as $path) { if (!$this->replace && in_array($path, $this->keepFiles)) { continue; } if (!preg_match('/^.*\.php$/', $path, $matches)) { // php file. continue; } else if (preg_match('/^.*\W([A-Z]\w+)\.php$/', $path, $matches)) { // Class file. file_put_contents($path, $this->createClassContent($matches[1], $path)); } else if (self::isMigration($path)) { // Class file. file_put_contents($path, $this->updateFileContent($path));
php
{ "resource": "" }
q267621
HTTP_Request2_SocketWrapper.readLine
test
public function readLine($bufferSize, $localTimeout = null) { $line = ''; while (!feof($this->socket)) { if (null !== $localTimeout) { stream_set_timeout($this->socket, $localTimeout); } elseif ($this->deadline) { stream_set_timeout($this->socket, max($this->deadline - time(), 1)); } $line .= @fgets($this->socket, $bufferSize); if (null === $localTimeout) { $this->checkTimeout(); } else {
php
{ "resource": "" }
q267622
HTTP_Request2_SocketWrapper.enableCrypto
test
public function enableCrypto() { $modes = array( STREAM_CRYPTO_METHOD_TLS_CLIENT, STREAM_CRYPTO_METHOD_SSLv3_CLIENT, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, STREAM_CRYPTO_METHOD_SSLv2_CLIENT ); foreach ($modes as $mode) { if
php
{ "resource": "" }
q267623
HTTP_Request2_SocketWrapper.checkTimeout
test
protected function checkTimeout() { $info = stream_get_meta_data($this->socket); if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { $reason = $this->deadline ? "after {$this->timeout} second(s)"
php
{ "resource": "" }
q267624
SlimBridge.addRoute
test
public function addRoute(RouteInterface $route) { if (!$route->isValid()) { //perhaps some log? return; } $routeValue = $route->getAction()->getValue(); $this->app->map( [strtolower($route->getMethod()->getValue())], $route->getUri()->getValue(), function ( RequestInterface $request, ResponseInterface $response,
php
{ "resource": "" }
q267625
Attributes.setItems
test
private function setItems(array $items) { $this->items = array_merge($this->defaults, $items);
php
{ "resource": "" }
q267626
Attributes.build
test
public function build($siteKey, array $items = []) { $this->setItems($items); $output = []; foreach ($this->getItems($siteKey) as $key => $value) {
php
{ "resource": "" }
q267627
Attributes.prepareNameAttribute
test
public function prepareNameAttribute($name) { if (is_null($name)) return []; if ($name === NoCaptcha::CAPTCHA_NAME) { throw new InvalidArgumentException(
php
{ "resource": "" }
q267628
Attributes.checkDataAttribute
test
private function checkDataAttribute($name, $default, array $available) { $item = $this->getItem($name); if ( ! is_null($item)) { $item = (is_string($item) and in_array($item, $available)) ?
php
{ "resource": "" }
q267629
SingleUseQueue.add
test
public function add($resource) { if (!isset($this->added[$path = $resource->getPath()])) {
php
{ "resource": "" }
q267630
DayBuilder.fromArray
test
public static function fromArray($dayOfWeek, array $openingIntervals): Day { $intervals = []; foreach ($openingIntervals as $interval) { if ($interval instanceof TimeIntervalInterface) { $intervals[] = $interval; } elseif (\is_array($intervals)) { $intervals[] = new TimeInterval( TimeBuilder::fromString($interval[0]), TimeBuilder::fromString($interval[1]) ); }
php
{ "resource": "" }
q267631
DayBuilder.fromAssociativeArray
test
public static function fromAssociativeArray(array $data): DayInterface { if (!isset($data['openingIntervals'], $data['dayOfWeek']) || !\is_array($data['openingIntervals'])) { throw new \InvalidArgumentException('Array is not valid.'); } $openingIntervals = []; foreach ($data['openingIntervals'] as $openingInterval) { if (!isset($openingInterval['start'], $openingInterval['end']))
php
{ "resource": "" }
q267632
DayBuilder.isIntervalAllDay
test
private static function isIntervalAllDay(Time $start, Time $end): bool { if ($start->getHours() !== 0 || $start->getMinutes() !== 0 || $start->getSeconds() !== 0) { return false; } if
php
{ "resource": "" }
q267633
Request.fromArray
test
public static function fromArray(Array $data) { $request = new static(); if (!isset($data['body']) || !isset($data['request'])) { throw new UnexpectedValueException( 'Unexpected data, invalid data' ); } $body = $data['body']; $params = $data['request']; $request->setTimestamp(microtime(true)); if (isset($params['RequestURI'])) { $request->setRequestUrl($params['RequestURI']); } if (isset($params['Method'])) { $request->setRequestMethod($params['Method']); } if (isset($params['Header']) && is_array($params['Header'])) { $headers = $params['Header']; if (isset($params['Host'])) { $headers['Host'] = [$params['Host']]; } $request->setHeaders($headers); //Malformed cookies will return a fatal error $cookies = $cookies = new Cookie($request->getHeader('Cookie')); if ($cookies) { $request->setCookies($cookies); }
php
{ "resource": "" }
q267634
Request.setServerInfo
test
public function setServerInfo(array $info) { $this->server = $info; if (isset($info['name']) && $info['name']) $name = (string) $info['name']; else $name = sprintf('%s:%s', $info['host'], $info['port']); $this->setServerGlobal('SERVER_NAME', $name); $this->setServerGlobal('SERVER_ADDR', (string) $info['host']);
php
{ "resource": "" }
q267635
Request.setHeaders
test
public function setHeaders(array $headers) { parent::addHeaders($headers); $this->setServerGlobal('HTTP_HOST', (string) $this->getHeader('Host')[0]); $this->setServerGlobal('HTTP_ACCEPT', (string) $this->getHeader('Accept')[0]); $this->setServerGlobal('HTTP_CONNECTION', (string) $this->getHeader('Connection')[0]); $this->setServerGlobal('HTTP_USER_AGENT', (string) $this->getHeader('User-Agent')[0]);
php
{ "resource": "" }
q267636
Request.setPostFields
test
public function setPostFields(array $fields) { $this->post = $fields; $body = new Message\Body();
php
{ "resource": "" }
q267637
Request.setQueryFields
test
public function setQueryFields(array $fields) { $this->get = $fields; $this->setServerGlobal('QUERY_STRING', $this->getQueryData());
php
{ "resource": "" }
q267638
Request.getHeader
test
public function getHeader($header, $into_class = null) { $header = parent::getHeader($header); if (!is_array($header)) {
php
{ "resource": "" }
q267639
Request.toArray
test
public function toArray() { return array( 'url' => $this->getRequestUrl(), 'method' => $this->getRequestMethod(),
php
{ "resource": "" }
q267640
NativeConsole.addCommand
test
public function addCommand(Command $command): void { $command->setMethod($command->getMethod() ?? static::RUN_METHOD); $dispatcher = $this->app->dispatcher(); $dispatcher->verifyClassMethod($command); $dispatcher->verifyFunction($command); $dispatcher->verifyClosure($command);
php
{ "resource": "" }
q267641
NativeConsole.addParsedCommand
test
protected function addParsedCommand(Command $command, array $parsedCommand): void { // Set the properties $command->setRegex($parsedCommand['regex']); $command->setParams($parsedCommand['params']); $command->setSegments($parsedCommand['segments']); // Set the command in the commands list self::$commands[$command->getPath()] = $command; // Set the command in the commands paths list
php
{ "resource": "" }
q267642
NativeConsole.command
test
public function command(string $name): ? Command { return $this->hasCommand($name)
php
{ "resource": "" }
q267643
NativeConsole.removeCommand
test
public function removeCommand(string $name): void { if ($this->hasCommand($name)) { unset(
php
{ "resource": "" }
q267644
NativeConsole.matchCommand
test
public function matchCommand(string $path): Command { // If the path matches a set command path if (isset(self::$commands[$path])) { return self::$commands[$path]; } $command = null; // Otherwise iterate through the commands and attempt to match via regex foreach (self::$paths as $regex => $commandPath) { // If the preg match is successful, we've found our command! if (preg_match($regex, $path, $matches)) { // Check if this command is provided if ($this->isProvided($commandPath)) { // Initialize the provided command $this->initializeProvided($commandPath); } // Clone the command to avoid changing the one set in the master // array
php
{ "resource": "" }
q267645
NativeConsole.all
test
public function all(): array { // Iterate through all the command providers to set any deferred // commands foreach (self::$provided as $provided => $provider) {
php
{ "resource": "" }
q267646
NativeConsole.setup
test
public function setup(bool $force = false, bool $useCache = true): void { // If the console was already setup no need to do it again if (self::$setup && ! $force) { return; } // The console is setting up self::$setup = true; // If the application should use the console cache files if ($useCache && $this->app->config()['console']['useCache']) { $this->setupFromCache(); // Then return out of setup return; } self::$paths
php
{ "resource": "" }
q267647
NativeConsole.setupFromCache
test
protected function setupFromCache(): void { // Set the application console with said file $cache = $this->app->config()['cache']['console'] ?? require $this->app->config()['console']['cacheFilePath']; self::$commands = unserialize( base64_decode($cache['commands'], true), [ 'allowed_classes' => [
php
{ "resource": "" }
q267648
NativeConsole.getCacheable
test
public function getCacheable(): array { $this->setup(true, false); return [ 'commands' => base64_encode(serialize(self::$commands)),
php
{ "resource": "" }
q267649
Zend_Filter_Word_Separator_Abstract.setSeparator
test
public function setSeparator($separator) { if ($separator == null) { throw new Zend_Filter_Exception('"' . $separator . '" is not a valid
php
{ "resource": "" }
q267650
NativeEvents.listen
test
public function listen(string $event, Listener $listener): void { $this->add($event); $this->app->dispatcher()->verifyDispatch($listener); // If this listener has an id if (null !== $listener->getId()) { // Use it when setting to allow removal //
php
{ "resource": "" }
q267651
NativeEvents.listenMany
test
public function listenMany(Listener $listener, string ...$events): void { // Iterate through the events foreach ($events as $event) {
php
{ "resource": "" }
q267652
NativeEvents.hasListener
test
public function hasListener(string $event, string $listenerId): bool
php
{ "resource": "" }
q267653
NativeEvents.removeListener
test
public function removeListener(string $event, string $listenerId): void { // If the listener exists if ($this->hasListener($event, $listenerId)) {
php
{ "resource": "" }
q267654
NativeEvents.hasListeners
test
public function hasListeners(string $event): bool {
php
{ "resource": "" }
q267655
NativeEvents.add
test
public function add(string $event): void { if (!
php
{ "resource": "" }
q267656
NativeEvents.remove
test
public function remove(string $event): void {
php
{ "resource": "" }
q267657
NativeEvents.trigger
test
public function trigger(string $event, array $arguments = null): array { // The responses $responses = []; if (! $this->has($event) || ! $this->hasListeners($event)) { return $responses; } // Iterate through all the event's listeners
php
{ "resource": "" }
q267658
NativeEvents.setup
test
public function setup(bool $force = false, bool $useCache = true): void { if (self::$setup && ! $force) { return; } self::$setup = true; // If the application should use the events cache files if ($useCache && $this->app->config()['events']['useCache']) { $this->setupFromCache(); // Then return out of setup return; } self::$events = []; // If annotations are enabled and the events should use annotations if ( $this->app->config()['events']['useAnnotations'] && $this->app->config()['annotations']['enabled'] ) {
php
{ "resource": "" }
q267659
NativeEvents.setupFromCache
test
protected function setupFromCache(): void { // Set the application events with said file $cache = $this->app->config()['cache']['events'] ?? require $this->app->config()['events']['cacheFilePath']; self::$events = unserialize(
php
{ "resource": "" }
q267660
TemplatingTrait.init
test
public function init($options) { $this->template = ''; $this->template_data = ''; $this->template_dir_orig = ''; if ($options['templatepath'] != '') { $this->template_dir_orig = $options['templatepath']; } // compile dir is required and must be writable $this->compile_dir_orig = $options['compiledir']; $this->caching = $options['usecache']; if ($this->caching) { $this->cache_dir = $options['cachedir']; }
php
{ "resource": "" }
q267661
TemplatingTrait.checkTemplateExists
test
public function checkTemplateExists($filepath,$options = array(),$tmplpath = '') { if (is_array($this->template_dir_orig) && $tmplpath == '') { foreach ($this->template_dir_orig as $path) { $exists = $this->checkTemplateExists($filepath,$options,$path); if ($exists) { return true; } } return
php
{ "resource": "" }
q267662
TemplatingTrait.fetchTemplate
test
public function fetchTemplate() { if ($this->template != '' && $this->template_data == '' && !$this->checkTemplateExists($this->template)) { throw new \Exception(sprintf('Template file %s not found',$this->template));
php
{ "resource": "" }
q267663
Config.load
test
public function load(array $options = []) { $options = array_replace_recursive( $this->getOption('loadOptions', []), $options ); // Simple shortcuts $options['readerOptions']['file'] = $options['readerOptions']['file'] ?? $options['file']; $options['readerOptions']['data'] = $options['readerOptions']['data'] ?? $options['data']; $reader = $this->getReader(); $data = $reader->read($options['readerOptions']); if ($options['processImports'] && isset($data['import'])) { if (!is_array($data['import'])) { throw ImportException::create('"import" parameter must be an array.'); } foreach ($data['import'] as $importData) { if (!is_array($importData)) { throw ImportException::create('Each "import" array element must be an array.'); } if (isset($importData['file'])) { if ($options['file']) { $importData['file'] = $importData['file']{0} === '/' ? $importData['file'] : dirname($options['file']).'/'.$importData['file']; } if (!is_file($importData['file'])) { continue; } } $readOptions = array_replace_recursive($options['readerOptions'], $importData); $data = array_replace_recursive($data, $reader->read($readOptions)); } } if ($options['clearFirst']) { $this->setData([],
php
{ "resource": "" }
q267664
Config.save
test
public function save(array $options = []) { $options = array_merge( [ 'file' => null, 'writerOptions' => [] ], $options ); // Simple shortcut $options['writerOptions']['file'] = $options['file']; /** @var Callable $callable */ $callable = $this->getOption('onBeforeSave');
php
{ "resource": "" }
q267665
Config.initializeReader
test
protected function initializeReader() { $reader = $this->getOption('reader'); if (is_string($reader)) { switch ($reader) { case 'array': $reader = new ArrayReader(); break; case 'file': $reader = new FileReader(); break; default: throw new \InvalidArgumentException( 'Invalid reader "'.$reader.'". Valid reader strings:
php
{ "resource": "" }
q267666
Config.initializeWriter
test
protected function initializeWriter() { $writer = $this->getOption('writer'); if (is_string($writer)) { switch ($writer) { case 'array': $writer = new ArrayWriter(); break; case 'file': $writer = new FileWriter(); break; default: throw new \InvalidArgumentException( 'Invalid writer "'.$writer.'". Valid writer strings:
php
{ "resource": "" }
q267667
Config.getDefaultOptions
test
public function getDefaultOptions(): array { return [ 'reader' => 'file', 'writer' => 'file', 'onAfterLoad' => function(Config $config, array $options) {}, 'onBeforeSave' => function(Config $config, array $options) {},
php
{ "resource": "" }
q267668
CryptDatabase.encrypt
test
protected function encrypt($data, $key) { $keySize = openssl_cipher_iv_length(static::CRYPT_MODE); $padding = $keySize - (mb_strlen($data, '8bit') % $keySize); /** @noinspection CryptographicallySecureRandomnessInspection */ $iv = openssl_random_pseudo_bytes($keySize); $key = $this->generateKey($key); $data .= str_repeat(chr($padding), $padding); // add in
php
{ "resource": "" }
q267669
CryptDatabase.decrypt
test
protected function decrypt($data, $key) { $base64 = base64_decode($data, true); $keySize = openssl_cipher_iv_length(static::CRYPT_MODE); $key = $this->generateKey($key); $iv = substr($base64, 0, $keySize); $results = substr($base64, $keySize);
php
{ "resource": "" }
q267670
CryptDatabase.generateKey
test
protected function generateKey($key) { $keySize = openssl_cipher_iv_length(static::CRYPT_MODE); $key = hash(
php
{ "resource": "" }
q267671
ExceptionHandler.throwToStdout
test
public function throwToStdout($exception, $full = true, $asJson = false) { $httpCode = method_exists($exception, 'getHttpCode') ? call_user_func([$exception, 'getHttpCode']) : 500; $logger = $this->getStdioLogger(); $message = $this->getExceptionData($exception, $full, true); if ($logger) { $logger->error($message, [], 1); } else { echo $message; } if ($asJson) {
php
{ "resource": "" }
q267672
ExceptionHandler.renderException
test
private function renderException($exception, $full = false) { $app = \Reaction::$app; try { $rendered = View::renderPhpStateless($this->getViewFileForException($exception), [ 'exceptionName' => $this->getExceptionName($exception), 'exception' => $exception,
php
{ "resource": "" }
q267673
ExceptionHandler.getViewFileForException
test
private function getViewFileForException($exception) { $basePath = \Reaction::$app->getAlias('@views/error'); $tplName = 'general.php'; if ($exception instanceof HttpExceptionInterface) { $code = $exception->statusCode; } else {
php
{ "resource": "" }
q267674
ExceptionHandler.getResponse
test
private function getResponse($code = 500, $headers = [], $body = null) { if (isset($body) && is_array($body)) { if (!isset($body['error'])) { $body = ['error' => $body]; }
php
{ "resource": "" }
q267675
ExceptionHandler.getExceptionData
test
private function getExceptionData($exception, $full = false, $plainText = false) { if ($plainText) { $text = $exception->getMessage() . "\n"; if ($full) { $text .= $exception->getFile() . " #" . $exception->getLine() . "\n"; $text .= $exception->getTraceAsString() . "\n"; } return $text;
php
{ "resource": "" }
q267676
ExceptionHandler.getStdioLogger
test
private function getStdioLogger() { try { /** @var StdioLogger $logger */
php
{ "resource": "" }
q267677
CachedSessionHandler.read
test
public function read($id) { $key = $this->getSessionKey($id); return $this->getDataFromCache($key)->then( function($record) { return $this->extractData($record, true); } )->then( null, function($error = null) use ($id) { //return $self->restoreSessionData($id, true)->then( return $this->archive->get($id)->then( function($data) use ($id, $error) { if (is_array($data)) { return $this->write($id, $data); } else { return \Reaction\Promise\reject($error);
php
{ "resource": "" }
q267678
CachedSessionHandler.write
test
public function write($id, $data) { $key = $this->getSessionKey($id); $record = $this->packRecord($data); return $this->writeDataToCache($key, $record)->then( function() use ($id) { $this->keys[$id] = time(); return $this->read($id); }, function($error = null) use ($id) {
php
{ "resource": "" }
q267679
CachedSessionHandler.destroy
test
public function destroy($id, $archiveRemove = false) { if (isset($this->keys[$id])) { unset($this->keys[$id]); } $key = $this->getSessionKey($id); return $this->cache->delete($key)->then( function() use ($id) { return
php
{ "resource": "" }
q267680
CachedSessionHandler.updateTimestamp
test
public function updateTimestamp($id, $data = null) { $self = $this; return $this->read($id)->then( function($dataStored) use ($self, $id, $data) { if (isset($data)) { $dataStored = $data; }
php
{ "resource": "" }
q267681
CachedSessionHandler.extractData
test
public function extractData($sessionRecord = [], $unserialize = false) { $data = isset($sessionRecord[$this->dataKey]) ? $sessionRecord[$this->dataKey] : [];
php
{ "resource": "" }
q267682
CachedSessionHandler.extractTimestamp
test
protected function extractTimestamp($record = []) {
php
{ "resource": "" }
q267683
CachedSessionHandler.getDataFromCache
test
protected function getDataFromCache($key) { $self = $this; return (new Promise(function($r, $c) use ($self, $key) { $self->cache ->get($key) ->then(function($data) { return $data !== null ? $data : reject(null); })->then(function($data) use ($r) { $r($data); }, function() use ($c, $key) {
php
{ "resource": "" }
q267684
Exception.getMessageWithVariables
test
final public function getMessageWithVariables(): string { if (empty($this->message)) { throw new \Exception(sprintf( 'Exception %s does not have a message', get_class($this) ), Level::CRITICAL); } $message = $this->message; preg_match_all(self::VARIABLE_REGEX, $message, $matches); foreach ($matches['variable'] as $variable) { $variableName = substr($variable, 1, -1); if (!isset($this->$variableName)) { throw new \Exception(sprintf( 'Variable "%s" for exception "%s" not found', $variableName, get_class($this) ), Level::CRITICAL); } if (!is_string($this->$variableName)) {
php
{ "resource": "" }
q267685
CreateMySqlDao.constraint
test
private final function constraint(TableInterface $table): string { $mySql = $selfKey = $foreignKey = ""; $name = $table->get($table::ATTR_NAME); foreach ($table->get($table::ATTR_KEY) as $key => $value) { if (KeyInterface::FOREIGN !== $value->getType()) { $selfKey .= $this->addKey($value, $name . "_" . $key); if (KeyInterface::PRIMARY === $value->getType()) { foreach ($value->getSubject() as $key) { $selfKey .= $this->addAutoIncrement( $key, $table->get($table::ATTR_COLUMN)); }
php
{ "resource": "" }
q267686
CreateMySqlDao.addAutoIncrement
test
private final function addAutoIncrement(string $key, array $column): string { $autoIncrement = ""; if (array_key_exists($key, $column) && in_array( ColumnInterface::OPT_AUTO_INCREMENT, $column[$key]->getOption())) { $autoIncrement .= "MODIFY "
php
{ "resource": "" }
q267687
CreateMySqlDao.addKey
test
private final function addKey(KeyInterface $key, string $name): string { return "ADD " . $this->constant($key->getType()) . " `k_"
php
{ "resource": "" }
q267688
CreateMySqlDao.addForeign
test
private final function addForeign(KeyInterface $key, string $name): string { return "ADD CONSTRAINT" . " `fk_" . $name . "`" . " " . $this->constant($key->getType()) . " (`" . implode("`, `", ($key->getSubject())) . "`) "
php
{ "resource": "" }
q267689
CreateMySqlDao.getColumnSyntaxe
test
private final function getColumnSyntaxe(ColumnInterface $column) { $mySql = "`" . $column->getName() . "` " . $this->constant($column->getType()) . "(" . $column->getSize() . ")"; foreach ($column->getOption() as $option) {
php
{ "resource": "" }
q267690
Plugin.jumpstart
test
public function jumpstart() { $this->getLoader()->action('activate_' . $this->getBasename(), array($this, 'activate')); $this->getLoader()->action('deactivate_' . $this->getBasename(), array($this, 'deactivate'));
php
{ "resource": "" }
q267691
CreateIterationExceptionCapableTrait._createIterationException
test
protected function _createIterationException( $message = null, $code = null, RootException $previous = null, IterationInterface $iteration = null
php
{ "resource": "" }
q267692
NavBar.renderToggleButton
test
protected function renderToggleButton() { $icon = $this->htmlHlp->tag('span', '', ['class' => 'navbar-toggler-icon']); $screenReader = isset($this->screenReaderToggleText) ? "<span class=\"sr-only\">{$this->screenReaderToggleText}</span>"
php
{ "resource": "" }
q267693
Money.getResponse
test
protected function getResponse($templateName, $isNaked = false) { $this->response = new ResponseTemplate(); $content = $this->getTemplate($templateName);
php
{ "resource": "" }
q267694
Money.getModuleName
test
protected function getModuleName() { if (empty($this->appModuleName)) { $className = trim(get_class($this)); $namespace = substr(__NAMESPACE__, 0, strrpos(__NAMESPACE__, '\\'));
php
{ "resource": "" }
q267695
Reflection.loadClassReflection
test
public static function loadClassReflection($class) { if (is_object($class)) { $class = get_class($class); } if (isset(self::$classReflections[$class])) {
php
{ "resource": "" }
q267696
Reflection.loadObjectReflection
test
public static function loadObjectReflection($object) { if (!is_object($object)) { throw new \InvalidArgumentException(sprintf( 'Could not load reflection for non object. Given: "%s".',
php
{ "resource": "" }
q267697
Reflection.loadPropertyReflection
test
public static function loadPropertyReflection($object, $property, $searchInParents = true) { $reflection = self::loadClassReflection($object); if (!$searchInParents) { return $reflection->getProperty($property); } $exception = null; do { try { $reflectionProperty = $reflection->getProperty($property); return $reflectionProperty;
php
{ "resource": "" }
q267698
Reflection.getCalledMethod
test
public static function getCalledMethod(\ReflectionFunctionAbstract $method, $closureInfo = true) { if ($method->isClosure()) { if ($closureInfo) { return sprintf( 'Closure [%s:%d]', $method->getFileName(), $method->getStartLine() ); } return 'Closure';
php
{ "resource": "" }
q267699
Reflection.getClassProperties
test
public static function getClassProperties($class, $inParents = false, $filter = null) { if ($filter === null) { $filter = \ReflectionProperty::IS_PRIVATE | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PUBLIC; } $reflection = self::loadClassReflection($class); if (!$inParents) { return $reflection->getProperties($filter); } $properties = []; do {
php
{ "resource": "" }