|
@@ -449,7 +449,7 @@ discard block |
|
|
block discarded – undo |
|
449
|
449
|
public static function rules(string $type, iterable $rules, bool $reset = false) : void |
|
450
|
450
|
{ |
|
451
|
451
|
foreach ($rules as $rule => $pattern) { |
|
452
|
|
- if (! is_array($pattern)) { |
|
|
452
|
+ if (!is_array($pattern)) { |
|
453
|
453
|
continue; |
|
454
|
454
|
} |
|
455
|
455
|
|
|
@@ -461,7 +461,7 @@ discard block |
|
|
block discarded – undo |
|
461
|
461
|
: $pattern + self::${$type}[$rule]; |
|
462
|
462
|
} |
|
463
|
463
|
|
|
464
|
|
- unset($rules[$rule], self::${$type}['cache' . ucfirst($rule)]); |
|
|
464
|
+ unset($rules[$rule], self::${$type}['cache'.ucfirst($rule)]); |
|
465
|
465
|
|
|
466
|
466
|
if (isset(self::${$type}['merged'][$rule])) { |
|
467
|
467
|
unset(self::${$type}['merged'][$rule]); |
|
@@ -490,26 +490,26 @@ discard block |
|
|
block discarded – undo |
|
490
|
490
|
return self::$cache['pluralize'][$word]; |
|
491
|
491
|
} |
|
492
|
492
|
|
|
493
|
|
- if (! isset(self::$plural['merged']['irregular'])) { |
|
|
493
|
+ if (!isset(self::$plural['merged']['irregular'])) { |
|
494
|
494
|
self::$plural['merged']['irregular'] = self::$plural['irregular']; |
|
495
|
495
|
} |
|
496
|
496
|
|
|
497
|
|
- if (! isset(self::$plural['merged']['uninflected'])) { |
|
|
497
|
+ if (!isset(self::$plural['merged']['uninflected'])) { |
|
498
|
498
|
self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected); |
|
499
|
499
|
} |
|
500
|
500
|
|
|
501
|
|
- if (! isset(self::$plural['cacheUninflected']) || ! isset(self::$plural['cacheIrregular'])) { |
|
502
|
|
- self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')'; |
|
503
|
|
- self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')'; |
|
|
501
|
+ if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) { |
|
|
502
|
+ self::$plural['cacheUninflected'] = '(?:'.implode('|', self::$plural['merged']['uninflected']).')'; |
|
|
503
|
+ self::$plural['cacheIrregular'] = '(?:'.implode('|', array_keys(self::$plural['merged']['irregular'])).')'; |
|
504
|
504
|
} |
|
505
|
505
|
|
|
506
|
|
- if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) { |
|
507
|
|
- self::$cache['pluralize'][$word] = $regs[1] . $word[0] . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1); |
|
|
506
|
+ if (preg_match('/(.*)\\b('.self::$plural['cacheIrregular'].')$/i', $word, $regs)) { |
|
|
507
|
+ self::$cache['pluralize'][$word] = $regs[1].$word[0].substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1); |
|
508
|
508
|
|
|
509
|
509
|
return self::$cache['pluralize'][$word]; |
|
510
|
510
|
} |
|
511
|
511
|
|
|
512
|
|
- if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) { |
|
|
512
|
+ if (preg_match('/^('.self::$plural['cacheUninflected'].')$/i', $word, $regs)) { |
|
513
|
513
|
self::$cache['pluralize'][$word] = $word; |
|
514
|
514
|
|
|
515
|
515
|
return $word; |
|
@@ -537,32 +537,32 @@ discard block |
|
|
block discarded – undo |
|
537
|
537
|
return self::$cache['singularize'][$word]; |
|
538
|
538
|
} |
|
539
|
539
|
|
|
540
|
|
- if (! isset(self::$singular['merged']['uninflected'])) { |
|
|
540
|
+ if (!isset(self::$singular['merged']['uninflected'])) { |
|
541
|
541
|
self::$singular['merged']['uninflected'] = array_merge( |
|
542
|
542
|
self::$singular['uninflected'], |
|
543
|
543
|
self::$uninflected |
|
544
|
544
|
); |
|
545
|
545
|
} |
|
546
|
546
|
|
|
547
|
|
- if (! isset(self::$singular['merged']['irregular'])) { |
|
|
547
|
+ if (!isset(self::$singular['merged']['irregular'])) { |
|
548
|
548
|
self::$singular['merged']['irregular'] = array_merge( |
|
549
|
549
|
self::$singular['irregular'], |
|
550
|
550
|
array_flip(self::$plural['irregular']) |
|
551
|
551
|
); |
|
552
|
552
|
} |
|
553
|
553
|
|
|
554
|
|
- if (! isset(self::$singular['cacheUninflected']) || ! isset(self::$singular['cacheIrregular'])) { |
|
555
|
|
- self::$singular['cacheUninflected'] = '(?:' . implode('|', self::$singular['merged']['uninflected']) . ')'; |
|
556
|
|
- self::$singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$singular['merged']['irregular'])) . ')'; |
|
|
554
|
+ if (!isset(self::$singular['cacheUninflected']) || !isset(self::$singular['cacheIrregular'])) { |
|
|
555
|
+ self::$singular['cacheUninflected'] = '(?:'.implode('|', self::$singular['merged']['uninflected']).')'; |
|
|
556
|
+ self::$singular['cacheIrregular'] = '(?:'.implode('|', array_keys(self::$singular['merged']['irregular'])).')'; |
|
557
|
557
|
} |
|
558
|
558
|
|
|
559
|
|
- if (preg_match('/(.*)\\b(' . self::$singular['cacheIrregular'] . ')$/i', $word, $regs)) { |
|
560
|
|
- self::$cache['singularize'][$word] = $regs[1] . $word[0] . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1); |
|
|
559
|
+ if (preg_match('/(.*)\\b('.self::$singular['cacheIrregular'].')$/i', $word, $regs)) { |
|
|
560
|
+ self::$cache['singularize'][$word] = $regs[1].$word[0].substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1); |
|
561
|
561
|
|
|
562
|
562
|
return self::$cache['singularize'][$word]; |
|
563
|
563
|
} |
|
564
|
564
|
|
|
565
|
|
- if (preg_match('/^(' . self::$singular['cacheUninflected'] . ')$/i', $word, $regs)) { |
|
|
565
|
+ if (preg_match('/^('.self::$singular['cacheUninflected'].')$/i', $word, $regs)) { |
|
566
|
566
|
self::$cache['singularize'][$word] = $word; |
|
567
|
567
|
|
|
568
|
568
|
return $word; |