当前位置: 首页>>代码示例>>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;未经允许,请勿转载。