Skip to content

Commit 55878ae

Browse files
committed
Apply php-cs-fixer rules
1 parent 83a95c7 commit 55878ae

File tree

93 files changed

+1844
-1572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1844
-1572
lines changed

.atoum.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*
@@ -39,12 +39,14 @@
3939
if (getenv('TRAVIS_PHP_VERSION') === '7.0') {
4040
$script
4141
->php('php -n -ddate.timezone=Europe/Paris')
42-
->noCodeCoverage();
42+
->noCodeCoverage()
43+
;
4344
} else {
4445
$script->noCodeCoverageForNamespaces('Composer');
4546
}
4647

4748
$script->addTestsFromDirectory(__DIR__ . '/tests/units');
4849
$runner
4950
->addExtension(new \Atoum\PraspelExtension\Manifest())
50-
->addExtension(new visibility\extension($script));
51+
->addExtension(new visibility\extension($script))
52+
;

.bootstrap.atoum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*

bin/pickle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ function includeIfExists($file)
1010
return file_exists($file) ? include $file : false;
1111
}
1212

13-
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
14-
echo 'You must set up the project dependencies, run the following commands:'.PHP_EOL.
15-
'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
16-
'php composer.phar install'.PHP_EOL;
13+
if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
14+
echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL
15+
. 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL
16+
. 'php composer.phar install' . PHP_EOL;
1717

