当前位置: 首页>>代码示例>>PHP>>正文


PHP StringHelper::startsWith方法代码示例

本文整理汇总了PHP中StringHelper::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::startsWith方法的具体用法?PHP StringHelper::startsWith怎么用?PHP StringHelper::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringHelper的用法示例。


在下文中一共展示了StringHelper::startsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read

 /**
  * Returns stream only including
  * lines from the original stream which don't start with any of the
  * specified comment prefixes.
  *
  * @param null $len
  * @return mixed the resulting stream, or -1
  *               if the end of the resulting stream has been reached.
  *
  */
 public function read($len = null)
 {
     if (!$this->getInitialized()) {
         $this->_initialize();
         $this->setInitialized(true);
     }
     $buffer = $this->in->read($len);
     if ($buffer === -1) {
         return -1;
     }
     $lines = explode("\n", $buffer);
     $filtered = array();
     $commentsSize = count($this->_comments);
     foreach ($lines as $line) {
         for ($i = 0; $i < $commentsSize; $i++) {
             $comment = $this->_comments[$i]->getValue();
             if (StringHelper::startsWith($comment, ltrim($line))) {
                 $line = null;
                 break;
             }
         }
         if ($line !== null) {
             $filtered[] = $line;
         }
     }
     $filtered_buffer = implode("\n", $filtered);
     return $filtered_buffer;
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:38,代码来源:StripLineComments.php

示例2: nextQuery

 /**
  * Returns next query from SQL source, null if no more queries left
  *
  * In case of "row" delimiter type this searches for strings containing only
  * delimiters. In case of "normal" delimiter type, this uses simple regular
  * expression logic to search for delimiters.
  *
  * @return string|null
  */
 public function nextQuery()
 {
     $sql = "";
     $hasQuery = false;
     while (($line = $this->sqlReader->readLine()) !== null) {
         $delimiter = $this->parent->getDelimiter();
         $project = $this->parent->getOwningTarget()->getProject();
         $line = ProjectConfigurator::replaceProperties($project, trim($line), $project->getProperties());
         if ($line != $delimiter && (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line))) {
             continue;
         }
         if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
             continue;
         }
         // MySQL supports defining new delimiters
         if (preg_match('/DELIMITER [\'"]?([^\'" $]+)[\'"]?/i', $line, $matches)) {
             $this->parent->setDelimiter($matches[1]);
             continue;
         }
         if ($this->sqlBacklog !== "") {
             $sql = $this->sqlBacklog;
             $this->sqlBacklog = "";
         }
         $sql .= " " . $line . "\n";
         // SQL defines "--" as a comment to EOL
         // and in Oracle it may contain a hint
         // so we cannot just remove it, instead we must end it
         if (strpos($line, "--") !== false) {
             $sql .= "\n";
         }
         // DELIM_ROW doesn't need this (as far as i can tell)
         if ($this->delimiterType == PDOSQLExecTask::DELIM_NORMAL) {
             $reg = "#((?:\"(?:\\\\.|[^\"])*\"?)+|'(?:\\\\.|[^'])*'?|" . preg_quote($delimiter) . ")#";
             $sqlParts = preg_split($reg, $sql, 0, PREG_SPLIT_DELIM_CAPTURE);
             $this->sqlBacklog = "";
             foreach ($sqlParts as $sqlPart) {
                 // we always want to append, even if it's a delim (which will be stripped off later)
                 $this->sqlBacklog .= $sqlPart;
                 // we found a single (not enclosed by ' or ") delimiter, so we can use all stuff before the delim as the actual query
                 if ($sqlPart === $delimiter) {
                     $sql = $this->sqlBacklog;
                     $this->sqlBacklog = "";
                     $hasQuery = true;
                 }
             }
         }
         if ($hasQuery || $this->delimiterType == PDOSQLExecTask::DELIM_ROW && $line == $delimiter) {
             // this assumes there is always a delimter on the end of the SQL statement.
             $sql = StringHelper::substring($sql, 0, strlen($sql) - strlen($delimiter) - ($this->delimiterType == PDOSQLExecTask::DELIM_ROW ? 2 : 1));
             return $sql;
         }
     }
     // Catch any statements not followed by ;
     if ($sql !== "") {
         return $sql;
     }
     return null;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:67,代码来源:DefaultPDOQuerySplitter.php

