當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Diff::__construct方法代碼示例

本文整理匯總了PHP中Diff::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Diff::__construct方法的具體用法?PHP Diff::__construct怎麽用?PHP Diff::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Diff的用法示例。


在下文中一共展示了Diff::__construct方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * @param string[] $linesBefore
  * @param string[] $linesAfter
  */
 public function __construct($linesBefore, $linesAfter)
 {
     list($wordsBefore, $wordsBeforeStripped) = $this->split($linesBefore);
     list($wordsAfter, $wordsAfterStripped) = $this->split($linesAfter);
     try {
         parent::__construct($wordsBeforeStripped, $wordsAfterStripped);
     } catch (ComplexityException $ex) {
         // Too hard to diff, just show whole paragraph(s) as changed
         $this->edits = [new DiffOpChange($linesBefore, $linesAfter)];
     }
     $xi = $yi = 0;
     $editCount = count($this->edits);
     for ($i = 0; $i < $editCount; $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($wordsBefore, $xi, count($orig));
             $xi += count($orig);
         }
         $closing =& $this->edits[$i]->closing;
         if (is_array($closing)) {
             $closing = array_slice($wordsAfter, $yi, count($closing));
             $yi += count($closing);
         }
     }
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:29,代碼來源:WordLevelDiff.php

示例2: __construct

 /**
  * Constructor.
  *
  * Computes diff between sequences of strings.
  *
  * This can be used to compute things like
  * case-insensitive diffs, or diffs which ignore
  * changes in white-space.
  *
  * @param $from_lines array An array of strings.
  *  (Typically these are lines from a file.)
  *
  * @param $to_lines array An array of strings.
  *
  * @param $mapped_from_lines array This array should
  *  have the same size number of elements as $from_lines.
  *  The elements in $mapped_from_lines and
  *  $mapped_to_lines are what is actually compared
  *  when computing the diff.
  *
  * @param $mapped_to_lines array This array should
  *  have the same number of elements as $to_lines.
  */
 public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 {
     assert(sizeof($from_lines) == sizeof($mapped_from_lines));
     assert(sizeof($to_lines) == sizeof($mapped_to_lines));
     parent::__construct($mapped_from_lines, $mapped_to_lines);
     $xi = $yi = 0;
     for ($i = 0; $i < sizeof($this->edits); $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($from_lines, $xi, sizeof($orig));
             $xi += sizeof($orig);
         }
         $closing =& $this->edits[$i]->closing;
         if (is_array($closing)) {
             $closing = array_slice($to_lines, $yi, sizeof($closing));
             $yi += sizeof($closing);
         }
     }
 }
開發者ID:sarahwillem,項目名稱:OD8,代碼行數:42,代碼來源:MappedDiff.php

示例3: __construct

 /**
  * @param string[] $linesBefore
  * @param string[] $linesAfter
  */
 public function __construct($linesBefore, $linesAfter)
 {
     list($wordsBefore, $wordsBeforeStripped) = $this->split($linesBefore);
     list($wordsAfter, $wordsAfterStripped) = $this->split($linesAfter);
     parent::__construct($wordsBeforeStripped, $wordsAfterStripped);
     $xi = $yi = 0;
     $editCount = count($this->edits);
     for ($i = 0; $i < $editCount; $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($wordsBefore, $xi, count($orig));
             $xi += count($orig);
         }
         $closing =& $this->edits[$i]->closing;
         if (is_array($closing)) {
             $closing = array_slice($wordsAfter, $yi, count($closing));
             $yi += count($closing);
         }
     }
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:24,代碼來源:WordLevelDiff.php

示例4: __construct

 /**
  * Constructor.
  *
  * Computes diff between sequences of strings.
  *
  * This can be used to compute things like
  * case-insensitve diffs, or diffs which ignore
  * changes in white-space.
  *
  * @param string[] $from_lines An array of strings.
  *   Typically these are lines from a file.
  * @param string[] $to_lines An array of strings.
  * @param string[] $mapped_from_lines This array should
  *   have the same size number of elements as $from_lines.
  *   The elements in $mapped_from_lines and
  *   $mapped_to_lines are what is actually compared
  *   when computing the diff.
  * @param string[] $mapped_to_lines This array should
  *   have the same number of elements as $to_lines.
  */
 public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 {
     wfProfileIn(__METHOD__);
     assert('count( $from_lines ) == count( $mapped_from_lines )');
     assert('count( $to_lines ) == count( $mapped_to_lines )');
     parent::__construct($mapped_from_lines, $mapped_to_lines);
     $xi = $yi = 0;
     $editCount = count($this->edits);
     for ($i = 0; $i < $editCount; $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($from_lines, $xi, count($orig));
             $xi += count($orig);
         }
         $closing =& $this->edits[$i]->closing;
         if (is_array($closing)) {
             $closing = array_slice($to_lines, $yi, count($closing));
             $yi += count($closing);
         }
     }
     wfProfileOut(__METHOD__);
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:42,代碼來源:DairikiDiff.php

示例5: __construct

 public function __construct(array $operations = array())
 {
     parent::__construct($operations, true);
 }
開發者ID:SRMSE,項目名稱:cron-wikidata,代碼行數:4,代碼來源:MapDiff.php

示例6: __construct

 /**
  * Constructor.
  *
  * Computes diff between sequences of strings.
  *
  * This can be used to compute things like
  * case-insensitve diffs, or diffs which ignore
  * changes in white-space.
  *
  * @param $from_lines array An array of strings.
  *  (Typically these are lines from a file.)
  *
  * @param $to_lines array An array of strings.
  *
  * @param $mapped_from_lines array This array should
  *  have the same size number of elements as $from_lines.
  *  The elements in $mapped_from_lines and
  *  $mapped_to_lines are what is actually compared
  *  when computing the diff.
  *
  * @param $mapped_to_lines array This array should
  *  have the same number of elements as $to_lines.
  */
 public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines)
 {
     assert(sizeof($from_lines) == sizeof($mapped_from_lines));
     assert(sizeof($to_lines) == sizeof($mapped_to_lines));
     parent::__construct($mapped_from_lines, $mapped_to_lines);
     $xi = $yi = 0;
     // Optimizing loop invariants:
     // http://phplens.com/lens/php-book/optimizing-debugging-php.php
     for ($i = 0, $max = sizeof($this->edits); $i < $max; $i++) {
         $orig =& $this->edits[$i]->orig;
         if (is_array($orig)) {
             $orig = array_slice($from_lines, $xi, sizeof($orig));
             $xi += sizeof($orig);
         }
         $final =& $this->edits[$i]->final;
         if (is_array($final)) {
             $final = array_slice($to_lines, $yi, sizeof($final));
             $yi += sizeof($final);
         }
     }
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:44,代碼來源:Diff.php


注:本文中的Diff::__construct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。