Code Duplication    Length = 28-33 lines in 3 locations

src/psalm-refactor.php 1 location

@@ 38-70 (lines=33) @@
35
     *
36
     * @return void
37
     */
38
    function ($arg) use ($valid_long_options, $valid_short_options) {
39
        if (substr($arg, 0, 2) === '--' && $arg !== '--') {
40
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 2));
41
42
            if ($arg_name === 'refactor') {
43
                // valid option for psalm, ignored by psalter
44
                return;
45
            }
46
47
            if (!in_array($arg_name, $valid_long_options)
48
                && !in_array($arg_name . ':', $valid_long_options)
49
                && !in_array($arg_name . '::', $valid_long_options)
50
            ) {
51
                fwrite(
52
                    STDERR,
53
                    'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
54
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
55
                );
56
                exit(1);
57
            }
58
        } elseif (substr($arg, 0, 2) === '-' && $arg !== '-' && $arg !== '--') {
59
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
60
61
            if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
62
                fwrite(
63
                    STDERR,
64
                    'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
65
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
66
                );
67
                exit(1);
68
            }
69
        }
70
    },
71
    $args
72
);
73

src/psalm.php 1 location

@@ 113-140 (lines=28) @@
110
     *
111
     * @return void
112
     */
113
    function ($arg) use ($valid_long_options, $valid_short_options) {
114
        if (substr($arg, 0, 2) === '--' && $arg !== '--') {
115
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 2));
116
117
            if (!in_array($arg_name, $valid_long_options)
118
                && !in_array($arg_name . ':', $valid_long_options)
119
                && !in_array($arg_name . '::', $valid_long_options)
120
            ) {
121
                fwrite(
122
                    STDERR,
123
                    'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
124
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
125
                );
126
                exit(1);
127
            }
128
        } elseif (substr($arg, 0, 1) === '-' && $arg !== '-' && $arg !== '--') {
129
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
130
131
            if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
132
                fwrite(
133
                    STDERR,
134
                    'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
135
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
136
                );
137
                exit(1);
138
            }
139
        }
140
    },
141
    $args
142
);
143

src/psalter.php 1 location

@@ 48-80 (lines=33) @@
45
     *
46
     * @return void
47
     */
48
    function ($arg) use ($valid_long_options, $valid_short_options) {
49
        if (substr($arg, 0, 2) === '--' && $arg !== '--') {
50
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 2));
51
52
            if ($arg_name === 'alter') {
53
                // valid option for psalm, ignored by psalter
54
                return;
55
            }
56
57
            if (!in_array($arg_name, $valid_long_options)
58
                && !in_array($arg_name . ':', $valid_long_options)
59
                && !in_array($arg_name . '::', $valid_long_options)
60
            ) {
61
                fwrite(
62
                    STDERR,
63
                    'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL
64
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
65
                );
66
                exit(1);
67
            }
68
        } elseif (substr($arg, 0, 2) === '-' && $arg !== '-' && $arg !== '--') {
69
            $arg_name = preg_replace('/=.*$/', '', substr($arg, 1));
70
71
            if (!in_array($arg_name, $valid_short_options) && !in_array($arg_name . ':', $valid_short_options)) {
72
                fwrite(
73
                    STDERR,
74
                    'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL
75
                    . 'Type --help to see a list of supported arguments'. PHP_EOL
76
                );
77
                exit(1);
78
            }
79
        }
80
    },
81
    $args
82
);
83