-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtestfile.php
More file actions
120 lines (101 loc) · 2.95 KB
/
testfile.php
File metadata and controls
120 lines (101 loc) · 2.95 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/*
* This file is part of the Symfony package.
*
* Taken from symfony-docs: contributing/code/standards.rst
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Acme;
const BAM = 1;
/**
* Coding standards demonstration.
*/
class FooBar
{
use AlphaTrait;
/**
* @use GenericTrait<foo>
*/
use GenericTrait;
use ZebraTrait;
public const SOME_CONST = 42;
public const STR_CONST = '43';
protected const PROTECT = 0;
public const LALA = 'lala';
/**
* @var string
*/
private $fooBar;
/**
* @param string $dummy Some argument description
*/
public function __construct(string $dummy)
{
$this->fooBar = $this->transformText($dummy);
}
/**
* @deprecated
*/
public function someDeprecatedMethod(): string
{
@\trigger_error(\sprintf('The %s() method is deprecated since version 2.8 and will be removed in 3.0. Use Acme\Baz::someMethod() instead.', __METHOD__), E_USER_DEPRECATED);
return Baz::someMethod();
}
/**
* Transforms the input given as first argument.
*
* @param bool|string $dummy Some argument description
* @param array<string> $options An options collection to be used within the transformation
*
* @return string|null The transformed input
*
* @throws \RuntimeException When an invalid option is provided
*/
private function transformText(bool|string $dummy, array $options = []): ?string
{
/** @var array<string, string> $defaultOptions */
$defaultOptions = [
'some_default' => 'values',
'another_default' => 'more values',
];
foreach ($options as $option) {
if (!\in_array($option, $defaultOptions)) {
throw new \RuntimeException(\sprintf('Unrecognized option "%s"', $option));
}
}
$destructuredStuff = \array_flip(...$defaultOptions);
$mergedOptions = \array_merge(
$defaultOptions,
$options
);
if (true === $dummy) {
return null;
}
if ('string' === $dummy) {
if ('values' === $mergedOptions['some_default']) {
return \substr($dummy, 0, 5);
}
return \ucwords($dummy);
}
return $destructuredStuff;
}
/**
* Performs some basic check for a given value.
*
* @param mixed $value Some value to check against
* @param bool $theSwitch Some switch to control the method's flow
*
* @return bool|void The resultant check if $theSwitch isn't false, void otherwise
*/
private function reverseBoolean(mixed $value = null, bool $theSwitch = false)
{
if (!$theSwitch) {
return;
}
return !$value;
}
}