_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q256300
ReflectionFunctionAbstract.isVariadic
test
public function isVariadic() : bool { $parameters = $this->getParameters(); foreach ($parameters as $parameter) { if ($parameter->isVariadic()) { return true; } } return false; }
php
{ "resource": "" }
q256301
ReflectionFunctionAbstract.setReturnType
test
public function setReturnType(string $newReturnType) : void { $this->node->returnType = new Node\Name($newReturnType); }
php
{ "resource": "" }
q256302
ReflectionFunctionAbstract.getBodyCode
test
public function getBodyCode(?PrettyPrinterAbstract $printer = null) : string { if ($printer === null) { $printer = new StandardPrettyPrinter(); } return $printer->prettyPrint($this->getBodyAst()); }
php
{ "resource": "" }
q256303
ReflectionFunctionAbstract.getReturnStatementsAst
test
public function getReturnStatementsAst() : array { $visitor = new ReturnNodeVisitor(); $traverser = new NodeTraverser(); $traverser->addVisitor($visitor); $traverser->traverse($this->node->getStmts()); return $visitor->getReturnNodes(); }
php
{ "resource": "" }
q256304
PsrAutoloaderLocator.locateIdentifiersByType
test
public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType) : array { return (new DirectoriesSourceLocator( $this->mapping->directories(), $this->astLocator ))->locateIdentifiersByType($reflector, $identifierType); }
php
{ "resource": "" }
q256305
ReflectionClassConstant.createFromNode
test
public static function createFromNode( Reflector $reflector, ClassConst $node, int $positionInNode, ReflectionClass $owner ) : self { $ref = new self(); $ref->node = $node; $ref->positionInNode = $positionInNode; $ref->owner ...
php
{ "resource": "" }
q256306
ReflectionClassConstant.getValue
test
public function getValue() { if ($this->valueWasCached !== false) { return $this->value; } $this->value = (new CompileNodeToValue())->__invoke( $this->node->consts[$this->positionInNode]->value, new CompilerContext($this->reflector, $this->getDec...
php
{ "resource": "" }
q256307
ReflectionClassConstant.getModifiers
test
public function getModifiers() : int { $val = 0; $val += $this->isPublic() ? ReflectionProperty::IS_PUBLIC : 0; $val += $this->isProtected() ? ReflectionProperty::IS_PROTECTED : 0; $val += $this->isPrivate() ? ReflectionProperty::IS_PRIVATE : 0; return $val; }
php
{ "resource": "" }
q256308
PhpDocAnnotationGenerator.generateDoc
test
private function generateDoc(string $className, bool $interface = false): array { $resource = $this->classes[$className]['resource']; $annotations = []; if (!$interface && isset($this->classes[$className]['interfaceName'])) { $annotations[] = '{@inheritdoc}'; $annota...
php
{ "resource": "" }
q256309
PhpDocAnnotationGenerator.formatDoc
test
private function formatDoc(string $doc, bool $indent = false): array { $doc = explode("\n", $this->htmlToMarkdown->convert($doc)); if ($indent) { $count = count($doc); for ($i = 1; $i < $count; ++$i) { $doc[$i] = self::INDENT.$doc[$i]; } }...
php
{ "resource": "" }
q256310
CardinalitiesExtractor.extract
test
public function extract(): array { $properties = []; foreach ($this->graphs as $graph) { foreach ($graph->allOfType('rdf:Property') as $property) { $properties[$property->localName()] = $this->extractForProperty($property); } } return $proper...
php
{ "resource": "" }
q256311
CardinalitiesExtractor.extractForProperty
test
private function extractForProperty(\EasyRdf_Resource $property): string { $localName = $property->localName(); $fromGoodRelations = $this->goodRelationsBridge->extractCardinality($localName); if (false !== $fromGoodRelations) { return $fromGoodRelations; } $comm...
php
{ "resource": "" }
q256312
TypesGenerator.isEnum
test
private function isEnum(\EasyRdf_Resource $type): bool { $subClassOf = $type->get('rdfs:subClassOf'); return $subClassOf && self::SCHEMA_ORG_ENUMERATION === $subClassOf->getUri(); }
php
{ "resource": "" }
q256313
TypesGenerator.createPropertiesMap
test
private function createPropertiesMap(array $types) { $typesAsString = []; $map = []; foreach ($types as $type) { // get all parent classes until the root $parentClasses = $this->getParentClasses($type); $typesAsString[] = $parentClasses; $map[$...
php
{ "resource": "" }
q256314
TypesGenerator.namespaceToDir
test
private function namespaceToDir(array $config, string $namespace): string { if (null !== ($prefix = $config['namespaces']['prefix'] ?? null) && 0 === strpos($namespace, $prefix)) { $namespace = substr($namespace, strlen($prefix)); } return sprintf('%s/%s/', $config['output'], st...
php
{ "resource": "" }
q256315
TypesGenerator.fixCs
test
private function fixCs(array $files): void { $fileInfos = []; foreach ($files as $file) { $fileInfos[] = new \SplFileInfo($file); } $fixers = (new FixerFactory()) ->registerBuiltInFixers() ->useRuleSet(new RuleSet([ '@Symfony' => t...
php
{ "resource": "" }
q256316
GoodRelationsBridge.exist
test
public function exist(string $id): bool { foreach ($this->relations as $relation) { $result = $relation->xpath(sprintf('//*[@rdf:about="%s"]', $this->getPropertyUrl($id))); if (!empty($result)) { return true; } } return false; }
php
{ "resource": "" }
q256317
GoodRelationsBridge.extractCardinality
test
public function extractCardinality(string $id) { foreach ($this->relations as $relation) { $result = $relation->xpath(sprintf('//*[@rdf:about="%s"]/rdfs:label', $this->getPropertyUrl($id))); if (count($result)) { preg_match('/\(.\.\..\)/', $result[0]->asXML(), $matche...
php
{ "resource": "" }
q256318
GoodRelationsBridge.getPropertyUrl
test
private function getPropertyUrl(string $id): string { $propertyId = $this->datatypePropertiesTable[$id] ?? $this->objectPropertiesTable[$id] ?? $id; return self::GOOD_RELATIONS_NAMESPACE.$propertyId; }
php
{ "resource": "" }
q256319
AbstractAnnotationGenerator.toPhpType
test
protected function toPhpType(array $field, bool $adderOrRemover = false): string { $range = $field['range']; if ($field['isEnum']) { if ($field['isArray']) { return 'string[]'; } return 'string'; } $data = false; switch (...
php
{ "resource": "" }
q256320
DoctrineOrmAnnotationGenerator.getRelationName
test
private function getRelationName(string $range): string { $class = $this->classes[$range]; if (isset($class['interfaceName'])) { return $class['interfaceName']; } if (isset($this->config['types'][$class['name']]['namespaces']['class'])) { return sprintf('%s\...
php
{ "resource": "" }
q256321
Sitemap.finishFile
test
private function finishFile() { if ($this->writer !== null) { $this->writer->endElement(); $this->writer->endDocument(); /* To prevent infinite recursion through flush */ $this->urlsCount = 0; $this->flush(0); $this->writerBackend->fi...
php
{ "resource": "" }
q256322
Sitemap.flush
test
private function flush($footSize = 10) { $data = $this->writer->flush(true); $dataSize = mb_strlen($data, '8bit'); /* * Limit the file size of each single site map * * We use a heuristic of 10 Bytes for the remainder of the file, * i.e. </urlset> plus a n...
php
{ "resource": "" }
q256323
Sitemap.addItem
test
public function addItem($location, $lastModified = null, $changeFrequency = null, $priority = null) { if ($this->urlsCount >= $this->maxUrls) { $this->finishFile(); } if ($this->writerBackend === null) { $this->createNewFile(); } if (is_array($locati...
php
{ "resource": "" }
q256324
Sitemap.addSingleLanguageItem
test
private function addSingleLanguageItem($location, $lastModified, $changeFrequency, $priority) { $this->validateLocation($location); $this->writer->startElement('url'); $this->writer->writeElement('loc', $location); if ($lastModified !== null) { $this->writer->writeEle...
php
{ "resource": "" }
q256325
Sitemap.addMultiLanguageItem
test
private function addMultiLanguageItem($locations, $lastModified, $changeFrequency, $priority) { foreach ($locations as $language => $url) { $this->validateLocation($url); $this->writer->startElement('url'); $this->writer->writeElement('loc', $url); if ($las...
php
{ "resource": "" }
q256326
Sitemap.getSitemapUrls
test
public function getSitemapUrls($baseUrl) { $urls = array(); foreach ($this->writtenFilePaths as $file) { $urls[] = $baseUrl . pathinfo($file, PATHINFO_BASENAME); } return $urls; }
php
{ "resource": "" }
q256327
Sitemap.setUseGzip
test
public function setUseGzip($value) { if ($value && !extension_loaded('zlib')) { throw new \RuntimeException('Zlib extension must be enabled to gzip the sitemap.'); } if ($this->writerBackend !== null && $value != $this->useGzip) { throw new \RuntimeException('Cannot c...
php
{ "resource": "" }
q256328
Index.addSitemap
test
public function addSitemap($location, $lastModified = null) { if (false === filter_var($location, FILTER_VALIDATE_URL)) { throw new \InvalidArgumentException( "The location must be a valid URL. You have specified: {$location}." ); } if ($this->writer ...
php
{ "resource": "" }
q256329
DeflateWriter.write
test
private function write($data, $flushMode) { assert($this->file !== null); $compressedChunk = deflate_add($this->deflateContext, $data, $flushMode); fwrite($this->file, $compressedChunk); }
php
{ "resource": "" }
q256330
DeflateWriter.finish
test
public function finish() { $this->write('', ZLIB_FINISH); $this->file = null; $this->deflateContext = null; }
php
{ "resource": "" }
q256331
TempFileGZIPWriter.finish
test
public function finish() { assert($this->tempFile !== null); $file = fopen('compress.zlib://' . $this->filename, 'wb'); rewind($this->tempFile); stream_copy_to_stream($this->tempFile, $file); fclose($file); fclose($this->tempFile); $this->tempFile = null; ...
php
{ "resource": "" }
q256332
Crypt_GPG_KeyGenerator.setExpirationDate
test
public function setExpirationDate($date) { if (is_int($date) || ctype_digit(strval($date))) { $expirationDate = intval($date); } else { $expirationDate = strtotime($date); } if ($expirationDate === false) { throw new InvalidArgumentException( ...
php
{ "resource": "" }
q256333
Crypt_GPG_KeyGenerator.setKeyParams
test
public function setKeyParams($algorithm, $size = 0, $usage = 0) { $algorithm = intval($algorithm); if ($algorithm === Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC) { throw new Crypt_GPG_InvalidKeyParamsException( 'Primary key algorithm must be capable of signing. The ' . ...
php
{ "resource": "" }
q256334
Crypt_GPG_KeyGenerator.setSubKeyParams
test
public function setSubKeyParams($algorithm, $size = '', $usage = 0) { $algorithm = intval($algorithm); if ($size != 0) { $size = intval($size); } if ($usage != 0) { $usage = intval($usage); } $usageSign = Crypt_GPG_SubKey::USAGE_SIGN; ...
php
{ "resource": "" }
q256335
Crypt_GPG_KeyGenerator.getUsage
test
protected function getUsage($usage) { $map = array( Crypt_GPG_SubKey::USAGE_ENCRYPT => 'encrypt', Crypt_GPG_SubKey::USAGE_SIGN => 'sign', Crypt_GPG_SubKey::USAGE_CERTIFY => 'cert', Crypt_GPG_SubKey::USAGE_AUTHENTICATION => 'auth', ...
php
{ "resource": "" }
q256336
Crypt_GPG_KeyGenerator.getUserId
test
protected function getUserId($name, $email = '', $comment = '') { if ($name instanceof Crypt_GPG_UserId) { $userId = $name; } else { $userId = new Crypt_GPG_UserId(); $userId->setName($name)->setEmail($email)->setComment($comment); } return $userI...
php
{ "resource": "" }
q256337
Crypt_GPG_UserId.parse
test
public static function parse($string) { $userId = new Crypt_GPG_UserId(); $name = ''; $email = ''; $comment = ''; // get email address from end of string if it exists $matches = array(); if (preg_match('/^(.*?)<([^>]+)>$/', $string, $matches) === 1) { ...
php
{ "resource": "" }
q256338
Crypt_GPG_ProcessControl.isRunning
test
public function isRunning() { $running = false; if (function_exists('posix_getpgid')) { $running = false !== posix_getpgid($this->pid); } elseif (PHP_OS === 'WINNT') { $command = 'tasklist /fo csv /nh /fi ' . escapeshellarg('PID eq ' . $this->pid); ...
php
{ "resource": "" }
q256339
Crypt_GPG_ProcessControl.terminate
test
public function terminate() { if (function_exists('posix_kill')) { posix_kill($this->pid, 15); } elseif (PHP_OS === 'WINNT') { exec('taskkill /PID ' . escapeshellarg($this->pid)); } else { exec('kill -15 ' . escapeshellarg($this->pid)); } }
php
{ "resource": "" }
q256340
Crypt_GPG_ProcessHandler.setOperation
test
public function setOperation($operation) { $op = null; $opArg = null; // Regexp matching all GPG "operational" arguments $regexp = '/--(' . 'version|import|list-public-keys|list-secret-keys' . '|list-keys|delete-key|delete-secret-key|encrypt|sign|clearsign...
php
{ "resource": "" }
q256341
Crypt_GPG_ProcessHandler.handleError
test
public function handleError($line) { if (stripos($line, 'gpg: WARNING: ') !== false) { $this->data['Warnings'][] = substr($line, 14); } if ($this->errorCode !== Crypt_GPG::ERROR_NONE) { return; } $pattern = '/no valid OpenPGP data found/'; if...
php
{ "resource": "" }
q256342
Crypt_GPG_ProcessHandler.setErrorCode
test
protected function setErrorCode($exitcode) { if ($this->needPassphrase > 0) { return Crypt_GPG::ERROR_MISSING_PASSPHRASE; } if ($this->operation == 'import') { return Crypt_GPG::ERROR_NONE; } if ($this->operation == 'decrypt' && !empty($this->data['D...
php
{ "resource": "" }
q256343
Crypt_GPG_ProcessHandler.setData
test
public function setData($name, $value) { switch ($name) { case 'Handle': $this->data[$name] = strval($value); break; case 'IgnoreVerifyErrors': $this->data[$name] = (bool) $value; break; } }
php
{ "resource": "" }
q256344
Crypt_GPG_ProcessHandler.badPassException
test
protected function badPassException($code, $message) { $badPassphrases = array_diff_key( isset($this->data['BadPassphrases']) ? $this->data['BadPassphrases'] : array(), isset($this->data['MissingPassphrases']) ? $this->data['MissingPassphrases'] : array() ); $missing...
php
{ "resource": "" }
q256345
Crypt_GPG_ProcessHandler.getPin
test
protected function getPin($key) { $passphrase = ''; $keyIdLength = mb_strlen($key, '8bit'); if ($keyIdLength && !empty($_ENV['PINENTRY_USER_DATA'])) { $passphrases = json_decode($_ENV['PINENTRY_USER_DATA'], true); foreach ($passphrases as $_keyId => $pass) { ...
php
{ "resource": "" }
q256346
Crypt_GPG_SignatureCreationInfo.getHashAlgorithmName
test
public function getHashAlgorithmName() { if (!isset(self::$hashAlgorithmNames[$this->hashAlgorithm])) { return null; } return self::$hashAlgorithmNames[$this->hashAlgorithm]; }
php
{ "resource": "" }
q256347
Crypt_GPG_SubKey.setCanSign
test
public function setCanSign($canSign) { if ($canSign) { $this->_usage |= self::USAGE_SIGN; } else { $this->_usage &= ~self::USAGE_SIGN; } return $this; }
php
{ "resource": "" }
q256348
Crypt_GPG_SubKey.setCanEncrypt
test
public function setCanEncrypt($canEncrypt) { if ($canEncrypt) { $this->_usage |= self::USAGE_ENCRYPT; } else { $this->_usage &= ~self::USAGE_ENCRYPT; } return $this; }
php
{ "resource": "" }
q256349
Crypt_GPG_SubKey.parse
test
public static function parse($string) { $tokens = explode(':', $string); $subKey = new Crypt_GPG_SubKey(); $subKey->setId($tokens[4]); $subKey->setLength($tokens[2]); $subKey->setAlgorithm($tokens[3]); $subKey->setCreationDate(self::_parseDate($tokens[5])); ...
php
{ "resource": "" }
q256350
Crypt_GPG_SubKey._parseDate
test
private static function _parseDate($string) { if ($string == '') { $timestamp = 0; } else { // all times are in UTC according to GPG documentation $timeZone = new DateTimeZone('UTC'); if (strpos($string, 'T') === false) { // interpret ...
php
{ "resource": "" }
q256351
Crypt_GPG.deletePublicKey
test
public function deletePublicKey($keyId) { $fingerprint = $this->getFingerprint($keyId); if ($fingerprint === null) { throw new Crypt_GPG_KeyNotFoundException( 'Public key not found: ' . $keyId, self::ERROR_KEY_NOT_FOUND, $keyId ...
php
{ "resource": "" }
q256352
Crypt_GPG.getFingerprint
test
public function getFingerprint($keyId, $format = self::FORMAT_NONE) { $output = ''; $operation = '--list-keys ' . escapeshellarg($keyId); $arguments = array( '--with-colons', '--with-fingerprint' ); $this->engine->reset(); $this->engine->se...
php
{ "resource": "" }
q256353
Crypt_GPG.encrypt
test
public function encrypt($data, $armor = self::ARMOR_ASCII) { return $this->_encrypt($data, false, null, $armor); }
php
{ "resource": "" }
q256354
Crypt_GPG.encryptFile
test
public function encryptFile( $filename, $encryptedFile = null, $armor = self::ARMOR_ASCII ) { return $this->_encrypt($filename, true, $encryptedFile, $armor); }
php
{ "resource": "" }
q256355
Crypt_GPG.encryptAndSign
test
public function encryptAndSign($data, $armor = self::ARMOR_ASCII) { return $this->_encryptAndSign($data, false, null, $armor); }
php
{ "resource": "" }
q256356
Crypt_GPG.encryptAndSignFile
test
public function encryptAndSignFile( $filename, $signedFile = null, $armor = self::ARMOR_ASCII ) { return $this->_encryptAndSign($filename, true, $signedFile, $armor); }
php
{ "resource": "" }
q256357
Crypt_GPG.decryptAndVerify
test
public function decryptAndVerify($encryptedData, $ignoreVerifyErrors = false) { return $this->_decryptAndVerify($encryptedData, false, null, $ignoreVerifyErrors); }
php
{ "resource": "" }
q256358
Crypt_GPG.decryptAndVerifyFile
test
public function decryptAndVerifyFile($encryptedFile, $decryptedFile = null, $ignoreVerifyErrors = false) { return $this->_decryptAndVerify($encryptedFile, true, $decryptedFile, $ignoreVerifyErrors); }
php
{ "resource": "" }
q256359
Crypt_GPG.signFile
test
public function signFile( $filename, $signedFile = null, $mode = self::SIGN_MODE_NORMAL, $armor = self::ARMOR_ASCII, $textmode = self::TEXT_RAW ) { return $this->_sign( $filename, true, $signedFile, $mode, $a...
php
{ "resource": "" }
q256360
Crypt_GPG.addDecryptKey
test
public function addDecryptKey($key, $passphrase = null) { $this->_addKey($this->decryptKeys, false, false, $key, $passphrase); return $this; }
php
{ "resource": "" }
q256361
Crypt_GPG.addEncryptKey
test
public function addEncryptKey($key) { $this->_addKey($this->encryptKeys, true, false, $key); return $this; }
php
{ "resource": "" }
q256362
Crypt_GPG.addSignKey
test
public function addSignKey($key, $passphrase = null) { $this->_addKey($this->signKeys, false, true, $key, $passphrase); return $this; }
php
{ "resource": "" }
q256363
Crypt_GPG._addKey
test
protected function _addKey(array &$array, $encrypt, $sign, $key, $passphrase = null ) { $subKeys = array(); if (is_scalar($key)) { $keys = $this->getKeys($key); if (count($keys) == 0) { throw new Crypt_GPG_KeyNotFoundException( 'Ke...
php
{ "resource": "" }
q256364
Crypt_GPG._importKey
test
protected function _importKey($key, $isFile) { $result = array(); $arguments = array(); $input = $this->_prepareInput($key, $isFile, false); $version = $this->engine->getVersion(); if (version_compare($version, '1.0.5', 'ge') && version_compare($version,...
php
{ "resource": "" }
q256365
Crypt_GPG._exportKey
test
protected function _exportKey($keyId, $armor = true, $private = false) { $fingerprint = $this->getFingerprint($keyId); if ($fingerprint === null) { throw new Crypt_GPG_KeyNotFoundException( 'Key not found: ' . $keyId, self::ERROR_KEY_NOT_FOUND, ...
php
{ "resource": "" }
q256366
Crypt_GPG._decryptAndVerify
test
protected function _decryptAndVerify($data, $isFile, $outputFile, $ignoreVerifyErrors = false) { $input = $this->_prepareInput($data, $isFile, false); $output = $this->_prepareOutput($outputFile, $input); $this->engine->reset(); $this->engine->setPins($this->decryptKeys); $...
php
{ "resource": "" }
q256367
Crypt_GPG._prepareInput
test
protected function _prepareInput($data, $isFile = false, $allowEmpty = true) { if ($isFile) { $input = @fopen($data, 'rb'); if ($input === false) { throw new Crypt_GPG_FileException( 'Could not open input file "' . $data . '"', ...
php
{ "resource": "" }
q256368
Crypt_GPG._prepareOutput
test
protected function _prepareOutput($outputFile, $input = null) { if ($outputFile === null) { $output = ''; } else { $output = @fopen($outputFile, 'wb'); if ($output === false) { if (is_resource($input)) { fclose($input); ...
php
{ "resource": "" }
q256369
Crypt_GPGAbstract._getKeys
test
protected function _getKeys($keyId = '') { // get private key fingerprints if ($keyId == '') { $operation = '--list-secret-keys'; } else { $operation = '--utf8-strings --list-secret-keys ' . escapeshellarg($keyId); } // According to The file 'doc/DETA...
php
{ "resource": "" }
q256370
Crypt_GPG_Engine.sendCommand
test
public function sendCommand($command) { if (array_key_exists(self::FD_COMMAND, $this->_openPipes)) { $this->_commandBuffer .= $command . PHP_EOL; } }
php
{ "resource": "" }
q256371
Crypt_GPG_Engine.reset
test
public function reset() { $this->_operation = ''; $this->_arguments = array(); $this->_input = null; $this->_message = null; $this->_output = ''; $this->_commandBuffer = ''; $this->_statusHandlers = array(); $this->_...
php
{ "resource": "" }
q256372
Crypt_GPG_Engine.run
test
public function run() { if ($this->_operation === '') { throw new Crypt_GPG_InvalidOperationException( 'No GPG operation specified. Use Crypt_GPG_Engine::setOperation() ' . 'before calling Crypt_GPG_Engine::run().' ); } $this->_openSub...
php
{ "resource": "" }
q256373
Crypt_GPG_Engine.setOperation
test
public function setOperation($operation, array $arguments = array()) { $this->_operation = $operation; $this->_arguments = $arguments; $this->_processHandler->setOperation($operation); }
php
{ "resource": "" }
q256374
Crypt_GPG_Engine.setPins
test
public function setPins(array $keys) { $envKeys = array(); foreach ($keys as $keyId => $key) { $envKeys[$keyId] = is_array($key) ? $key['passphrase'] : $key; } $_ENV['PINENTRY_USER_DATA'] = json_encode($envKeys); }
php
{ "resource": "" }
q256375
Crypt_GPG_Engine.getVersion
test
public function getVersion() { if ($this->_version == '') { $options = array( 'homedir' => $this->_homedir, 'binary' => $this->_binary, 'debug' => $this->_debug, 'agent' => $this->_agent, ); $engine = n...
php
{ "resource": "" }
q256376
Crypt_GPG_Engine.getProcessData
test
public function getProcessData($name) { if ($this->_processHandler) { switch ($name) { case 'SignatureInfo': if ($data = $this->_processHandler->getData('SigCreated')) { return new Crypt_GPG_SignatureCreationInfo($data); } ...
php
{ "resource": "" }
q256377
Crypt_GPG_Engine.setProcessData
test
public function setProcessData($name, $value) { if ($this->_processHandler) { $this->_processHandler->setData($name, $value); } }
php
{ "resource": "" }
q256378
Crypt_GPG_Engine._closeSubprocess
test
private function _closeSubprocess() { // clear PINs from environment if they were set $_ENV['PINENTRY_USER_DATA'] = null; if (is_resource($this->_process)) { $this->_debug('CLOSING GPG SUBPROCESS'); // close remaining open pipes foreach (array_keys($this...
php
{ "resource": "" }
q256379
Crypt_GPG_Engine._closeAgentLaunchProcess
test
private function _closeAgentLaunchProcess() { if (is_resource($this->_agentProcess)) { $this->_debug('CLOSING GPG-AGENT LAUNCH PROCESS'); // close agent pipes foreach ($this->_agentPipes as $pipe) { fflush($pipe); fclose($pipe); ...
php
{ "resource": "" }
q256380
Crypt_GPG_Engine._closePipe
test
private function _closePipe($pipeNumber) { $pipeNumber = intval($pipeNumber); if (array_key_exists($pipeNumber, $this->_openPipes)) { fflush($this->_openPipes[$pipeNumber]); fclose($this->_openPipes[$pipeNumber]); unset($this->_openPipes[$pipeNumber]); } ...
php
{ "resource": "" }
q256381
Crypt_GPG_Engine._closeIdleAgents
test
private function _closeIdleAgents() { if ($this->_gpgconf) { // before 2.1.13 --homedir wasn't supported, use env variable $env = array('GNUPGHOME' => $this->_homedir); $cmd = $this->_gpgconf . ' --kill gpg-agent'; if ($process = proc_open($cmd, array(), $pip...
php
{ "resource": "" }
q256382
Crypt_GPG_Engine._findBinary
test
private function _findBinary($name) { $binary = ''; if ($this->_isDarwin) { $locations = array( '/opt/local/bin/', // MacPorts '/usr/local/bin/', // Mac GPG '/sw/bin/', // Fink '/usr/bin/' ); } el...
php
{ "resource": "" }
q256383
Crypt_GPG_Engine._getPinEntry
test
private function _getPinEntry() { // Find PinEntry program depending on the way how the package is installed $ds = DIRECTORY_SEPARATOR; $root = __DIR__ . $ds . '..' . $ds . '..' . $ds; $paths = array( '@bin-dir@', // PEAR $root . 'scripts', // Git ...
php
{ "resource": "" }
q256384
Crypt_GPG_Engine._debug
test
private function _debug($text) { if ($this->_debug) { if (php_sapi_name() === 'cli') { foreach (explode(PHP_EOL, $text) as $line) { echo "Crypt_GPG DEBUG: ", $line, PHP_EOL; } } else if (is_callable($this->_debug)) { ...
php
{ "resource": "" }
q256385
Crypt_GPG_Key.getPrimaryKey
test
public function getPrimaryKey() { $primary_key = null; if (count($this->_subKeys) > 0) { $primary_key = $this->_subKeys[0]; } return $primary_key; }
php
{ "resource": "" }
q256386
Crypt_GPG_Key.canSign
test
public function canSign() { $canSign = false; foreach ($this->_subKeys as $subKey) { if ($subKey->canSign()) { $canSign = true; break; } } return $canSign; }
php
{ "resource": "" }
q256387
Crypt_GPG_Key.canEncrypt
test
public function canEncrypt() { $canEncrypt = false; foreach ($this->_subKeys as $subKey) { if ($subKey->canEncrypt()) { $canEncrypt = true; break; } } return $canEncrypt; }
php
{ "resource": "" }
q256388
Crypt_GPG_PinEntry.setLogFilename
test
public function setLogFilename($filename) { if (is_resource($this->logFile)) { fflush($this->logFile); fclose($this->logFile); $this->logFile = null; } if ($filename != '') { if (($this->logFile = fopen($filename, 'w')) === false) { ...
php
{ "resource": "" }
q256389
Crypt_GPG_PinEntry.log
test
protected function log($data, $level) { if ($this->verbosity >= $level) { if (is_resource($this->logFile)) { fwrite($this->logFile, $data); fflush($this->logFile); } else { $this->parser->outputter->stderr($data); } ...
php
{ "resource": "" }
q256390
Crypt_GPG_PinEntry.connect
test
protected function connect() { // Binary operations will not work on Windows with PHP < 5.2.6. $rb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'r' : 'rb'; $wb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'w' : 'wb'; $this->stdin = fopen('php://stdin', $rb); $this->st...
php
{ "resource": "" }
q256391
Crypt_GPG_PinEntry.parseCommand
test
protected function parseCommand($line) { $this->log('<- ' . $line . PHP_EOL, self::VERBOSITY_ALL); $parts = explode(' ', $line, 2); $command = $parts[0]; if (count($parts) === 2) { $data = $parts[1]; } else { $data = null; } switch ...
php
{ "resource": "" }
q256392
Crypt_GPG_PinEntry.initPinsFromENV
test
protected function initPinsFromENV() { if (($userData = getenv('PINENTRY_USER_DATA')) !== false) { $pins = json_decode($userData, true); if ($pins === null) { $this->log( '-- failed to parse user data' . PHP_EOL, self::VERBOSITY...
php
{ "resource": "" }
q256393
Crypt_GPG_PinEntry.disconnect
test
protected function disconnect() { $this->log('-- disconnecting' . PHP_EOL, self::VERBOSITY_ALL); fflush($this->stdout); fclose($this->stdout); fclose($this->stdin); $this->stdin = null; $this->stdout = null; $this->log('-- disconnected' . PHP_EOL, self::VE...
php
{ "resource": "" }
q256394
Crypt_GPG_PinEntry.sendSetDescription
test
protected function sendSetDescription($text) { $text = rawurldecode($text); $matches = array(); // TODO: handle user id with quotation marks $exp = '/\n"(.+)"\n.*\sID ([A-Z0-9]+),\n/mu'; if (preg_match($exp, $text, $matches) === 1) { $userId = $matches[1]; ...
php
{ "resource": "" }
q256395
Crypt_GPG_PinEntry.sendGetPin
test
protected function sendGetPin() { $foundPin = ''; if (is_array($this->currentPin)) { $keyIdLength = mb_strlen($this->currentPin['keyId'], '8bit'); // search for the pin foreach ($this->pins as $_keyId => $pin) { // Warning: GnuPG 2.1 asks 3 times...
php
{ "resource": "" }
q256396
Crypt_GPG_PinEntry.sendGetInfo
test
protected function sendGetInfo($data) { $parts = explode(' ', $data, 2); $command = reset($parts); switch ($command) { case 'pid': return $this->sendGetInfoPID(); default: return $this->send($this->getOK()); } return $this; }
php
{ "resource": "" }
q256397
Crypt_GPG_PinEntry.getData
test
protected function getData($data) { // Escape data. Only %, \n and \r need to be escaped but other // values are allowed to be escaped. See // http://www.gnupg.org/documentation/manuals/assuan/Server-responses.html $data = rawurlencode($data); $data = $this->getWordWrappedDat...
php
{ "resource": "" }
q256398
Crypt_GPG_PinEntry.getWordWrappedData
test
protected function getWordWrappedData($data, $prefix) { $lines = array(); do { if (mb_strlen($data, '8bit') > 997) { $line = $prefix . ' ' . mb_strcut($data, 0, 996, 'utf-8') . "\\\n"; $lines[] = $line; $lineLength = mb_strlen($line, '8bit...
php
{ "resource": "" }
q256399
Crypt_GPG_PinEntry.send
test
protected function send($data) { $this->log('-> ' . $data, self::VERBOSITY_ALL); fwrite($this->stdout, $data); fflush($this->stdout); return $this; }
php
{ "resource": "" }