示例3: main

 function main($_sourceFileName)
 {
     if ($this->fromPrefix === null || !StringHelper::startsWith($this->fromPrefix, $_sourceFileName) || !StringHelper::endsWith($this->fromPostfix, $_sourceFileName)) {
         return null;
     }
     $varpart = $this->_extractVariablePart($_sourceFileName);
     $substitution = $this->toPrefix . $varpart . $this->toPostfix;
     return array($substitution);
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:9,代码来源:GlobMapper.php

示例4: MaskCheck

 public static function MaskCheck($item, $masks)
 {
     $maskCheck = false;
     foreach ($masks as $mask) {
         if (\StringHelper::startsWith($item, $mask) || \StringHelper::endsWith($item, $mask)) {
             $maskCheck = true;
         }
     }
     return $maskCheck;
 }
开发者ID:dotBunny,项目名称:Blueprint,代码行数:10,代码来源:string.php

示例5: normalizeSlashes

 function normalizeSlashes($path)
 {
     // Url must not end with slash
     while (StringHelper::endsWith($path, '/')) {
         $path = substr($path, 0, -1);
     }
     // Url must start with slash
     if (!StringHelper::startsWith($path, '/')) {
         $path = '/' . $path;
     }
     return $path;
 }
开发者ID:ademirzanetti,项目名称:labs,代码行数:12,代码来源:Route.php

示例6: execute

 public function execute(IWebRequest $request, IWebResponse $response)
 {
     $this->model->setTemplateName($this->getTemplateName());
     $this->model->setFeeding($this->feedingRepository->getInProgress());
     $feeding = $this->model->getFeeding();
     if ($feeding->hasBottle() && !$this->stringHelper->startsWith($request->path(), '/bottle')) {
         $response->redirect('/bottle');
     } else {
         if ($feeding->hasMilking() && !$this->stringHelper->startsWith($request->path(), '/milking')) {
             $response->redirect('/milking');
         } else {
             if ($feeding->hasBreastFeeding() && !$this->stringHelper->startsWith($request->path(), '/breast')) {
                 $response->redirect('/breast');
             } else {
                 if ($feeding->hasDiaper() && !$this->stringHelper->startsWith($request->path(), '/diaper')) {
                     $response->redirect('/diaper');
                 }
             }
         }
     }
     return $this->model;
 }
开发者ID:pingvinen,项目名称:octobabytracker,代码行数:22,代码来源:InputControllerBase.class.php

示例7: nextQuery

 /**
  * Returns entire SQL source
  *
  * @return string|null
  */
 public function nextQuery()
 {
     $sql = null;
     while (($line = $this->sqlReader->readLine()) !== null) {
         $delimiter = $this->parent->getDelimiter();
         $project = $this->parent->getOwningTarget()->getProject();
         $line = ProjectConfigurator::replaceProperties($project, trim($line), $project->getProperties());
         if ($line != $delimiter && (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line))) {
             continue;
         }
         $sql .= " " . $line . "\n";
     }
     return $sql;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:19,代码来源:DummyPDOQuerySplitter.php

示例8: main

 /**
  * Does the work.
  *
  * @throws BuildException if someting goes wrong with the build
  */
 public final function main()
 {
     if ($this->cvsRoot === null) {
         throw new BuildException("cvsroot is required");
     }
     if ($this->password === null) {
         throw new BuildException("password is required");
     }
     $this->log("cvsRoot: " . $this->cvsRoot, Project::MSG_DEBUG);
     $this->log("password: " . $this->password, Project::MSG_DEBUG);
     $this->log("passFile: " . $this->passFile->__toString(), Project::MSG_DEBUG);
     $reader = null;
     $writer = null;
     try {
         $buf = "";
         if ($this->passFile->exists()) {
             $reader = new BufferedReader(new FileReader($this->passFile));
             $line = null;
             while (($line = $reader->readLine()) !== null) {
                 if (!StringHelper::startsWith($this->cvsRoot, $line)) {
                     $buf .= $line . PHP_EOL;
                 }
             }
         }
         $pwdfile = $buf . $this->cvsRoot . " A" . $this->mangle($this->password);
         $this->log("Writing -> " . $pwdfile, Project::MSG_DEBUG);
         $writer = new BufferedWriter(new FileWriter($this->passFile));
         $writer->write($pwdfile);
         $writer->newLine();
         $writer->close();
         if ($reader) {
             $reader->close();
         }
     } catch (IOException $e) {
         if ($reader) {
             try {
                 $reader->close();
             } catch (Exception $e) {
             }
         }
         if ($writer) {
             try {
                 $writer->close();
             } catch (Exception $e) {
             }
         }
         throw new BuildException($e);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:54,代码来源:CvsPassTask.php

示例9: evaluate

 function evaluate()
 {
     $osName = strtolower(Phing::getProperty("os.name"));
     if ($this->family !== null) {
         if ($this->family === "windows") {
             return StringHelper::startsWith("win", $osName);
         } elseif ($this->family === "mac") {
             return strpos($osName, "mac") !== false || strpos($osName, "darwin") !== false;
         } elseif ($this->family === "unix") {
             return StringHelper::endsWith("ix", $osName) || StringHelper::endsWith("ux", $osName) || StringHelper::endsWith("bsd", $osName) || StringHelper::startsWith("sunos", $osName) || StringHelper::startsWith("darwin", $osName);
         }
         throw new BuildException("Don't know how to detect os family '" . $this->family . "'");
     }
     return false;
 }
开发者ID:vinnivinsachi,项目名称:Vincent-DR,代码行数:15,代码来源:OsCondition.php

示例10: nextQuery

 /**
  * Returns entire SQL source
  *
  * @return string|null
  */
 public function nextQuery()
 {
     $sql = null;
     while (($line = $this->sqlReader->readLine()) !== null) {
         $delimiter = $this->parent->getDelimiter();
         $project = $this->parent->getOwningTarget()->getProject();
         $line = ProjectConfigurator::replaceProperties($project, trim($line), $project->getProperties());
         if ($line != $delimiter && (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line))) {
             continue;
         }
         $sql .= " " . $line . "\n";
         /**
          * fix issue with PDO and wrong formated multistatements
          * @issue 1108
          */
         if (StringHelper::endsWith($delimiter, $line)) {
             break;
         }
     }
     return $sql;
 }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:26,代码来源:DummyPDOQuerySplitter.php

示例11: matchPatternStart

 /**
  * Tests whether or not a given path matches the start of a given
  * pattern up to the first "**".
  * <p>
  * This is not a general purpose test and should only be used if you
  * can live with false positives. For example, <code>pattern=**\a</code>
  * and <code>str=b</code> will yield <code>true</code>.
  *
  * @param string $pattern
  * @param string $str
  * @param bool   $isCaseSensitive
  *
  * @internal param The $pattern pattern to match against. Must not be
  *                <code>null</code>.
  * @internal param The $str path to match, as a String. Must not be
  *                <code>null</code>.
  * @internal param Whether $isCaseSensitive or not matching should be performed
  *                        case sensitively.
  *
  * @return bool whether or not a given path matches the start of a given
  *                 pattern up to the first "**".
  */
 public static function matchPatternStart($pattern, $str, $isCaseSensitive = true)
 {
     // When str starts with a DIRECTORY_SEPARATOR, pattern has to start with a
     // DIRECTORY_SEPARATOR.
     // When pattern starts with a DIRECTORY_SEPARATOR, str has to start with a
     // DIRECTORY_SEPARATOR.
     if (StringHelper::startsWith(DIRECTORY_SEPARATOR, $str) !== StringHelper::startsWith(DIRECTORY_SEPARATOR, $pattern)) {
         return false;
     }
     $patDirs = explode(DIRECTORY_SEPARATOR, $pattern);
     $strDirs = explode(DIRECTORY_SEPARATOR, $str);
     $patIdxStart = 0;
     $patIdxEnd = count($patDirs) - 1;
     $strIdxStart = 0;
     $strIdxEnd = count($strDirs) - 1;
     // up to first '**'
     while ($patIdxStart <= $patIdxEnd && $strIdxStart <= $strIdxEnd) {
         $patDir = $patDirs[$patIdxStart];
         if ($patDir == "**") {
             break;
         }
         if (!self::match($patDir, $strDirs[$strIdxStart], $isCaseSensitive)) {
             return false;
         }
         $patIdxStart++;
         $strIdxStart++;
     }
     if ($strIdxStart > $strIdxEnd) {
         // String is exhausted
         return true;
     } elseif ($patIdxStart > $patIdxEnd) {
         // String not exhausted, but pattern is. Failure.
         return false;
     } else {
         // pattern now holds ** while string is not exhausted
         // this will generate false positives but we can live with that.
         return true;
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:61,代码来源:SelectorUtils.php

示例12: runStatements

 /**
  * Read the statements from the .sql file and execute them.
  * Lines starting with '//', '--' or 'REM ' are ignored.
  *
  * Developer note:  must be public in order to be called from
  * sudo-"inner" class PropelSQLExecTransaction.
  *
  * @param      Reader $reader
  * @param      $out Optional output stream.
  * @throws     SQLException
  * @throws     IOException
  */
 public function runStatements(Reader $reader, $out = null)
 {
     $sql = "";
     $line = "";
     $sqlBacklog = "";
     $hasQuery = false;
     $in = new BufferedReader($reader);
     try {
         while (($line = $in->readLine()) !== null) {
             $line = trim($line);
             $line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
             if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
                 continue;
             }
             if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
                 continue;
             }
             if ($sqlBacklog !== "") {
                 $sql = $sqlBacklog;
                 $sqlBacklog = "";
             }
             $sql .= " " . $line . "\n";
             // SQL defines "--" as a comment to EOL
             // and in Oracle it may contain a hint
             // so we cannot just remove it, instead we must end it
             if (strpos($line, "--") !== false) {
                 $sql .= "\n";
             }
             // DELIM_ROW doesn't need this (as far as i can tell)
             if ($this->delimiterType == self::DELIM_NORMAL) {
                 $reg = "#((?:\"(?:\\\\.|[^\"])*\"?)+|'(?:\\\\.|[^'])*'?|" . preg_quote($this->delimiter) . ")#";
                 $sqlParts = preg_split($reg, $sql, 0, PREG_SPLIT_DELIM_CAPTURE);
                 $sqlBacklog = "";
                 foreach ($sqlParts as $sqlPart) {
                     // we always want to append, even if it's a delim (which will be stripped off later)
                     $sqlBacklog .= $sqlPart;
                     // we found a single (not enclosed by ' or ") delimiter, so we can use all stuff before the delim as the actual query
                     if ($sqlPart === $this->delimiter) {
                         $sql = $sqlBacklog;
                         $sqlBacklog = "";
                         $hasQuery = true;
                     }
                 }
             }
             if ($hasQuery || $this->delimiterType == self::DELIM_ROW && $line == $this->delimiter) {
                 // this assumes there is always a delimter on the end of the SQL statement.
                 $sql = StringHelper::substring($sql, 0, strlen($sql) - 1 - strlen($this->delimiter));
                 $this->log("SQL: " . $sql, PROJECT_MSG_VERBOSE);
                 $this->execSQL($sql, $out);
                 $sql = "";
                 $hasQuery = false;
             }
         }
         // Catch any statements not followed by ;
         if ($sql !== "") {
             $this->execSQL($sql, $out);
         }
     } catch (SQLException $e) {
         throw $e;
     }
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:73,代码来源:PropelSQLExec.php

示例13: execute

 /**
  * Setup/initialize Phing environment from commandline args.
  * @param array $args commandline args passed to phing shell.
  * @return void
  */
 public function execute($args)
 {
     self::$definedProps = new Properties();
     $this->searchForThis = null;
     // 1) First handle any options which should always
     // Note: The order in which these are executed is important (if multiple of these options are specified)
     if (in_array('-help', $args) || in_array('-h', $args)) {
         $this->printUsage();
         return;
     }
     if (in_array('-version', $args) || in_array('-v', $args)) {
         $this->printVersion();
         return;
     }
     // 2) Next pull out stand-alone args.
     // Note: The order in which these are executed is important (if multiple of these options are specified)
     if (false !== ($key = array_search('-quiet', $args, true))) {
         self::$msgOutputLevel = Project::MSG_WARN;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-verbose', $args, true))) {
         self::$msgOutputLevel = Project::MSG_VERBOSE;
         unset($args[$key]);
     }
     if (false !== ($key = array_search('-debug', $args, true))) {
         self::$msgOutputLevel = Project::MSG_DEBUG;
         unset($args[$key]);
     }
     // 3) Finally, cycle through to parse remaining args
     //
     $keys = array_keys($args);
     // Use keys and iterate to max(keys) since there may be some gaps
     $max = $keys ? max($keys) : -1;
     for ($i = 0; $i <= $max; $i++) {
         if (!array_key_exists($i, $args)) {
             // skip this argument, since it must have been removed above.
             continue;
         }
         $arg = $args[$i];
         if ($arg == "-logfile") {
             try {
                 // see: http://phing.info/trac/ticket/65
                 if (!isset($args[$i + 1])) {
                     $msg = "You must specify a log file when using the -logfile argument\n";
                     throw new ConfigurationException($msg);
                 } else {
                     $logFile = new PhingFile($args[++$i]);
                     $out = new FileOutputStream($logFile);
                     // overwrite
                     self::setOutputStream($out);
                     self::setErrorStream($out);
                     self::$isLogFileUsed = true;
                 }
             } catch (IOException $ioe) {
                 $msg = "Cannot write on the specified log file. Make sure the path exists and you have write permissions.";
                 throw new ConfigurationException($msg, $ioe);
             }
         } elseif ($arg == "-buildfile" || $arg == "-file" || $arg == "-f") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a buildfile when using the -buildfile argument.";
                 throw new ConfigurationException($msg);
             } else {
                 $this->buildFile = new PhingFile($args[++$i]);
             }
         } elseif ($arg == "-listener") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a listener class when using the -listener argument";
                 throw new ConfigurationException($msg);
             } else {
                 $this->listeners[] = $args[++$i];
             }
         } elseif (StringHelper::startsWith("-D", $arg)) {
             $name = substr($arg, 2);
             $value = null;
             $posEq = strpos($name, "=");
             if ($posEq !== false) {
                 $value = substr($name, $posEq + 1);
                 $name = substr($name, 0, $posEq);
             } elseif ($i < count($args) - 1 && !StringHelper::startsWith("-D", $arg)) {
                 $value = $args[++$i];
             }
             self::$definedProps->setProperty($name, $value);
         } elseif ($arg == "-logger") {
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a classname when using the -logger argument";
                 throw new ConfigurationException($msg);
             } else {
                 $this->loggerClassname = $args[++$i];
             }
         } elseif ($arg == "-inputhandler") {
             if ($this->inputHandlerClassname !== null) {
                 throw new ConfigurationException("Only one input handler class may be specified.");
             }
             if (!isset($args[$i + 1])) {
                 $msg = "You must specify a classname when using the -inputhandler argument";
//.........这里部分代码省略.........
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:101,代码来源:phing.php

示例14: resolveFile

 function resolveFile(PhingFile $f)
 {
     $path = $f->getPath();
     $pl = (int) $f->getPrefixLength();
     if ($pl === 2 && $path[0] === $this->slash) {
         return path;
         // UNC
     }
     if ($pl === 3) {
         return $path;
         // Absolute local
     }
     if ($pl === 0) {
         return (string) ($this->_getUserPath() . $this->slashify($path));
         //Completely relative
     }
     if ($pl === 1) {
         // Drive-relative
         $up = (string) $this->_getUserPath();
         $ud = (string) $this->_getDrive($up);
         if ($ud !== null) {
             return (string) $ud . $path;
         }
         return (string) $up . $path;
         //User dir is a UNC path
     }
     if ($pl === 2) {
         // Directory-relative
         $up = (string) $this->_getUserPath();
         $ud = (string) $this->_getDrive($up);
         if ($ud !== null && StringHelper::startsWith($ud, $path)) {
             return (string) ($up . $this->slashify(substr($path, 2)));
         }
         $drive = (string) $path[0];
         $dir = (string) $this->_getDriveDirectory($drive);
         $np = (string) "";
         if ($dir !== null) {
             /* When resolving a directory-relative path that refers to a
                drive other than the current drive, insist that the caller
                have read permission on the result */
             $p = (string) $drive . (':' . $dir . $this->slashify(substr($path, 2)));
             if (!$this->checkAccess($p, false)) {
                 // FIXME
                 // throw security error
                 die("Can't resolve path {$p}");
             }
             return $p;
         }
         return (string) $drive . ':' . $this->slashify(substr($path, 2));
         //fake it
     }
     throw new Exception("Unresolvable path: " . $path);
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:53,代码来源:Win32FileSystem.php

示例15: _slashify

 /**
  *
  * Enter description here ...
  * @param  PhingFile|string $path
  * @param  boolean          $isDirectory
  * @return string
  */
 public function _slashify($path, $isDirectory)
 {
     $p = (string) $path;
     if (self::$separator !== '/') {
         $p = str_replace(self::$separator, '/', $p);
     }
     if (!StringHelper::startsWith('/', $p)) {
         $p = '/' . $p;
     }
     if (!StringHelper::endsWith('/', $p) && $isDirectory) {
         $p = $p . '/';
     }
     return $p;
 }
开发者ID:kenguest,项目名称:phing,代码行数:21,代码来源:PhingFile.php


注:本文中的StringHelper::startsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。