本文整理汇总了PHP中vs函数的典型用法代码示例。如果您正苦于以下问题:PHP vs函数的具体用法?PHP vs怎么用?PHP vs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __set
/**
* @ignore
*/
public function __set($name, $value)
{
// The purpose of this method is to detect references to undeclared object variables (properties) in
// implementations of non-static methods, where the name of the undeclared variable could be resulting from
// a typo.
assert('false', vs(isset($this), get_defined_vars()));
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CRootClass.php
示例2: encode
/**
* Encodes a data with Base64 encoding and returns the result.
*
* @param data $data The data to be encoded.
*
* @return CUStringObject The encoded data.
*/
public static function encode($data)
{
assert('is_cstring($data)', vs(isset($this), get_defined_vars()));
$encodedData = base64_encode($data);
assert('is_cstring($encodedData)', vs(isset($this), get_defined_vars()));
return $encodedData;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:14,代码来源:CBase64.php
示例3: hashTypeToString
protected static function hashTypeToString($hashType)
{
switch ($hashType) {
case self::MD2:
return "md2";
case self::MD4:
return "md4";
case self::MD5:
return "md5";
case self::SHA1:
return "sha1";
case self::SHA224:
return "sha224";
case self::SHA256:
return "sha256";
case self::SHA384:
return "sha384";
case self::SHA512:
return "sha512";
case self::RIPEMD128:
return "ripemd128";
case self::RIPEMD160:
return "ripemd160";
case self::RIPEMD256:
return "ripemd256";
case self::RIPEMD320:
return "ripemd320";
case self::WHIRLPOOL:
return "whirlpool";
case self::TIGER128_3:
return "tiger128,3";
case self::TIGER160_3:
return "tiger160,3";
case self::TIGER192_3:
return "tiger192,3";
case self::TIGER128_4:
return "tiger128,4";
case self::TIGER160_4:
return "tiger160,4";
case self::TIGER192_4:
return "tiger192,4";
case self::SNEFRU:
return "snefru";
case self::SNEFRU256:
return "snefru256";
case self::GOST:
return "gost";
case self::ADLER32:
return "adler32";
case self::CRC32:
return "crc32";
case self::CRC32B:
return "crc32b";
case self::FNV132:
return "fnv132";
case self::FNV164:
return "fnv164";
case self::JOAAT:
return "joaat";
case self::HAVAL128_3:
return "haval128,3";
case self::HAVAL160_3:
return "haval160,3";
case self::HAVAL192_3:
return "haval192,3";
case self::HAVAL224_3:
return "haval224,3";
case self::HAVAL256_3:
return "haval256,3";
case self::HAVAL128_4:
return "haval128,4";
case self::HAVAL160_4:
return "haval160,4";
case self::HAVAL192_4:
return "haval192,4";
case self::HAVAL224_4:
return "haval224,4";
case self::HAVAL256_4:
return "haval256,4";
case self::HAVAL128_5:
return "haval128,5";
case self::HAVAL160_5:
return "haval160,5";
case self::HAVAL192_5:
return "haval192,5";
case self::HAVAL224_5:
return "haval224,5";
case self::HAVAL256_5:
return "haval256,5";
default:
assert('false', vs(isset($this), get_defined_vars()));
}
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:93,代码来源:CHash.php
示例4: enterTd
/**
* In a string, escapes all characters that have a special meaning in the regular expression domain, and returns
* the escaped string.
*
* With this method, you can prepare an arbitrary string to be used as a part of a regular expression.
*
* @param string $string The string to be escaped.
* @param string $delimiter **OPTIONAL. Default is** "/". The pattern delimiter that is going to be used by the
* resulting regular expression and therefore needs to be escaped as well.
*
* @return string The escaped string.
*/
public static function enterTd($string, $delimiter = self::DEFAULT_PATTERN_DELIMITER)
{
assert('is_cstring($string) && is_cstring($delimiter)', vs(isset($this), get_defined_vars()));
return preg_quote($string, $delimiter);
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:17,代码来源:CRegex.php
示例5: isNameIcuCompatible
/**
* @ignore
*/
public static function isNameIcuCompatible($name)
{
assert('is_cstring($name)', vs(isset($this), get_defined_vars()));
$itz = IntlTimeZone::createTimeZone($name);
return CString::equals($name, $itz->getID());
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:9,代码来源:CTimeZone.php
示例6: finalize
protected function finalize()
{
$res = fclose($this->m_file);
assert('$res', vs(isset($this), get_defined_vars()));
$this->m_done = true;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:6,代码来源:CFile.php
示例7: setMailing
public static function setMailing(CMail $mail, $minTimeBetweenSendMailHours = self::DEFAULT_MIN_TIME_BETWEEN_SEND_MAIL_HOURS)
{
// Enables mailing about encountered errors with the provided CMail object.
assert('is_int($minTimeBetweenSendMailHours)', vs(isset($this), get_defined_vars()));
assert('$minTimeBetweenSendMailHours >= 0', vs(isset($this), get_defined_vars()));
self::$ms_mailing = true;
self::$ms_mail = $mail;
self::$ms_minTimeBetweenSendMailHours = $minTimeBetweenSendMailHours;
self::registerHandlers();
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CDebug.php
示例8: leaveTdAll
/**
* Translates a string out of the XML text domain, replacing all XML entities with their literal equivalents.
*
* Both double and single quotes are translated.
*
* @param string $string The string to be translated.
*
* @return CUStringObject The translated string.
*/
public static function leaveTdAll($string)
{
assert('is_cstring($string)', vs(isset($this), get_defined_vars()));
return html_entity_decode($string, ENT_QUOTES, "UTF-8");
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:14,代码来源:CXml.php
示例9: convertMassf
/**
* Converts a floating-point quantity of mass from one unit into another and returns the result.
*
* @param float $quantity The quantity to be converted.
* @param enum $fromUnit The source unit.
* @param enum $toUnit The destination unit.
*
* @return float The converted quantity.
*/
public static function convertMassf($quantity, $fromUnit, $toUnit)
{
assert('is_float($quantity) && is_enum($fromUnit) && is_enum($toUnit)', vs(isset($this), get_defined_vars()));
assert('$quantity >= 0.0', vs(isset($this), get_defined_vars()));
if ($fromUnit == $toUnit) {
return $quantity;
}
$milligramQty;
switch ($fromUnit) {
case self::MILLIGRAM:
$milligramQty = $quantity;
break;
case self::GRAM:
$milligramQty = $quantity * 1000;
break;
case self::KILOGRAM:
$milligramQty = $quantity * 1000000;
break;
case self::TON:
$milligramQty = $quantity * 1000000000;
break;
case self::OUNCE:
$milligramQty = $quantity * 28349.5231;
break;
case self::POUND:
$milligramQty = $quantity * 453592.37;
break;
case self::STONE:
$milligramQty = $quantity * 6350293.18;
break;
case self::SHORT_TON:
$milligramQty = $quantity * 907184740;
break;
case self::LONG_TON:
$milligramQty = $quantity * 1016046908.8;
break;
default:
assert('false', vs(isset($this), get_defined_vars()));
break;
}
$outputQty;
switch ($toUnit) {
case self::MILLIGRAM:
$outputQty = $milligramQty;
break;
case self::GRAM:
$outputQty = $milligramQty / 1000;
break;
case self::KILOGRAM:
$outputQty = $milligramQty / 1000000;
break;
case self::TON:
$outputQty = $milligramQty / 1000000000;
break;
case self::OUNCE:
$outputQty = $milligramQty / 28349.5231;
break;
case self::POUND:
$outputQty = $milligramQty / 453592.37;
break;
case self::STONE:
$outputQty = $milligramQty / 6350293.18;
break;
case self::SHORT_TON:
$outputQty = $milligramQty / 907184740;
break;
case self::LONG_TON:
$outputQty = $milligramQty / 1016046908.8;
break;
default:
assert('false', vs(isset($this), get_defined_vars()));
break;
}
return $outputQty;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:84,代码来源:CUUnit.php
示例10: frameworkPath
/**
* Replaces any reference to one of the framework's special directories in a path with the directory's actual path
* and returns the usable path.
*
* A framework's directory is referenced in a path by wrapping its ID into double curly braces, as in
* "{{PHRED_PATH_TO_FRAMEWORK_ROOT}}", optionally with "/" after the reference.
*
* @param string $path The path to the file or directory (can be absolute or relative).
*
* @return CUStringObject The usable path.
*/
public static function frameworkPath($path)
{
assert('!isset($path) || is_cstring($path)', vs(isset($this), get_defined_vars()));
if (!isset($path)) {
return null;
}
// Replace every "{{EXAMPLE_PATH}}" in the path string with the value of "EXAMPLE_PATH" key from $GLOBALS
// variable if such key exists in the variable.
$modified = false;
$path = CRegex::replaceWithCallback($path, "/\\{\\{\\w+\\}\\}/", function ($matches) use(&$modified) {
$pathVarName = CString::substr($matches[0], 2, CString::length($matches[0]) - 4);
if (isset($GLOBALS[$pathVarName])) {
$modified = true;
return $GLOBALS[$pathVarName] . "/";
} else {
assert('false', vs(isset($this), get_defined_vars()));
return $matches[0];
}
});
if ($modified) {
$path = CRegex::replace($path, "/\\/{2,}/", "/");
}
return $path;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:35,代码来源:CFilePath.php
示例11: repeat
/**
* Repeats an element for a specified number of times and returns the resulting array.
*
* For instance, an element of "a" repeated three times would result in an array of "a", "a", "a".
*
* @param mixed $element The element to be repeated.
* @param int $times The length of the resulting array.
*
* @return CArray The resulting array.
*/
public static function repeat($element, $times)
{
assert('is_int($times)', vs(isset($this), get_defined_vars()));
assert('$times > 0', vs(isset($this), get_defined_vars()));
$resArray = self::make($times);
for ($i = 0; $i < $times; $i++) {
$resArray[$i] = $element;
}
return $resArray;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:20,代码来源:CArray.php
示例12: repeat
/**
* Repeats a string for a specified number of times and returns the resulting string.
*
* For instance, the string of "a" repeated three times would result in "aaa".
*
* @param string $string The string to be repeated.
* @param int $times The number of times for the string to be repeated.
*
* @return string The resulting string.
*/
public static function repeat($string, $times)
{
assert('is_cstring($string) && is_int($times)', vs(isset($this), get_defined_vars()));
assert('$times > 0 || (self::isEmpty($string) && $times == 0)', vs(isset($this), get_defined_vars()));
return str_repeat($string, $times);
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:16,代码来源:CString.php
示例13: patternEnumToString
protected static function patternEnumToString($pattern)
{
switch ($pattern) {
case self::PATTERN_DEFAULT:
return "Y-m-d H:i:s e";
case self::PATTERN_DEFAULT_DATE:
return "Y-m-d";
case self::PATTERN_DEFAULT_TIME:
return "H:i:s";
case self::PATTERN_ATOM:
return "Y-m-d\\TH:i:sP";
case self::PATTERN_COOKIE:
return "l, d-M-y H:i:s T";
case self::PATTERN_HTTP_HEADER_GMT:
return "D, d M Y H:i:s T";
case self::PATTERN_ISO8601:
return "Y-m-d\\TH:i:sO";
case self::PATTERN_MYSQL:
return "Y-m-d H:i:s";
case self::PATTERN_RFC822:
return "D, d M y H:i:s O";
case self::PATTERN_RFC850:
return "l, d-M-y H:i:s T";
case self::PATTERN_RFC1036:
return "D, d M y H:i:s O";
case self::PATTERN_RFC2822:
return "D, d M Y H:i:s O";
case self::PATTERN_RFC3339:
return "Y-m-d\\TH:i:sP";
case self::PATTERN_RSS:
return "D, d M Y H:i:s O";
case self::PATTERN_W3C:
return "Y-m-d\\TH:i:sP";
default:
assert('false', vs(isset($this), get_defined_vars()));
}
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:37,代码来源:CTime.php
示例14: onThirdPartyUpdateByPackageManager
/**
* @ignore
*/
public static function onThirdPartyUpdateByPackageManager()
{
if (!self::isInCliMode()) {
// This method can be run in CLI mode only.
assert('false', vs(isset($this), get_defined_vars()));
}
$timeoutPause = new CTimeoutPause();
CShell::speak("Processing third-party components ...");
$tpDps = CFile::listDirectories(CFilePath::absolute($GLOBALS["PHRED_PATH_TO_THIRD_PARTY"]));
$ignorePackages = CConfiguration::option("upd.thirdPartyOopWrappingIgnorePackages");
$ignorePackagesL2 = CArray::filter($ignorePackages, function ($package) {
return CString::find($package, "/");
});
$newTpDps = CArray::make();
$len = CArray::length($tpDps);
for ($i = 0; $i < $len; $i++) {
$tpDp = $tpDps[$i];
$dirName = CFilePath::name($tpDp);
if (!CArray::find($ignorePackages, $dirName)) {
$dpHasL2DirsToIgnore = CArray::find($ignorePackagesL2, $dirName, function ($packageL2, $dirName) {
return CString::equals(CFilePath::directory($packageL2), $dirName);
});
if (!$dpHasL2DirsToIgnore) {
CArray::push($newTpDps, $tpDp);
} else {
$tpSubDps = CFile::listDirectories($tpDp);
$tpSubDps = CArray::filter($tpSubDps, function ($subDp) use($ignorePackagesL2) {
return !CArray::find($ignorePackagesL2, $subDp, function ($packageL2, $subDp) {
return CString::endsWith($subDp, $packageL2);
});
});
CArray::pushArray($newTpDps, $tpSubDps);
}
}
}
$tpDps = $newTpDps;
$wrapProtectedMethods = CConfiguration::option("upd.thirdPartyOopWrappingInProtectedMethods");
$wrapPrivateMethods = CConfiguration::option("upd.thirdPartyOopWrappingInPrivateMethods");
static $s_stdPhpTag = "<?php";
static $s_progressResolution = 0.05;
$prevProgressDivR = 0;
$tpDpsLen = CArray::length($tpDps);
for ($i0 = 0; $i0 < $tpDpsLen; $i0++) {
$tpFps = CFile::reFindFilesRecursive($tpDps[$i0], "/\\.php\\d?\\z/");
$tpFpsLen = CArray::length($tpFps);
for ($i1 = 0; $i1 < $tpFpsLen; $i1++) {
$fileCode = CFile::read($tpFps[$i1]);
if (!CString::find($fileCode, self::$ms_thirdPartyAlreadyOopWrappedMark)) {
$parser = new PhpParser\Parser(new PhpParser\Lexer());
try {
// Parse the code.
$statements = $parser->parse($fileCode);
// Wrap the code into OOP.
$traverser = new PhpParser\NodeTraverser();
$mainVisitor = new CMainVisitor($wrapProtectedMethods, $wrapPrivateMethods);
$traverser->addVisitor($mainVisitor);
$statements = $traverser->traverse($statements);
$wrappedCode = (new PhpParser\PrettyPrinter\Standard())->prettyPrint($statements);
$phpTagPos = CString::indexOf($wrappedCode, $s_stdPhpTag);
if ($phpTagPos == -1) {
$wrappedCode = "{$s_stdPhpTag}\n\n{$wrappedCode}";
$phpTagPos = 0;
}
$wrappedCode = CString::insert($wrappedCode, $phpTagPos + CString::length($s_stdPhpTag), "\n\n" . self::$ms_thirdPartyAlreadyOopWrappedMark);
// Save.
CFile::write($tpFps[$i1], $wrappedCode);
} catch (PhpParser\Error $parserError) {
CShell::say("\nPhpParser: " . $tpFps[$i1] . ", at line " . $parserError->getRawLine() . ": " . $parserError->getRawMessage());
}
}
$progress = (double) ($i0 / $tpDpsLen + 1 / $tpDpsLen * $i1 / $tpFpsLen);
$progressDivR = CMathi::floor($progress / $s_progressResolution);
if ($progressDivR != $prevProgressDivR) {
$perc = CMathi::round($progressDivR * $s_progressResolution * 100);
CShell::speak("{$perc}%");
}
$prevProgressDivR = $progressDivR;
}
}
CShell::speak("100%");
CShell::say("Done.");
$timeoutPause->end();
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:86,代码来源:CSystem.php
示例15: leaveTdOld
/**
* In a string, removes percent-encoding (URL encoding) from all characters encoded according to the older flavor
* of percent-encoding and returns the new string.
*
* According to the older flavor of percent-encoding, the space character is decoded from either "+" or "%20"
* (literal spaces are not permitted in a valid URL), "+" from "%2B" only, and "~" from either "%7E" or "~". This
* flavor of percent-encoding is primarily used with query strings in URLs and with
* "application/x-www-form-urlencoded" data in POST requests. In any other place, the newer flavor of
* percent-encoding is usually preferred.
*
* @param string $string The string to be translated out of the URL text domain.
*
* @return CUStringObject The translated string.
*/
public static function leaveTdOld($string)
{
assert('is_cstring($string)', vs(isset($this), get_defined_vars()));
return urldecode($string);
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:19,代码来源:CUrl.php
示例16: recurseValueBeforeFiltering
protected static function recurseValueBeforeFiltering($value, $inputFilterOrFilterCollection, &$success, $currDepth)
{
assert('$inputFilterOrFilterCollection instanceof CInputFilter || ' . 'is_collection($inputFilterOrFilterCollection)', vs(isset($this), get_defined_vars()));
if ($currDepth == self::$ms_maxRecursionDepth) {
$success = false;
return;
}
$currDepth++;
if (!is_cmap($value)) {
// Only interested in PHP arrays.
return $value;
}
if (is_carray($inputFilterOrFilterCollection)) {
// The output value is expected to be a CArray; the keys in the arrived PHP array should be sequential.
if (!CMap::areKeysSequential($value)) {
$success = false;
return;
}
$value = CArray::fromPArray($value);
$len = CArray::length($value);
if ($len != CArray::length($inputFilterOrFilterCollection)) {
$success = false;
return;
}
for ($i = 0; $i < $len; $i++) {
$inputValue = $value[$i];
$inputFilterElement = $inputFilterOrFilterCollection[$i];
$inputValue = self::recurseValueBeforeFiltering($inputValue, $inputFilterElement, $success, $currDepth);
if (!$success) {
return;
}
$value[$i] = $inputValue;
}
} else {
if (is_cmap($inputFilterOrFilterCollection)) {
// The output value is expected to be a CMap; already got one.
foreach ($value as $inputKey => &$inputValue) {
if (!CMap::hasKey($inputFilterOrFilterCollection, $inputKey)) {
$success = false;
return;
}
$inputFilterElement = $inputFilterOrFilterCollection[$inputKey];
$inputValue = self::recurseValueBeforeFiltering($inputValue, $inputFilterElement, $success, $currDepth);
if (!$success) {
return;
}
}
unset($inputValue);
} else {
$success = false;
return;
}
}
return $value;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:55,代码来源:CRequest.php
示例17: isReturnTransferSet
/**
* @ignore
*/
public function isReturnTransferSet()
{
// To be used by "friend" classes only.
assert('isset($this->m_isReturnTransferSet)', vs(isset($this), get_defined_vars()));
return $this->m_isReturnTransferSet;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:9,代码来源:CInetRequest.php
示例18: addComponent
/**
* Adds a component to a URL path.
*
* @param string $component The component to be added. All the characters in the component's string should be
* represented literally and none of the characters should be percent-encoded.
*
* @return void
*/
public function addComponent($component)
{
assert('is_cstring($component)', vs(isset($this), get_defined_vars()));
CArray::push($this->m_components, $component);
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:13,代码来源:CUrlPath.php
示例19: send
/**
* Sends a message to the recipient(s).
*
* @param reference $failedAddresses **OPTIONAL. OUTPUT.** After the method is called with this parameter
* provided, the parameter's value, which is of type `CArrayObject`, is an array containing the email addresses of
* the recipients who failed to receive the message.
*
* @return int The number of recipients who have successfully received the message.
*/
public function send(&$failedAddresses = null)
{
assert('isset($this->m_swiftMailer) && isset($this->m_swiftMessage)', vs(isset($this), get_defined_vars()));
assert('(isset($this->m_from) || isset($this->m_sender) || isset($this->m_returnAddress)) && ' . '(isset($this->m_to) || isset($this->m_cc) || isset($this->m_bcc))', vs(isset($this), get_defined_vars()));
$message = $this->m_swiftMessage;
if (isset($this->m_from)) {
$message->setFrom($this->m_from);
}
if (isset($this->m_to)) {
$message->setTo($this->m_to);
}
if (isset($this->m_cc)) {
$message->setCc($this->m_cc);
}
if (isset($this->m_bcc)) {
$message->setBcc($this->m_bcc);
}
if (isset($this->m_sender)) {
$message->setSender($this->m_sender);
}
if (isset($this->m_returnAddress)) {
$message->setReturnPath($this->m_returnAddress);
}
if (isset($this->m_replyAddress)) {
$message->setReplyTo($this->m_replyAddress);
}
if (isset($this->m_body)) {
if (CString::equals($this->m_bodyType, CMimeType::PLAIN_TEXT)) {
$this->m_body = $this->maybeWrapText($this->m_body);
}
$message->setBody($this->m_body, $this->m_bodyType);
}
if (isset($this->m_altBodiesAndTypes)) {
$len = CArray::length($this->m_altBodiesAndTypes);
for ($i = 0; $i < $len; $i++) {
$bodyAndType = $this->m_altBodiesAndTypes[$i];
$body = $bodyAndType[0];
$type = $bodyAndType[1];
if (CString::equals($type, CMimeType::PLAIN_TEXT)) {
$body = $this->maybeWrapText($body);
}
$message->addPart($body, $type);
}
}
$paFailedAddresses;
$res = $this->m_swiftMailer->send($message, $paFailedAddresses);
if (is_cmap($paFailedAddresses)) {
$failedAddresses = oop_a(CArray::fromPArray($paFailedAddresses));
}
$res = is_int($res) ? $res : 0;
return $res;
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:61,代码来源:CMail.php
示例20: offsetUnset
/**
* @ignore
*/
public function offsetUnset($offset)
{
assert('false', vs(isset($this), get_defined_vars()));
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:7,代码来源:CArrayObject.php
注:本文中的vs函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论