1818
exit(1);
1919
}
@@ -25,7 +25,7 @@ if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
2525
| |_) | |/ __| |/ / |/ _ \
2626
| __/| | (__| <| | __/
2727
|_| |_|\___|_|\_\_|\___| ';
28-
} else {
28+
} else {
2929
$name = '
3030
██████╗ ██╗ ██████╗██╗ ██╗██╗ ███████╗
3131
██╔══██╗██║██╔════╝██║ ██╔╝██║ ██╔════╝

features/bootstrap/FeatureContext.php

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*
@@ -33,6 +33,7 @@
3333
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3434
* POSSIBILITY OF SUCH DAMAGE.
3535
*/
36+
3637
use Behat\Behat\Context\SnippetAcceptingContext;
3738
use Behat\Gherkin\Node\PyStringNode;
3839
use Symfony\Component\Process\PhpExecutableFinder;
@@ -45,12 +46,16 @@
4546
*/
4647
class FeatureContext implements SnippetAcceptingContext
4748
{
48-
const PICKLE_BIN = 'bin/pickle';
49+
protected const PICKLE_BIN = 'bin/pickle';
4950

5051
private $assert;
52+
5153
private $php;
54+
5255
private $dir;
56+
5357
private $workingDir;
58+
5459
private $process;
5560

5661
public function __construct()
@@ -84,49 +89,40 @@ public function prepare()
8489
$this->php = $php;
8590
}
8691

87-
private function moveToNewPath($path)
88-
{
89-
$newWorkingDir = $this->workingDir .'/' . $path;
90-
91-
if (!file_exists($newWorkingDir)) {
92-
mkdir($newWorkingDir, 0777, true);
93-
}
94-
95-
$this->workingDir = $newWorkingDir;
96-
}
97-
9892
/**
9993
* @Given /^I am in the "([^"]*)" path$/
10094
*/
10195
public function iAmInThePath($path)
10296
{
10397
$this->moveToNewPath($path);
10498
}
105-
/* convert Convert package.xml to new format
106-
help Displays help for a command
107-
info Display information about a PECL extension
108-
install Install a php extension
109-
list Lists commands
110-
release Package a PECL extension for release
111-
validate Validate a PECL extension */
99+
100+
/* convert Convert package.xml to new format
101+
help Displays help for a command
102+
info Display information about a PECL extension
103+
install Install a php extension
104+
list Lists commands
105+
release Package a PECL extension for release
106+
validate Validate a PECL extension */
107+
112108
/**
113109
* @When /^I run "pickle(?: ((?:\"|[^"])*))?"$/
114110
*/
115111
public function iRunPickle($argumentsString = '')
116112
{
117-
$argumentsString = strtr($argumentsString, array('\'' => '"'));
118-
$arguments = explode(' ',$argumentsString);
113+
$argumentsString = strtr($argumentsString, ['\'' => '"']);
114+
$arguments = explode(' ', $argumentsString);
119115
$processArguments = [
120-
$this->php,
121-
__DIR__ . '/../../' . static::PICKLE_BIN,
122-
];
116+
$this->php,
117+
__DIR__ . '/../../' . static::PICKLE_BIN,
118+
];
123119

124120
$processArguments = array_merge($processArguments, $arguments);
125121
$processArguments[] = '--no-ansi';
126122
$this->process = new Process($processArguments);
127123

128124
$timeout = getenv('PICKLE_BEHAT_PROCESS_TIMEOUT');
129-
if (false !== $timeout) {
125+
if ($timeout !== false) {
130126
$this->process->setTimeout($timeout);
131127
}
132128

@@ -148,14 +144,14 @@ public function theOutputShouldContain(PyStringNode $text)
148144
*/
149145
public function itShouldFail($success)
150146
{
151-
if ('fail' === $success) {
152-
if (0 === $this->getExitCode()) {
147+
if ($success === 'fail') {
148+
if ($this->getExitCode() === 0) {
153149
echo 'Actual output:' . PHP_EOL . PHP_EOL . $this->getOutput();
154150
}
155151

156152
$this->assert->integer($this->getExitCode())->isGreaterThan(0);
157153
} else {
158-
if (0 !== $this->getExitCode()) {
154+
if ($this->getExitCode() !== 0) {
159155
echo 'Actual output:' . PHP_EOL . PHP_EOL . $this->getOutput();
160156
}
161157

@@ -177,7 +173,7 @@ public function itShouldPassWith($success, PyStringNode $text)
177173
*/
178174
public function aFileNamedWith($filename, PyStringNode $content)
179175
{
180-
$content = strtr((string) $content, array("'''" => '"""'));
176+
$content = strtr((string) $content, ["'''" => '"""']);
181177
$this->createFile($this->workingDir . '/' . $filename, $content);
182178
}
183179

@@ -221,6 +217,36 @@ public function JsonfileShouldContain($path, PyStringNode $text)
221217
$this->assert->object($fileContent)->isEqualTo(json_decode($text));
222218
}
223219

220+
/**
221+
* @Then /^"([^"]*)" ((?:\d+\.?)+(?:RC\d*|beta\d*|alpha\d*)?) extension exists$/
222+
*/
223+
public function extensionExists($name, $version)
224+
{
225+
$url = 'https://pecl.php.net/get/' . $name . '/' . $version . '?uncompress=1';
226+
$file = $name . '-' . $version . '.tgz';
227+
$dir = $this->workingDir . '/' . $name . '-' . $version;
228+
229+
if (is_dir($dir) === false) {
230+
mkdir($dir, 0777, true);
231+
}
232+
$downloadFile = $dir . '/' . $file;
233+
file_put_contents($downloadFile, file_get_contents($url));
234+
$p = new PharData($downloadFile);
235+
$phar = $p->decompress('.tar');
236+
$phar->extractTo($dir);
237+
}
238+
239+
private function moveToNewPath($path)
240+
{
241+
$newWorkingDir = $this->workingDir . '/' . $path;
242+
243+
if (!file_exists($newWorkingDir)) {
244+
mkdir($newWorkingDir, 0777, true);
245+
}
246+
247+
$this->workingDir = $newWorkingDir;
248+
}
249+
224250
private function getExitCode()
225251
{
226252
return $this->process->getExitCode();
@@ -249,21 +275,19 @@ private function getOutput()
249275
$output = str_replace(PHP_EOL, "\n", $output);
250276
}
251277

252-
return trim(preg_replace("/ +$/m", '', $output));
278+
return trim(preg_replace('/ +$/m', '', $output));
253279
}
254280

255281
private function getExpectedOutput(PyStringNode $expectedText)
256282
{
257-
$text = strtr(
283+
return strtr(
258284
$expectedText,
259285
[
260286
'\'\'\'' => '"""',
261287
'%%TMP_DIR%%' => sys_get_temp_dir(),
262288
'%%TEST_DIR%%' => realpath($this->dir),
263289
]
264290
);
265-
266-
return $text;
267291
}
268292

269293
private static function clearDirectory($path)
@@ -283,23 +307,4 @@ private static function clearDirectory($path)
283307

284308
rmdir($path);
285309
}
286-
287-
/**
288-
* @Then /^"([^"]*)" ((?:\d+\.?)+(?:RC\d*|beta\d*|alpha\d*)?) extension exists$/
289-
*/
290-
public function extensionExists($name, $version)
291-
{
292-
$url = 'https://pecl.php.net/get/' . $name . '/' . $version . '?uncompress=1';
293-
$file = $name . '-' . $version . '.tgz';
294-
$dir = $this->workingDir . '/' . $name . '-' . $version;
295-
296-
if (is_dir($dir) === false) {
297-
mkdir($dir, 0777, true);
298-
}
299-
$downloadFile = $dir . '/' . $file;
300-
file_put_contents($downloadFile, file_get_contents($url));
301-
$p = new PharData($downloadFile);
302-
$phar = $p->decompress('.tar');
303-
$phar->extractTo($dir);
304-
}
305310
}

features/bootstrap/PharFeatureContext.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*
@@ -33,7 +33,8 @@
3333
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3434
* POSSIBILITY OF SUCH DAMAGE.
3535
*/
36+
3637
class PharFeatureContext extends FeatureContext
3738
{
38-
const PICKLE_BIN = 'pickle.phar';
39+
protected const PICKLE_BIN = 'pickle.phar';
3940
}

src/Base/Abstracts/Console/Command/BuildCommand.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*
@@ -36,14 +36,15 @@
3636

3737
namespace Pickle\Base\Abstracts\Console\Command;
3838

39+
use Exception;
40+
use Pickle\Base\Interfaces\Package;
3941
use Symfony\Component\Console\Command\Command;
4042
use Symfony\Component\Console\Input\InputArgument;
4143
use Symfony\Component\Console\Input\InputInterface;
4244
use Symfony\Component\Console\Input\InputOption;
4345
use Symfony\Component\Console\Output\OutputInterface;
4446
use Symfony\Component\Console\Question\ConfirmationQuestion;
4547
use Symfony\Component\Console\Question\Question;
46-
use Pickle\Base\Interfaces\Package;
4748

4849
abstract class BuildCommand extends Command
4950
{
@@ -101,10 +102,10 @@ protected function buildOptions(Package $package, InputInterface $input, OutputI
101102

102103
if ($force_opts) {
103104
if (!file_exists($force_opts) || !is_file($force_opts) || !is_readable($force_opts)) {
104-
throw new \Exception("File '$force_opts' is unusable");
105+
throw new Exception("File '{$force_opts}' is unusable");
105106
}
106107

107-
$force_opts = preg_replace(",\s+,", ' ', file_get_contents($force_opts));
108+
$force_opts = preg_replace(',\\s+,', ' ', file_get_contents($force_opts));
108109

109110
return [null, $force_opts];
110111
}
@@ -116,8 +117,8 @@ protected function buildOptions(Package $package, InputInterface $input, OutputI
116117
/* enable/with-<extname> */
117118
if ($name == $package->getName() || str_replace('-', '_', $name) == $package->getName()) {
118119
$optionsValue[$name] = (object) [
119-
'type' => $opt->type,
120-
'input' => true,
120+
'type' => $opt->type,
121+
'input' => true,
121122
];
122123

123124
continue;
@@ -127,9 +128,9 @@ protected function buildOptions(Package $package, InputInterface $input, OutputI
127128
$value = $opt->default;
128129
} else {
129130
if ($opt->type == 'enable') {
130-
$prompt = new ConfirmationQuestion($opt->prompt.' (default: '.($opt->default ? 'yes' : 'no').'): ', $opt->default);
131+
$prompt = new ConfirmationQuestion($opt->prompt . ' (default: ' . ($opt->default ? 'yes' : 'no') . '): ', $opt->default);
131132
} else {
132-
$prompt = new Question($opt->prompt.' (default: '.($opt->default ? $opt->default : '').'): ', $opt->default);
133+
$prompt = new Question($opt->prompt . ' (default: ' . ($opt->default ?: '') . '): ', $opt->default);
133134
}
134135

135136
$value = $helper->ask($input, $output, $prompt);

src/Base/Abstracts/Engine.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* Pickle
55
*
66
*
@@ -47,16 +47,13 @@ public function getArchitecture()
4747
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
4848
if ($is_64_bit) {
4949
return 'x64';
50-
} else {
51-
return 'x86';
52-
}
53-
} else {
54-
if ($is_64_bit) {
55-
return 'x86_64';
56-
} else {
57-
return 'i386';
5850
}
51+
return 'x86';
52+
}
53+
if ($is_64_bit) {
54+
return 'x86_64';
5955
}
56+
return 'i386';
6057
}
6158
}
6259

0 commit comments

Comments
 (0)