Skip to content

Commit

Permalink
Merge pull request #47 from weierophinney/hotfix/doc-linting-errors
Browse files Browse the repository at this point in the history
Fix documentation linting errors
  • Loading branch information
weierophinney authored Apr 7, 2021
2 parents c9b7cf7 + ca2760b commit 5e85a8f
Show file tree
Hide file tree
Showing 24 changed files with 244 additions and 164 deletions.
22 changes: 13 additions & 9 deletions docs/book/filters/alnum.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Alnum

The `Alnum` filter can be used to **return only alphabetic characters and
digits** in the unicode "letter" and "number" categories, respectively. All
The `Alnum` filter can be used to **return only alphabetic characters and
digits** in the unicode "letter" and "number" categories, respectively. All
other characters are suppressed.

## Basic Usage
Expand All @@ -20,20 +20,22 @@ provided by PHP's `Locale` class and the `getDefault()` method.
To allow whitespace characters (`\s`) on filtering set the option to `true`;
otherwise they are suppressed.

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\Alnum(true);

echo $filter->filter('This is (my) content: 123'); // "This is my content 123"
```

=== "Setter Usage"
```php
$filter = new Laminas\I18n\Filter\Alnum();
$filter->setAllowWhiteSpace(true);

echo $filter->filter('This is (my) content: 123'); // "This is my content 123"
```
<!-- markdownlint-restore -->

### Get Current Value

Expand All @@ -52,32 +54,34 @@ suppressed.

## Using Locale

The locale string used in identifying the characters to filter (locale name,
The locale string used in identifying the characters to filter (locale name,
e.g. `en_US`).

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\Alnum(null, 'en_US');

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent123"
```

=== "Setter Usage"
```php
$filter = new Laminas\I18n\Filter\Alnum();
$filter->setLocale('en_US');

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent123"
```

=== "Locale Class Usage"
```php
Locale::setDefault('en_US');

$filter = new Laminas\I18n\Filter\Alnum();

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent123"
```
<!-- markdownlint-restore -->

### Get Current Value

Expand Down
18 changes: 11 additions & 7 deletions docs/book/filters/alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ provided by PHP's `Locale` class and the `getDefault()` method.
To allow whitespace characters (`\s`) on filtering set the option to `true`;
otherwise they are suppressed.

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\Alpha(true);

echo $filter->filter('This is (my) content: 123'); // "This is my content"
```

=== "Setter Usage"
```php
$filter = new Laminas\I18n\Filter\Alpha();
$filter->setAllowWhiteSpace(true);

echo $filter->filter('This is (my) content: 123'); // "This is my content"
```
<!-- markdownlint-restore -->

### Get Current Value

Expand All @@ -51,32 +53,34 @@ suppressed.

## Using Locale

The locale string used in identifying the characters to filter (locale name,
The locale string used in identifying the characters to filter (locale name,
e.g. `en_US`).

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\Alpha(null, 'en_US');

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent"
```

=== "Setter Usage"
```php
$filter = new Laminas\I18n\Filter\Alpha();
$filter->setLocale('en_US');

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent"
```

=== "Locale Class Usage"
```php
Locale::setDefault('en_US');

$filter = new Laminas\I18n\Filter\Alpha();

echo $filter->filter('This is (my) content: 123'); // "Thisismycontent"
```
<!-- markdownlint-restore -->

### Get Current Value

Expand Down
9 changes: 5 additions & 4 deletions docs/book/filters/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

laminas-i18n ships with a set of internationalization-related filters.

* [Alnum](alnum.md)
* [Alpha](alpha.md)
* [NumberFormat](number-format.md)
* [NumberParse](number-parse.md)
- [Alnum](alnum.md)
- [Alpha](alpha.md)
- [NumberFormat](number-format.md)
- [NumberParse](number-parse.md)

