77 * For the full copyright and license information, please view the LICENSE
88 * file that was distributed with this source code.
99 */
10-
1110namespace SebastianBergmann \Diff ;
1211
1312use SebastianBergmann \Diff \Output \DiffOutputBuilderInterface ;
1918final class Differ
2019{
2120 public const OLD = 0 ;
21+
2222 public const ADDED = 1 ;
23+
2324 public const REMOVED = 2 ;
25+
2426 public const DIFF_LINE_END_WARNING = 3 ;
27+
2528 public const NO_LINE_END_EOF_WARNING = 4 ;
2629
2730 /**
@@ -58,11 +61,8 @@ public function __construct($outputBuilder = null)
5861 /**
5962 * Returns the diff between two arrays or strings as string.
6063 *
61- * @param array|string $from
62- * @param array|string $to
63- * @param null|LongestCommonSubsequenceCalculator $lcs
64- *
65- * @return string
64+ * @param array|string $from
65+ * @param array|string $to
6666 */
6767 public function diff ($ from , $ to , LongestCommonSubsequenceCalculator $ lcs = null ): string
6868 {
@@ -89,8 +89,6 @@ public function diff($from, $to, LongestCommonSubsequenceCalculator $lcs = null)
8989 * @param array|string $from
9090 * @param array|string $to
9191 * @param LongestCommonSubsequenceCalculator $lcs
92- *
93- * @return array
9492 */
9593 public function diffToArray ($ from , $ to , LongestCommonSubsequenceCalculator $ lcs = null ): array
9694 {
@@ -159,8 +157,6 @@ public function diffToArray($from, $to, LongestCommonSubsequenceCalculator $lcs
159157 /**
160158 * Casts variable to string if it is not a string or array.
161159 *
162- * @param mixed $input
163- *
164160 * @return array|string
165161 */
166162 private function normalizeDiffInput ($ input )
@@ -174,22 +170,12 @@ private function normalizeDiffInput($input)
174170
175171 /**
176172 * Checks if input is string, if so it will split it line-by-line.
177- *
178- * @param string $input
179- *
180- * @return array
181173 */
182174 private function splitStringByLines (string $ input ): array
183175 {
184- return \preg_split ('/(.*\R)/ ' , $ input , -1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
176+ return \preg_split ('/(.*\R)/ ' , $ input , -1 , \ PREG_SPLIT_DELIM_CAPTURE | \ PREG_SPLIT_NO_EMPTY );
185177 }
186178
187- /**
188- * @param array $from
189- * @param array $to
190- *
191- * @return LongestCommonSubsequenceCalculator
192- */
193179 private function selectLcsImplementation (array $ from , array $ to ): LongestCommonSubsequenceCalculator
194180 {
195181 // We do not want to use the time-efficient implementation if its memory
@@ -208,24 +194,17 @@ private function selectLcsImplementation(array $from, array $to): LongestCommonS
208194 /**
209195 * Calculates the estimated memory footprint for the DP-based method.
210196 *
211- * @param array $from
212- * @param array $to
213- *
214197 * @return float|int
215198 */
216199 private function calculateEstimatedFootprint (array $ from , array $ to )
217200 {
218- $ itemSize = PHP_INT_SIZE === 4 ? 76 : 144 ;
201+ $ itemSize = \ PHP_INT_SIZE === 4 ? 76 : 144 ;
219202
220203 return $ itemSize * \min (\count ($ from ), \count ($ to )) ** 2 ;
221204 }
222205
223206 /**
224207 * Returns true if line ends don't match in a diff.
225- *
226- * @param array $diff
227- *
228- * @return bool
229208 */
230209 private function detectUnmatchedLineEndings (array $ diff ): bool
231210 {
0 commit comments