Passed
Push — master ( 119e27...c32e95 )
by Gaetano
08:58
created

pakefile.php (37 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
    /// @todo allow this to be set via an option
37
    public static function buildDir()
38
    {
39
        return self::$buildDir;
40
    }
41
42
    public static function workspaceDir()
43
    {
44
        return self::option('workspace') != '' ? self::option('workspace') : self::buildDir().'/workspace';
45
    }
46
47
    public static function toolsDir()
48
    {
49
        return self::buildDir().'/tools';
50
    }
51
52
    // most likely things will break if this one is moved outside the BuildDir
53
    public static function distDir()
54
    {
55
        return self::buildDir().'/xmlrpc-'.self::libVersion();
56
    }
57
58
    // these will be generated in BuildDir
59
    public static function distFiles()
60
    {
61
        return array(
62
            'xmlrpc-'.self::libVersion().'.tar.gz',
63
            'xmlrpc-'.self::libVersion().'.zip',
64
        );
65
    }
66
67
    public static function getOpts($args=array(), $cliOpts=array())
68
    {
69
        if (count($args) > 0)
70
        //    throw new \Exception('Missing library version argument');
71
            self::$libVersion = $args[0];
72
73
        foreach (self::$tools as $name => $binary) {
74
            if (isset($cliOpts[$name])) {
75
                self::$tools[$name] = $cliOpts[$name];
76
            }
77
        }
78
79
        foreach (self::$options as $name => $value) {
80
            if (isset($cliOpts[$name])) {
81
                self::$options[$name] = $cliOpts[$name];
82
            }
83
        }
84
85
        //pake_echo('---'.self::$libVersion.'---');
86
    }
87
88
    /**
89
     * @param string $name
90
     * @return string
91
     */
92
    public static function tool($name)
93
    {
94
        return self::$tools[$name];
95
    }
96
97
    /**
98
     * @param string $name
99
     * @return string
100
     */
101
    public static function option($name)
102
    {
103
        return self::$options[$name];
104
    }
105
106
    /**
107
     * @param string $inFile
108
     * @param string $xssFile
109
     * @param string $outFileOrDir
110
     * @throws \Exception
111
     */
112
    public static function applyXslt($inFile, $xssFile, $outFileOrDir)
113
    {
114
        if (!file_exists($inFile)) {
115
            throw new \Exception("File $inFile cannot be found");
116
        }
117
        if (!file_exists($xssFile)) {
118
            throw new \Exception("File $xssFile cannot be found");
119
        }
120
121
        $docbookFoXslPath = realpath(Builder::buildDir().'/tools/vendor/docbook/docbook-xsl/fo/docbook.xsl');
122
        $docbookChunkXslPath = realpath(Builder::buildDir().'/tools/vendor/docbook/docbook-xsl/xhtml/chunk.xsl');
123
        file_put_contents(
124
            $xssFile,
125
            str_replace(
126
                array('%fo-docbook.xsl%', '%docbook-chunk.xsl%'),
127
                array($docbookFoXslPath, $docbookChunkXslPath),
128
                file_get_contents($xssFile)
129
            )
130
        );
131
132
        // Load the XML source
133
        $xml = new \DOMDocument();
134
        $xml->load($inFile);
135
        $xsl = new \DOMDocument();
136
        $xsl->load($xssFile);
137
138
        // Configure the transformer
139
        $processor = new \XSLTProcessor();
140
        if (version_compare(PHP_VERSION, '5.4', "<")) {
141
            if (defined('XSL_SECPREF_WRITE_FILE')) {
142
                ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
143
            }
144
        } else {
145
            // the php online docs only mention setSecurityPrefs, but somehow some installs have setSecurityPreferences...
146
            if (method_exists('XSLTProcessor', 'setSecurityPrefs')) {
147
                $processor->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
148
            } else {
149
                $processor->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
150
            }
151
        }
152
        $processor->importStyleSheet($xsl); // attach the xsl rules
153
154
        if (is_dir($outFileOrDir)) {
155
            if (!$processor->setParameter('', 'base.dir', realpath($outFileOrDir))) {
156
                echo "setting param base.dir KO\n";
157
            }
158
        }
159
160
        $out = $processor->transformToXML($xml);
161
162
        if (!is_dir($outFileOrDir)) {
163
            file_put_contents($outFileOrDir, $out);
164
        }
165
    }
166
167
    public static function highlightPhpInHtml($content)
168
    {
169
        $startTag = '<pre class="programlisting">';
170
        $endTag = '</pre>';
171
172
        //$content = file_get_contents($inFile);
173
        $last = 0;
174
        $out = '';
175
        while (($start = strpos($content, $startTag, $last)) !== false) {
176
            $end = strpos($content, $endTag, $start);
177
            $code = substr($content, $start + strlen($startTag), $end - $start - strlen($startTag));
178
            if ($code[strlen($code) - 1] == "\n") {
179
                $code = substr($code, 0, -1);
180
            }
181
182
            $code = str_replace(array('&gt;', '&lt;'), array('>', '<'), $code);
183
            $code = highlight_string('<?php ' . $code, true);
184
            $code = str_replace('<span style="color: #0000BB">&lt;?php&nbsp;<br />', '<span style="color: #0000BB">', $code);
185
186
            $out = $out . substr($content, $last, $start + strlen($startTag) - $last) . $code . $endTag;
187
            $last = $end + strlen($endTag);
188
        }
189
        $out .= substr($content, $last, strlen($content));
190
191
        return $out;
192
    }
193
}
194
195
}
196
197
namespace {
198
199
use PhpXmlRpc\Builder;
200
201
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

201
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 $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

201
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...
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

201
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...
202
{
203
    echo "Syntax: pake {\$pake-options} \$task \$lib-version [\$git-tag] {\$task-options}\n";
204
    echo "\n";
205
    echo "  Run 'pake help' to list all pake options\n";
206
    echo "  Run 'pake -T' to list available tasks\n";
207
    echo "  Run 'pake -P' to list all available tasks (including hidden ones) and their dependencies\n";
208
    echo "\n";
209
    echo "  Task options:\n";
210
    echo "      --repo=REPO      URL of the source repository to clone. Defaults to the official github repo.\n";
211
    echo "      --branch=BRANCH  The git branch to build from. Defaults to 'master'\n";
212
    echo "      --workspace=DIR   The dir where to check out source code. Defaults to build/workspace\n";
213
    echo "      --asciidoctor=ASCIIDOCTOR Location of the asciidoctor command-line tool\n";
214
    echo "      --fop=FOP        Location of the apache fop command-line tool\n";
215
    echo "      --php=PHP        Location of the php command-line interpreter\n";
216
    echo "      --zip=ZIP        Location of the zip tool\n";
217
}
218
219
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

219
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...
220
{
221
    Builder::getOpts($args, $cliOpts);
222
}
223
224
/**
225
 * Downloads source code in the build workspace directory, optionally checking out the given branch/tag
226
 * @todo allow using current installation / dir as source, bypassing git clone in workspace - at least for doc generation
227
 */
228
function run_init($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

228
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...
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

228
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 $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

228
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...
229
{
230
    // download the current version into the workspace
231
    $targetDir = Builder::workspaceDir();
232
233
    // check if workspace exists and is not already set to the correct repo
234
    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...
235
        $repo = new pakeGit($targetDir);
236
        $remotes = $repo->remotes();
237
        if (trim($remotes['origin']['fetch']) != Builder::option('repo')) {
238
            throw new Exception("Directory '$targetDir' exists and is not linked to correct git repo");
239
        }
240
241
        /// @todo we should just fetch if we are checking out a tag, but pull if we are checking out a branch.
242
        ///       Also, we should only pull after having checked out the correct branch...
243
        $repo->pull();
244
    } else {
245
        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

245
        /** @scrutinizer ignore-call */ 
246
        pake_mkdirs(dirname($targetDir));
Loading history...
246
        $repo = pakeGit::clone_repository(Builder::option('repo'), Builder::workspaceDir());
247
    }
248
249
    $repo->checkout(Builder::option('branch'));
250
}
251
252
/**
253
 * Runs all the build steps.
254
 *
255
 * (does nothing by itself, as all the steps are managed via task dependencies)
256
 */
257
function run_build($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

257
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...
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

257
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 $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

257
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...
258
{
259
}
260
261
function run_clean_doc()
262
{
263
    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

263
    /** @scrutinizer ignore-call */ 
264
    pake_remove_dir(Builder::workspaceDir().'/doc/api');
Loading history...
264
    $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...
265
    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

265
    /** @scrutinizer ignore-call */ 
266
    pake_remove($finder, Builder::workspaceDir().'/doc/manual');
Loading history...
266
    $finder = pakeFinder::type('file')->name('*.xml');
267
    pake_remove($finder, Builder::workspaceDir().'/doc/manual');
268
}
269
270
/**
271
 * Generates documentation in all formats
272
 */
273
function run_doc($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

273
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

273
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...
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

273
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...
274
{
275
    // in
276
    $srcDir = Builder::workspaceDir();
277
    // out
278
    $docDir = Builder::workspaceDir().'/doc';
279
280
    // API docs
281
282
    // from phpdoc comments using phpdocumentor
283
    $cmd = Builder::tool('php');
284
    pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/phpdoc run --cache-folder ".Builder::buildDir()."/.phpdoc -d ".$srcDir.'/src'." -t ".$docDir.'/api --title PHP-XMLRPC --defaultpackagename PHPXMLRPC');
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

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

356
    /** @scrutinizer ignore-call */ 
357
    pake_remove_dir(Builder::distDir());
Loading history...
357
    $finder = pakeFinder::type('file')->name(Builder::distFiles());
358
    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

358
    /** @scrutinizer ignore-call */ 
359
    pake_remove($finder, Builder::buildDir());
Loading history...
359
}
360
361
/**
362
 * Creates the tarballs for a release
363
 */
364
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

364
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

364
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

364
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...
365
{
366
    // copy workspace dir into dist dir, without git
367
    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

367
    /** @scrutinizer ignore-call */ 
368
    pake_mkdirs(Builder::distDir());
Loading history...
368
    $finder = pakeFinder::type('any')->ignore_version_control();
369
    /// @todo make sure we don't recurse - avoid 'build' dir
370
    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

370
    /** @scrutinizer ignore-call */ 
371
    pake_mirror($finder, realpath(Builder::workspaceDir()), realpath(Builder::distDir()));
Loading history...
371
372
    // @todo remove unwanted files from dist dir - files and dirs from .gitattributes
373
374
    // also: do we still need to run dos2unix?
375
376
    // create tarballs
377
    $cwd = getcwd();
378
    chdir(dirname(Builder::distDir()));
379
    foreach(Builder::distFiles() as $distFile) {
380
        // php can not really create good zip files via phar: they are not compressed!
381
        if (substr($distFile, -4) == '.zip') {
382
            $cmd = Builder::tool('zip');
383
            $extra = '-9 -r';
384
            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

384
            /** @scrutinizer ignore-call */ 
385
            pake_sh("$cmd $distFile $extra ".basename(Builder::distDir()));
Loading history...
385
        }
386
        else {
387
            $finder = pakeFinder::type('any')->pattern(basename(Builder::distDir()).'/**');
388
            // see https://bugs.php.net/bug.php?id=58852
389
            $pharFile = str_replace(Builder::libVersion(), '_LIBVERSION_', $distFile);
390
            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...
391
            rename($pharFile, $distFile);
392
        }
393
    }
394
    chdir($cwd);
395
}
396
397
function run_clean_workspace($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

397
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...
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

397
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 $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

397
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...
398
{
399
    if (realpath(__DIR__) === realpath(Builder::workspaceDir())) {
400
        throw new \Exception("Can not remove workspace dir, as it is where pakefile is located!");
401
    }
402
    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

402
    /** @scrutinizer ignore-call */ 
403
    pake_remove_dir(Builder::workspaceDir());
Loading history...
403
}
404
405
/**
406
 * Cleans up the whole build directory
407
 * @todo 'make clean' usually just removes the results of the build, distclean removes all but sources
408
 */
409
function run_clean($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

409
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 $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

409
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 $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

409
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...
410
{
411
    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

411
    /** @scrutinizer ignore-call */ 
412
    pake_remove_dir(Builder::buildDir());
Loading history...
412
}
413
414
// helper task: display help text
415
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

415
/** @scrutinizer ignore-call */ 
416
pake_task( 'default' );
Loading history...
416
// internal task: parse cli options
417
pake_task('getopts');
418
pake_task('init', 'getopts');
419
pake_task('doc', 'getopts', 'init', 'clean-doc');
420
pake_task('build', 'getopts', 'init', 'doc');
421
pake_task('dist', 'getopts', 'init', 'build', 'clean-dist');
422
pake_task('clean-doc', 'getopts');
423
pake_task('clean-dist', 'getopts');
424
pake_task('clean-workspace', 'getopts');
425
pake_task('clean', 'getopts');
426
427
}
428