本文整理汇总了PHP中CString::indexOf方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::indexOf方法的具体用法?PHP CString::indexOf怎么用?PHP CString::indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::indexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}