Passed
Push — master ( 3f3f21...970c56 )
by Gaetano
07:47
created

pakefile.php (38 issues)

1
<?php
2
/**
3
 * Makefile for phpxmlrpc library.
4
 * To be used with the Pake tool: https://github.com/indeyets/pake/wiki
5
 *
6
 * @copyright (c) 2015-2021 G. Giunta
7
 *
8
 * @todo !important allow user to specify location of docbook xslt instead of the one installed via composer
9
 */
10
11
namespace PhpXmlRpc {
12
13
class Builder
14
{
15
    protected static $buildDir = 'build';
16
    protected static $libVersion;
17
    protected static $tools = array(
18
        'asciidoctor' => 'asciidoctor',
19
        'fop' => 'fop',
20
        'php' => 'php',
21
        'zip' => 'zip',
22
    );
23
    protected static $options = array(
24
        'repo' => 'https://github.com/gggeek/phpxmlrpc',
25
        'branch' => 'master',
26
        'workspace' => null
27
    );
28
29
    public static function libVersion()
30
    {
31
        if (self::$libVersion == null)
32
            throw new \Exception('Missing library version argument');
33
        return self::$libVersion;
34
    }
35
36
    public static function buildDir()
37
    {
38
        return self::$buildDir;
39
    }
40
41
    public static function workspaceDir()
42
    {
43
        return self::option('workspace') != '' ? self::option('workspace') : self::buildDir().'/workspace';
44
    }
45
46
    public static function toolsDir()
47
    {
48
        return self::buildDir().'/tools';
49
    }
50
51
    /// most likely things will break if this one is moved outside of BuildDir
52
    public static function distDir()
53
    {
54
        return self::buildDir().'/xmlrpc-'.self::libVersion();
55
    }
56
57
    /// these will be generated in BuildDir
58
    public static function distFiles()
59
    {
60
        return array(
61
            'xmlrpc-'.self::libVersion().'.tar.gz',
62
            'xmlrpc-'.self::libVersion().'.zip',
63
        );
64
    }
65
66
    public static function getOpts($args=array(), $cliOpts=array())
67
    {
68
        if (count($args) > 0)
69
        //    throw new \Exception('Missing library version argument');
70
            self::$libVersion = $args[0];
71
72
        foreach (self::$tools as $name => $binary) {
73
            if (isset($cliOpts[$name])) {
74
                self::$tools[$name] = $cliOpts[$name];
75
            }
76
        }
77
78
        foreach (self::$options as $name => $value) {
79
            if (isset($cliOpts[$name])) {
80
                self::$options[$name] = $cliOpts[$name];
81
            }
82
        }
83
84
        //pake_echo('---'.self::$libVersion.'---');
85
    }
86
87
    /**
88
     * @param string $name
89
     * @return string
90
     */
91
    public static function tool($name)
92
    {
93
        return self::$tools[$name];
94
    }
95
96
    /**
97
     * @param string $name
98
     * @return string
99
     */
100
    public static function option($name)
101
    {
102
        return self::$options[$name];
103
    }
104
105
    /**
106
     * @param string $inFile
107
     * @param string $xssFile
108
     * @param string $outFileOrDir
109
     * @throws \Exception
110
     */
111
    public static function applyXslt($inFile, $xssFile, $outFileOrDir)
112
    {
113
        if (!file_exists($inFile)) {
114
            throw new \Exception("File $inFile cannot be found");
115
        }
116
        if (!file_exists($xssFile)) {
117
            throw new \Exception("File $xssFile cannot be found");
118
        }
119
120
        // Load the XML source
121
        $xml = new \DOMDocument();
122
        $xml->load($inFile);
123
        $xsl = new \DOMDocument();
124
        $xsl->load($xssFile);
125
126
        // Configure the transformer
127
        $processor = new \XSLTProcessor();
128
        if (version_compare(PHP_VERSION, '5.4', "<")) {
129
            if (defined('XSL_SECPREF_WRITE_FILE')) {
130
                ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
131
            }
132
        } else {
133
            // the php online docs only mention setSecurityPrefs, but somehow some installs have setSecurityPreferences...
134
            if (method_exists('XSLTProcessor', 'setSecurityPrefs')) {
135
                $processor->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
136
            } else {
137
                $processor->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
0 ignored issues
show
The method setSecurityPreferences() does not exist on XSLTProcessor. Did you maybe mean setSecurityPrefs()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

137
                $processor->/** @scrutinizer ignore-call */ 
138
                            setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
138
            }
139
        }
140
        $processor->importStyleSheet($xsl); // attach the xsl rules
141
142
        if (is_dir($outFileOrDir)) {
143
            if (!$processor->setParameter('', 'base.dir', realpath($outFileOrDir))) {
144
                echo "setting param base.dir KO\n";
145
            }
146
        }
147
148
        $out = $processor->transformToXML($xml);
149
150
        if (!is_dir($outFileOrDir)) {
151
            file_put_contents($outFileOrDir, $out);
152
        }
153
    }
154
155
    public static function highlightPhpInHtml($content)
156
    {
157
        $startTag = '<pre class="programlisting">';
158
        $endTag = '</pre>';
159
160
        //$content = file_get_contents($inFile);
161
        $last = 0;
162
        $out = '';
163
        while (($start = strpos($content, $startTag, $last)) !== false) {
164
            $end = strpos($content, $endTag, $start);
165
            $code = substr($content, $start + strlen($startTag), $end - $start - strlen($startTag));
166
            if ($code[strlen($code) - 1] == "\n") {
167
                $code = substr($code, 0, -1);
168
            }
169
170
            $code = str_replace(array('&gt;', '&lt;'), array('>', '<'), $code);
171
            $code = highlight_string('<?php ' . $code, true);
172
            $code = str_replace('<span style="color: #0000BB">&lt;?php&nbsp;<br />', '<span style="color: #0000BB">', $code);
173
174
            $out = $out . substr($content, $last, $start + strlen($startTag) - $last) . $code . $endTag;
175
            $last = $end + strlen($endTag);
176
        }
177
        $out .= substr($content, $last, strlen($content));
178
179
        return $out;
180
    }
181
}
182
183
}
184
185
namespace {
186
187
use PhpXmlRpc\Builder;
188
189
function run_default($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

189
function run_default($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

189
function run_default(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

189
function run_default($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
190
{
191
    echo "Syntax: pake {\$pake-options} \$task \$lib-version [\$git-tag] {\$task-options}\n";
192
    echo "\n";
193
    echo "  Run 'pake help' to list all pake options\n";
194
    echo "  Run 'pake -T' to list available tasks\n";
195
    echo "  Run 'pake -P' to list all available tasks (including hidden ones) and their dependencies\n";
196
    echo "\n";
197
    echo "  Task options:\n";
198
    echo "      --repo=REPO      URL of the source repository to clone. Defaults to the github repo.\n";
199
    echo "      --branch=BRANCH  The git branch to build from.\n";
200
    echo "      --asciidoctor=ASCIIDOCTOR Location of the asciidoctor command-line tool\n";
201
    echo "      --fop=FOP        Location of the apache fop command-line tool\n";
202
    echo "      --php=PHP        Location of the php command-line interpreter\n";
203
    echo "      --zip=ZIP        Location of the zip tool\n";
204
}
205
206
function run_getopts($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

206
function run_getopts(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
207
{
208
    Builder::getOpts($args, $cliOpts);
209
}
210
211
/**
212
 * Downloads source code in the build workspace directory, optionally checking out the given branch/tag
213
 * @todo allow using current installation as source, bypassing git clone in workspace - at least for doc generation
214
 */
215
function run_init($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

215
function run_init($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

215
function run_init($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

215
function run_init(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
216
{
217
    // download the current version into the workspace
218
    $targetDir = Builder::workspaceDir();
219
220
    // check if workspace exists and is not already set to the correct repo
221
    if (is_dir($targetDir) && pakeGit::isRepository($targetDir)) {
0 ignored issues
show
The type pakeGit was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
222
        $repo = new pakeGit($targetDir);
223
        $remotes = $repo->remotes();
224
        if (trim($remotes['origin']['fetch']) != Builder::option('repo')) {
225
            throw new Exception("Directory '$targetDir' exists and is not linked to correct git repo");
226
        }
227
228
        /// @todo should we not just fetch instead?
229
        $repo->pull();
230
    } else {
231
        pake_mkdirs(dirname($targetDir));
0 ignored issues
show
The function pake_mkdirs was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

231
        /** @scrutinizer ignore-call */ 
232
        pake_mkdirs(dirname($targetDir));
Loading history...
232
        $repo = pakeGit::clone_repository(Builder::option('repo'), Builder::workspaceDir());
233
    }
234
235
    $repo->checkout(Builder::option('branch'));
236
}
237
238
/**
239
 * Runs all the build steps.
240
 *
241
 * (does nothing by itself, as all the steps are managed via task dependencies)
242
 */
243
function run_build($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

243
function run_build($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

243
function run_build(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

243
function run_build($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
244
{
245
}
246
247
function run_clean_doc()
248
{
249
    pake_remove_dir(Builder::workspaceDir().'/doc/api');
0 ignored issues
show
The function pake_remove_dir was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

249
    /** @scrutinizer ignore-call */ 
250
    pake_remove_dir(Builder::workspaceDir().'/doc/api');
Loading history...
250
    $finder = pakeFinder::type('file')->name('*.html');
0 ignored issues
show
The type pakeFinder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
251
    pake_remove($finder, Builder::workspaceDir().'/doc/manual');
0 ignored issues
show
The function pake_remove was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

251
    /** @scrutinizer ignore-call */ 
252
    pake_remove($finder, Builder::workspaceDir().'/doc/manual');
Loading history...
252
    $finder = pakeFinder::type('file')->name('*.xml');
253
    pake_remove($finder, Builder::workspaceDir().'/doc/manual');
254
}
255
256
/**
257
 * Generates documentation in all formats
258
 */
259
function run_doc($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

259
function run_doc(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

259
function run_doc($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

259
function run_doc($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
260
{
261
    // in
262
    $srcDir = Builder::workspaceDir();
263
    // out
264
    $docDir = Builder::workspaceDir().'/doc';
265
266
    // API docs
267
268
    // from phpdoc comments using phpdocumentor
269
    $cmd = Builder::tool('php');
270
    pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/phpdoc run --cache-folder ".Builder::buildDir()."/.phpdoc -d ".$srcDir.'/src'." -t ".$docDir.'/api --title PHP-XMLRPC');
0 ignored issues
show
The function pake_sh was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

270
    /** @scrutinizer ignore-call */ 
271
    pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/phpdoc run --cache-folder ".Builder::buildDir()."/.phpdoc -d ".$srcDir.'/src'." -t ".$docDir.'/api --title PHP-XMLRPC');
Loading history...
271
272
    // from phpdoc comments using Sami
273
    // deprecated on 2021/12, as Sami is abandonware
274
    /*$samiConfig = <<<EOT
275
<?php
276
    \$iterator = Symfony\Component\Finder\Finder::create()
277
      ->files()
278
      ->exclude('debugger')
279
      ->exclude('demo')
280
      ->exclude('doc')
281
      ->exclude('tests')
282
      ->in('./build/workspace');
283
    return new Sami\Sami(\$iterator, array(
284
        'title' => 'PHP-XMLRPC',
285
        'build_dir' => 'build/workspace/doc/api',
286
        'cache_dir' => 'build/cache',
287
    ));
288
EOT;
289
    file_put_contents('build/sami_config.php', $samiConfig);
290
    $cmd = Builder::tool('php');
291
    pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/sami.php update -vvv build/sami_config.php");*/
292
293
    // User Manual
294
295
    // html (single file) from asciidoc
296
    $cmd = Builder::tool('asciidoctor');
297
    pake_sh("$cmd -d book -o $docDir/manual/phpxmlrpc_manual.html $srcDir/doc/manual/phpxmlrpc_manual.adoc");
298
299
    // then docbook from asciidoc
300
    /// @todo create phpxmlrpc_manual.xml with the good version number
301
    /// @todo create phpxmlrpc_manual.xml with the date set to the one of last commit (or today?)
302
    pake_sh("$cmd -d book -b docbook -o $docDir/manual/phpxmlrpc_manual.xml $srcDir/doc/manual/phpxmlrpc_manual.adoc");
303
304
    # Other tools for docbook...
305
    #
306
    # jade cmd yet to be rebuilt, starting from xml file and putting output in ./out dir, e.g.
307
    #	jade -t xml -d custom.dsl xmlrpc_php.xml
308
    #
309
    # convertdoc command for xmlmind xxe editor
310
    #	convertdoc docb.toHTML xmlrpc_php.xml -u out
311
    #
312
    # saxon + xerces xml parser + saxon extensions + xslthl: adds a little syntax highlighting
313
    # (bold and italics only, no color) for php source examples...
314
    #	java \
315
    #	-classpath c:\programmi\saxon\saxon.jar\;c:\programmi\saxon\xslthl.jar\;c:\programmi\xerces\xercesImpl.jar\;C:\htdocs\xmlrpc_cvs\docbook-xsl\extensions\saxon65.jar \
316
    #	-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
317
    #	-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
318
    #	-Dxslthl.config=file:///c:/htdocs/xmlrpc_cvs/docbook-xsl/highlighting/xslthl-config.xml \
319
    #	com.icl.saxon.StyleSheet -o xmlrpc_php.fo.xml xmlrpc_php.xml custom.fo.xsl use.extensions=1
320
321
    // HTML (multiple files) from docbook - discontinued, as we use the nicer-looking html gotten from asciidoc
322
    /*Builder::applyXslt($docDir.'/manual/phpxmlrpc_manual.xml', $docDir.'/build/custom.xsl', $docDir.'/manual');
323
    // post process html files to highlight php code samples
324
    foreach(pakeFinder::type('file')->name('*.html')->in($docDir.'/manual') as $file)
325
    {
326
        file_put_contents($file, Builder::highlightPhpInHtml(file_get_contents($file)));
327
    }*/
328
329
    // PDF file from docbook
330
331
    // convert to fo and then to pdf using apache fop
332
    Builder::applyXslt($docDir.'/manual/phpxmlrpc_manual.xml', $docDir.'/build/custom.fo.xsl', $docDir.'/manual/phpxmlrpc_manual.fo.xml');
333
    $cmd = Builder::tool('fop');
334
    pake_sh("$cmd $docDir/manual/phpxmlrpc_manual.fo.xml $docDir/manual/phpxmlrpc_manual.pdf");
335
336
    // cleanup
337
    unlink($docDir.'/manual/phpxmlrpc_manual.xml');
338
    unlink($docDir.'/manual/phpxmlrpc_manual.fo.xml');
339
}
340
341
function run_clean_dist()
342
{
343
    pake_remove_dir(Builder::distDir());
0 ignored issues
show
The function pake_remove_dir was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

343
    /** @scrutinizer ignore-call */ 
344
    pake_remove_dir(Builder::distDir());
Loading history...
344
    $finder = pakeFinder::type('file')->name(Builder::distFiles());
345
    pake_remove($finder, Builder::buildDir());
0 ignored issues
show
The function pake_remove was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

345
    /** @scrutinizer ignore-call */ 
346
    pake_remove($finder, Builder::buildDir());
Loading history...
346
}
347
348
/**
349
 * Creates the tarballs for a release
350
 */
351
function run_dist($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

351
function run_dist(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

351
function run_dist($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

351
function run_dist($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
352
{
353
    // copy workspace dir into dist dir, without git
354
    pake_mkdirs(Builder::distDir());
0 ignored issues
show
The function pake_mkdirs was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

354
    /** @scrutinizer ignore-call */ 
355
    pake_mkdirs(Builder::distDir());
Loading history...
355
    $finder = pakeFinder::type('any')->ignore_version_control();
356
    /// @todo make sure we don't recurse - avoid 'build' dir
357
    pake_mirror($finder, realpath(Builder::workspaceDir()), realpath(Builder::distDir()));
0 ignored issues
show
The function pake_mirror was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

357
    /** @scrutinizer ignore-call */ 
358
    pake_mirror($finder, realpath(Builder::workspaceDir()), realpath(Builder::distDir()));
Loading history...
358
359
    // @todo remove unwanted files from dist dir - files and dirs from .gitattributes
360
361
    // also: do we still need to run dos2unix?
362
363
    // create tarballs
364
    $cwd = getcwd();
365
    chdir(dirname(Builder::distDir()));
366
    foreach(Builder::distFiles() as $distFile) {
367
        // php can not really create good zip files via phar: they are not compressed!
368
        if (substr($distFile, -4) == '.zip') {
369
            $cmd = Builder::tool('zip');
370
            $extra = '-9 -r';
371
            pake_sh("$cmd $distFile $extra ".basename(Builder::distDir()));
0 ignored issues
show
The function pake_sh was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

371
            /** @scrutinizer ignore-call */ 
372
            pake_sh("$cmd $distFile $extra ".basename(Builder::distDir()));
Loading history...
372
        }
373
        else {
374
            $finder = pakeFinder::type('any')->pattern(basename(Builder::distDir()).'/**');
375
            // see https://bugs.php.net/bug.php?id=58852
376
            $pharFile = str_replace(Builder::libVersion(), '_LIBVERSION_', $distFile);
377
            pakeArchive::createArchive($finder, '.', $pharFile);
0 ignored issues
show
The type pakeArchive was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
378
            rename($pharFile, $distFile);
379
        }
380
    }
381
    chdir($cwd);
382
}
383
384
function run_clean_workspace($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

384
function run_clean_workspace($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

384
function run_clean_workspace(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

384
function run_clean_workspace($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
385
{
386
    pake_remove_dir(Builder::workspaceDir());
0 ignored issues
show
The function pake_remove_dir was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

386
    /** @scrutinizer ignore-call */ 
387
    pake_remove_dir(Builder::workspaceDir());
Loading history...
387
}
388
389
/**
390
 * Cleans up the whole build directory
391
 * @todo 'make clean' usually just removes the results of the build, distclean removes all but sources
392
 */
393
function run_clean($task=null, $args=array(), $cliOpts=array())
0 ignored issues
show
The parameter $task is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

393
function run_clean(/** @scrutinizer ignore-unused */ $task=null, $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $cliOpts is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

393
function run_clean($task=null, $args=array(), /** @scrutinizer ignore-unused */ $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

393
function run_clean($task=null, /** @scrutinizer ignore-unused */ $args=array(), $cliOpts=array())

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
394
{
395
    pake_remove_dir(Builder::buildDir());
0 ignored issues
show
The function pake_remove_dir was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

395
    /** @scrutinizer ignore-call */ 
396
    pake_remove_dir(Builder::buildDir());
Loading history...
396
}
397
398
// helper task: display help text
399
pake_task( 'default' );
0 ignored issues
show
The function pake_task was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

399
/** @scrutinizer ignore-call */ 
400
pake_task( 'default' );
Loading history...
400
// internal task: parse cli options
401
pake_task('getopts');
402
pake_task('init', 'getopts');
403
pake_task('doc', 'getopts', 'init', 'clean-doc');
404
pake_task('build', 'getopts', 'init', 'doc');
405
pake_task('dist', 'getopts', 'init', 'build', 'clean-dist');
406
pake_task('clean-doc', 'getopts');
407
pake_task('clean-dist', 'getopts');
408
pake_task('clean-workspace', 'getopts');
409
pake_task('clean', 'getopts');
410
411
}
412