File: type3_clone.php

package info (click to toggle)
phpcpd 7.0.0~git20230110-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 504 kB
  • sloc: php: 2,284; xml: 132; makefile: 21
file content (40 lines) | stat: -rw-r--r-- 646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * Purpose is to demonstrate detection of Type 3 clone, which contains small changes.
 *
 * ./phpcpd --min-tokens 1 --min-lines 5 tests/fixture/type3_clone.php
 * ./phpcpd --algorithm suffixtree --min-tokens 5 --min-lines 5 --head-equality 2 tests/fixture/type3_clone.php
 */

function foo()
{
    $a = 10;
    $b = 20;
    if ($a > $b) {
        return 'foo';
    } else {
        return 'bar';
    }
}

function bar()
{
    $a = 10;
    $b = 20;
    if ($a > $b) {
    } else {
        return 'bar';
    }
}

function bar()
{
    $a = 10;
    $b = '20';
    if ($a) {
        return 'foo';
    } else {
        return 'bar';
    }
}