These filters are based on Laminas component for filtering and
normalizing data and files:
Expand All @@ -14,6 +14,7 @@ normalizing data and files:
The concept and the basic usage of the filters can be found in the
[documentation of laminas-filter](https://docs.laminas.dev/laminas-filter/).

<!-- markdownlint-disable-next-line MD001 -->
> ### Installation requirements
>
> The filtering support of laminas-i18n depends on the
Expand Down
40 changes: 23 additions & 17 deletions docs/book/filters/number-parse.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NumberParse

The `NumberParse` filter can be used to **parse a number from a string**. It
The `NumberParse` filter can be used to **parse a number from a string**. It
acts as a wrapper for the `NumberFormatter` class within PHP's
internationalization extension (`ext/intl`).

Expand All @@ -19,32 +19,34 @@ provided by PHP's `Locale` class and the `getDefault()` method.

## Using Locale

The locale string used in identifying the characters to filter (locale name,
The locale string used in identifying the characters to filter (locale name,
e.g. `en_US` or `de_DE`).

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\NumberParse('de_DE');

echo $filter->filter('1.234.567,891'); // 1234567.8912346
```

=== "Setter Usage"
```php
$filter = new Laminas\I18n\Filter\NumberParse();
$filter->setLocale('de_DE');

echo $filter->filter('1.234.567,891'); // 1234567.8912346
```

=== "Locale Class Usage"
```php
Locale::setDefault('de_DE');

$filter = new Laminas\I18n\Filter\NumberParse();

echo $filter->filter('1.234.567,891'); // 1234567.8912346
```
<!-- markdownlint-restore -->

> ### Notice
>
Expand All @@ -68,19 +70,20 @@ provided by PHP's `Locale::getDefault()`.

## Using Style

This option sets the style of the parsing; one of the
This option sets the style of the parsing; one of the
[`NumberFormatter` format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle).

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
// Example 1
$filter = new Laminas\I18n\Filter\NumberParse('en_US', NumberFormatter::PERCENT);

echo $filter->filter('80%'); // 0.80

// Example 2
$filter = new Laminas\I18n\Filter\NumberParse('fr_FR', NumberFormatter::SCIENTIFIC);

echo $filter->filter('1,23456789E-3'); // 0.00123456789
```

Expand All @@ -89,19 +92,20 @@ This option sets the style of the parsing; one of the
// Example 1
$filter = new Laminas\I18n\Filter\NumberParse('en_US');
$filter->setStyle(NumberFormatter::PERCENT);

echo $filter->filter('80%'); // 0.80

// Example 2
$filter = new Laminas\I18n\Filter\NumberParse('fr_FR');
$filter->setStyle(NumberFormatter::SCIENTIFIC);

echo $filter->filter('1,23456789E-3'); // 0.00123456789
```
<!-- markdownlint-restore -->

> ### Notice
>
> After the first filtering, the style changes will have no effect anymore.
> After the first filtering, the style changes will have no effect anymore.
> Create a new instance of the filter to change the style.
### Get Current Value
Expand All @@ -123,14 +127,15 @@ The default value of this option is `NumberFormatter::DEFAULT_STYLE`.
The type speficied the [`NumberFormatter` parsing type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types)
to use.

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$filter = new Laminas\I18n\Filter\NumberParse(
'de_DE',
NumberFormatter::DEFAULT_STYLE,
NumberFormatter::DECIMAL
);

echo $filter->filter('1.234.567,891'); // 1234567
```

Expand All @@ -139,9 +144,10 @@ to use.
$filter = new Laminas\I18n\Filter\NumberParse();
$filter->setLocale('de_DE');
$filter->setType(NumberFormatter::DECIMAL);

echo $filter->filter('1.234.567,891'); // 1234567
```
<!-- markdownlint-restore -->

### Get Current Value

Expand All @@ -160,7 +166,7 @@ The default value of this option is `NumberFormatter::TYPE_DOUBLE`.
## Using Custom NumberFormatter

```php
$formatter = new NumberFormatter('en_US', NumberFormatter::PERCENT);
$formatter = new NumberFormatter('en_US', NumberFormatter::PERCENT);
$filter = new Laminas\I18n\Filter\NumberParse();
$filter->setFormatter($formatter);
```
Expand Down
2 changes: 1 addition & 1 deletion docs/book/migration/migration-to-v2.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ instead starting in 2.4.0.

### IsInt

In PHP 7, `int` is a reserved keyword, which required renaming the
In PHP 7, `int` is a reserved keyword, which required renaming the
`Laminas\I18n\Validator\Int` validator. If you were using the
`Laminas\I18n\Validator\Int` validator directly previously, you will now
receive an `E_USER_DEPRECATED` notice on instantiation. Please update your code
Expand Down
1 change: 1 addition & 0 deletions docs/book/translator/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ In production, it makes sense to cache your translations. This not only saves
you from loading and parsing the individual formats each time, but also
guarantees an optimized loading procedure.

<!-- markdownlint-disable-next-line MD001 -->
> ### Installation requirements
>
> The cache support of laminas-i18n depends on the
Expand Down
5 changes: 3 additions & 2 deletions docs/book/translator/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ translations:
The typical usage for these events is to log missing translations and track when
the loading of messages fails.

<!-- markdownlint-disable-next-line MD001 -->
> ### Installation requirements
>
> The event support of laminas-i18n depends on the
Expand Down Expand Up @@ -88,7 +89,7 @@ $eventManager = $translator->getEventManager(); // instance of Laminas\EventMana
```

> ### Automatic instantiation
>
>
> The translator can create an event manager instance independently. If no custom
> event manager is set for the translator, the `getEventManager()` method
> returns this instance.
Expand Down Expand Up @@ -120,7 +121,7 @@ $translator->getEventManager()->attach(

### Event Target and Parameters

In the previous code example the variable `$event` contains an instance of
In the previous code example the variable `$event` contains an instance of
`Laminas\EventManager\Event` which implements `Laminas\EventManager\EventInterface`.

As target of the event the current instance of
Expand Down
2 changes: 1 addition & 1 deletion docs/book/translator/factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ $translator = Laminas\I18n\Translator\Translator::factory([
]);
```

Each remote option array must contain `type`. The option for `text_domain` is
Each remote option array must contain `type`. The option for `text_domain` is
optional. The default value for `text_domain` is `default`.

### Adding Translations
Expand Down
2 changes: 1 addition & 1 deletion docs/book/translator/format-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ identifier1.translation = "voiture"

identifier2.message = "train"
identifier2.translation = "train"
```
```
8 changes: 5 additions & 3 deletions docs/book/validators/alnum.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ if ($validator->isValid('Abcd12')) {
By default, whitespace is not accepted as it is not part of the alphabet.
However, if you want to validate complete sentences or phrases, you may need to
allow whitespace; this can be done via the `allowWhiteSpace` option, either at
instantiation or afterwards via the `setAllowWhiteSpace()` method.
instantiation or afterwards via the `setAllowWhiteSpace()` method.

<!-- markdownlint-disable MD038 MD009 MD046 -->
=== "Constructor Usage"
```php
$validator = new Laminas\I18n\Validator\Alnum(['allowWhiteSpace' => true]);

if ($validator->isValid('Abcd and 12')) {
// Value contains only allowed chars
}
Expand All @@ -33,11 +34,12 @@ instantiation or afterwards via the `setAllowWhiteSpace()` method.
```php
$validator = new Laminas\I18n\Validator\Alnum();
$validator->setAllowWhiteSpace(true);

if ($validator->isValid('Abcd and 12')) {
// Value contains only allowed chars
}
```
<!-- markdownlint-restore -->

### Get Current Value

Expand Down
Loading

0 comments on commit 5e85a8f

Please sign in to comment.