|
@@ -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]); |
|
@@ -492,31 +492,31 @@ discard block |
|
|
block discarded – undo |
|
492
|
492
|
return self::$cache['pluralize'][$word]; |
|
493
|
493
|
} |
|
494
|
494
|
|
|
495
|
|
- if (! isset(self::$plural['merged']['irregular'])) { |
|
|
495
|
+ if (!isset(self::$plural['merged']['irregular'])) { |
|
496
|
496
|
self::$plural['merged']['irregular'] = self::$plural['irregular']; |
|
497
|
497
|
} |
|
498
|
498
|
|
|
499
|
|
- if (! isset(self::$plural['merged']['uninflected'])) { |
|
|
499
|
+ if (!isset(self::$plural['merged']['uninflected'])) { |
|
500
|
500
|
self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected); |
|
501
|
501
|
} |
|
502
|
502
|
|
|
503
|
|
- if (! isset(self::$plural['cacheUninflected']) || ! isset(self::$plural['cacheIrregular'])) { |
|
504
|
|
- self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')'; |
|
505
|
|
- self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')'; |
|
|
503
|
+ if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) { |
|
|
504
|
+ self::$plural['cacheUninflected'] = '(?:'.implode('|', self::$plural['merged']['uninflected']).')'; |
|
|
505
|
+ self::$plural['cacheIrregular'] = '(?:'.implode('|', array_keys(self::$plural['merged']['irregular'])).')'; |
|
506
|
506
|
} |
|
507
|
507
|
|
|
508
|
508
|
|
|
509
|
|
- if (preg_match('/(.*(?:\\b|_))(' . self::$plural['cacheIrregular'] . ')$/i', $tablized_word, $regs)) { |
|
510
|
|
- $result = $regs[1] . substr($regs[2], 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1); |
|
|
509
|
+ if (preg_match('/(.*(?:\\b|_))('.self::$plural['cacheIrregular'].')$/i', $tablized_word, $regs)) { |
|
|
510
|
+ $result = $regs[1].substr($regs[2], 0, 1).substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1); |
|
511
|
511
|
if ($tablized_word !== $word) { |
|
512
|
512
|
$camelized_result = self::camelize($result); |
|
513
|
|
- $result = substr($word, 0, 1) . substr($camelized_result, 1); |
|
|
513
|
+ $result = substr($word, 0, 1).substr($camelized_result, 1); |
|
514
|
514
|
} |
|
515
|
515
|
|
|
516
|
516
|
return self::$cache['pluralize'][$word] = $result; |
|
517
|
517
|
} |
|
518
|
518
|
|
|
519
|
|
- if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) { |
|
|
519
|
+ if (preg_match('/^('.self::$plural['cacheUninflected'].')$/i', $word, $regs)) { |
|
520
|
520
|
self::$cache['pluralize'][$word] = $word; |
|
521
|
521
|
|
|
522
|
522
|
return $word; |
|
@@ -546,36 +546,36 @@ discard block |
|
|
block discarded – undo |
|
546
|
546
|
return self::$cache['singularize'][$word]; |
|
547
|
547
|
} |
|
548
|
548
|
|
|
549
|
|
- if (! isset(self::$singular['merged']['uninflected'])) { |
|
|
549
|
+ if (!isset(self::$singular['merged']['uninflected'])) { |
|
550
|
550
|
self::$singular['merged']['uninflected'] = array_merge( |
|
551
|
551
|
self::$singular['uninflected'], |
|
552
|
552
|
self::$uninflected |
|
553
|
553
|
); |
|
554
|
554
|
} |
|
555
|
555
|
|
|
556
|
|
- if (! isset(self::$singular['merged']['irregular'])) { |
|
|
556
|
+ if (!isset(self::$singular['merged']['irregular'])) { |
|
557
|
557
|
self::$singular['merged']['irregular'] = array_merge( |
|
558
|
558
|
self::$singular['irregular'], |
|
559
|
559
|
array_flip(self::$plural['irregular']) |
|
560
|
560
|
); |
|
561
|
561
|
} |
|
562
|
562
|
|
|
563
|
|
- if (! isset(self::$singular['cacheUninflected']) || ! isset(self::$singular['cacheIrregular'])) { |
|
564
|
|
- self::$singular['cacheUninflected'] = '(?:' . implode('|', self::$singular['merged']['uninflected']) . ')'; |
|
565
|
|
- self::$singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$singular['merged']['irregular'])) . ')'; |
|
|
563
|
+ if (!isset(self::$singular['cacheUninflected']) || !isset(self::$singular['cacheIrregular'])) { |
|
|
564
|
+ self::$singular['cacheUninflected'] = '(?:'.implode('|', self::$singular['merged']['uninflected']).')'; |
|
|
565
|
+ self::$singular['cacheIrregular'] = '(?:'.implode('|', array_keys(self::$singular['merged']['irregular'])).')'; |
|
566
|
566
|
} |
|
567
|
567
|
|
|
568
|
|
- if (preg_match('/(.*(?:\\b|_))(' . self::$singular['cacheIrregular'] . ')$/i', $tablized_word, $regs)) { |
|
569
|
|
- $result = $regs[1] . substr($regs[2], 0, 1) . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1); |
|
|
568
|
+ if (preg_match('/(.*(?:\\b|_))('.self::$singular['cacheIrregular'].')$/i', $tablized_word, $regs)) { |
|
|
569
|
+ $result = $regs[1].substr($regs[2], 0, 1).substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1); |
|
570
|
570
|
|
|
571
|
571
|
if ($tablized_word !== $word) { |
|
572
|
572
|
$camelized_result = self::camelize($result); |
|
573
|
|
- $result = substr($word, 0, 1) . substr($camelized_result, 1); |
|
|
573
|
+ $result = substr($word, 0, 1).substr($camelized_result, 1); |
|
574
|
574
|
} |
|
575
|
575
|
return self::$cache['singularize'][$word] = $result; |
|
576
|
576
|
} |
|
577
|
577
|
|
|
578
|
|
- if (preg_match('/^(' . self::$singular['cacheUninflected'] . ')$/i', $word, $regs)) { |
|
|
578
|
+ if (preg_match('/^('.self::$singular['cacheUninflected'].')$/i', $word, $regs)) { |
|
579
|
579
|
self::$cache['singularize'][$word] = $word; |
|
580
|
580
|
|
|
581
|
581
|
return $word; |