Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 961dada

Browse files
Merge pull request #19 from iosifch/master
some quotes replacements
2 parents 9c6e564 + f0f2214 commit 961dada

File tree

1 file changed

+41
-32
lines changed

1 file changed

+41
-32
lines changed

‎src/VerbalExpressions/PHPVerbalExpressions/VerbalExpressions.php‎

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
class VerbalExpressions
1212
{
13-
public $prefixes = "";
14-
public $source = "";
15-
public $suffixes = "";
16-
public $modifiers = "m"; // default to global multi line matching
13+
public $prefixes = '';
14+
public $source = '';
15+
public $suffixes = '';
16+
public $modifiers = 'm'; // default to global multi line matching
1717
public $replaceLimit = 1; // the limit of preg_replace when g modifier is not set
1818
protected $lastAdded = false; // holds the last added regex
1919

@@ -28,7 +28,7 @@ class VerbalExpressions
2828
*/
2929
public static function sanitize($value)
3030
{
31-
return $value ? preg_quote($value, "/") : $value;
31+
return $value ? preg_quote($value, '/') : $value;
3232
}
3333

3434
/**
@@ -58,7 +58,7 @@ public function add($value)
5858
*/
5959
public function startOfLine($enable = true)
6060
{
61-
$this->prefixes = $enable ? "^" : "";
61+
$this->prefixes = $enable ? '^' : '';
6262

6363
return $this;
6464
}
@@ -74,7 +74,7 @@ public function startOfLine($enable = true)
7474
*/
7575
public function endOfLine($enable = true)
7676
{
77-
$this->suffixes = $enable ? "$" : "";
77+
$this->suffixes = $enable ? '$' : '';
7878

7979
return $this;
8080
}
@@ -90,7 +90,7 @@ public function endOfLine($enable = true)
9090
*/
9191
public function then($value)
9292
{
93-
return $this->add("(?:" . self::sanitize($value) . ")");
93+
return $this->add('(?:' . self::sanitize($value) . ')');
9494
}
9595

9696
/**
@@ -116,7 +116,7 @@ public function find($value)
116116
*/
117117
public function maybe($value)
118118
{
119-
return $this->add("(?:" . self::sanitize($value) . ")?");
119+
return $this->add('(?:' . self::sanitize($value) . ')?');
120120
}
121121

122122
/**
@@ -129,7 +129,7 @@ public function maybe($value)
129129
*/
130130
public function anything()
131131
{
132-
return $this->add("(?:.*)");
132+
return $this->add('(?:.*)');
133133
}
134134

135135
/**
@@ -143,7 +143,7 @@ public function anything()
143143
*/
144144
public function anythingBut($value)
145145
{
146-
return $this->add("(?:[^" . self::sanitize($value) . "]*)");
146+
return $this->add('(?:[^' . self::sanitize($value) . ']*)');
147147
}
148148

149149
/**
@@ -156,7 +156,7 @@ public function anythingBut($value)
156156
*/
157157
public function something()
158158
{
159-
return $this->add("(?:.+)");
159+
return $this->add('(?:.+)');
160160
}
161161

162162
/**
@@ -170,7 +170,7 @@ public function something()
170170
*/
171171
public function somethingBut($value)
172172
{
173-
return $this->add("(?:[^" . self::sanitize($value) . "]+)");
173+
return $this->add('(?:[^' . self::sanitize($value) . ']+)');
174174
}
175175

176176
/**
@@ -205,7 +205,7 @@ public function replace($source, $value)
205205
*/
206206
public function lineBreak()
207207
{
208-
return $this->add("(?:\\n|(\\r\\n))");
208+
return $this->add('(?:\\n|(\\r\\n))');
209209
}
210210

211211
/**
@@ -231,7 +231,7 @@ public function br()
231231
*/
232232
public function tab()
233233
{
234-
return $this->add("\\t");
234+
return $this->add('\\t');
235235
}
236236

237237
/**
@@ -244,7 +244,7 @@ public function tab()
244244
*/
245245
public function word()
246246
{
247-
return $this->add("\\w+");
247+
return $this->add('\\w+');
248248
}
249249

250250
/**
@@ -258,7 +258,7 @@ public function word()
258258
*/
259259
public function anyOf($value)
260260
{
261-
return $this->add("[" . $value . "]");
261+
return $this->add('[' . $value . ']');
262262
}
263263

264264
/**
@@ -290,17 +290,17 @@ public function range()
290290
$arg_num = func_num_args();
291291

292292
if ($arg_num%2 != 0) {
293-
throw new \InvalidArgumentException("Number of args must be even", 1);
293+
throw new \InvalidArgumentException('Number of args must be even', 1);
294294
}
295295

296-
$value = "[";
296+
$value = '[';
297297
$arg_list = func_get_args();
298298

299299
for ($i = 0; $i < $arg_num;) {
300-
$value .= self::sanitize($arg_list[$i++]) . "-" . self::sanitize($arg_list[$i++]);
300+
$value .= self::sanitize($arg_list[$i++]) . '-' . self::sanitize($arg_list[$i++]);
301301
}
302302

303-
$value .= "]";
303+
$value .= ']';
304304

305305
return $this->add($value);
306306
}
@@ -418,15 +418,15 @@ public function multiple($value)
418418
*/
419419
public function _or($value)
420420
{
421-
if (strpos($this->prefixes, "(") === false) {
422-
$this->prefixes .= "(?:";
421+
if (strpos($this->prefixes, '(') === false) {
422+
$this->prefixes .= '(?:';
423423
}
424424

425-
if (strpos($this->suffixes, ")") === false) {
426-
$this->suffixes .= ")";
425+
if (strpos($this->suffixes, ')') === false) {
426+
$this->suffixes .= ')';
427427
}
428428

429-
$this->add(")|(?:");
429+
$this->add(')|(?:');
430430

431431
if ($value) {
432432
$this->add($value);
@@ -458,7 +458,7 @@ public function __toString()
458458
*/
459459
public function getRegex()
460460
{
461-
return "/" . $this->prefixes . $this->source . $this->suffixes . "/" . $this->modifiers;
461+
return '/' . $this->prefixes . $this->source . $this->suffixes . '/' . $this->modifiers;
462462
}
463463

464464
/**
@@ -493,7 +493,16 @@ public function test($value)
493493
*/
494494
public function clean(array $options = array())
495495
{
496-
$options = array_merge(array("prefixes"=> "", "source"=>"", "suffixes"=>"", "modifiers"=>"gm", "replaceLimit"=>"1"), $options);
496+
$options = array_merge(
497+
array(
498+
'prefixes' => '',
499+
'source' => '',
500+
'suffixes' => '',
501+
'modifiers' => 'gm',
502+
'replaceLimit' => '1'
503+
),
504+
$options
505+
);
497506
$this->prefixes = $options['prefixes'];
498507
$this->source = $options['source'];
499508
$this->suffixes = $options['suffixes'];
@@ -519,15 +528,15 @@ public function clean(array $options = array())
519528
public function limit($min, $max = 0)
520529
{
521530
if ($max == 0) {
522-
$value = "{" . $min . "}";
531+
$value = '{' . $min . '}';
523532
} elseif ($max < $min) {
524-
$value = "{" . $min . ",}";
533+
$value = '{' . $min . ',}';
525534
} else {
526-
$value = "{" . $min . "," . $max . "}";
535+
$value = '{' . $min . ',' . $max . '}';
527536
}
528537

529538
// check if the expression has * or + for the last expression
530-
if (preg_match("/\*|\+/", $this->lastAdded)) {
539+
if (preg_match('/\*|\+/', $this->lastAdded)) {
531540
$l = 1;
532541
$this->source = strrev(str_replace(array('+','*'), strrev($value), strrev($this->source), $l));
533542

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /