Skip to content

Commit

Permalink
prepare 5.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Mar 14, 2018
1 parent add5164 commit f2bceb7
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 51 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

All Notable changes to `League\Uri` will be documented in this file

## 5.3.0 - 2018-03-14

See packages release notes for more informations

- [URI Parser](https://github.com/thephpleague/uri-parser/releases/tag/1.4.0)
- [URI Components](https://github.com/thephpleague/uri-components/releases/tag/1.8.0)
- [URI Hostname Parser](https://github.com/thephpleague/uri-hostname-parser/releases/tag/1.1.0)
- [URI Manipulations](https://github.com/thephpleague/uri-manipulations/releases/tag/1.5.0)
- [URI Schemes](https://github.com/thephpleague/uri-schemes/releases/tag/1.2.0)

### Added

- IPvFuture support

### Fixed

- Adding PHPStan
- Improve RFC3986 compliance
- Improve performance

### Remove

- remove `mbstring` extension requirement

## 5.2.0 - 2017-12-01

- [URI Parser](https://github.com/thephpleague/uri-parser/releases/tag/1.3.0)
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
"ext-mbstring" : "*",
"ext-intl" : "*",
"ext-fileinfo": "*",
"league/uri-components": "^1.5.0",
"league/uri-hostname-parser": "^1.0.4",
"league/uri-components": "^1.8",
"league/uri-hostname-parser": "^1.1",
"league/uri-interfaces": "^1.0",
"league/uri-manipulations": "^1.3",
"league/uri-parser": "^1.3.0",
"league/uri-schemes": "^1.1.1",
"league/uri-manipulations": "^1.5",
"league/uri-parser": "^1.4",
"league/uri-schemes": "^1.2",
"php" : ">=7.0.13",
"psr/http-message": "^1.0"
},
Expand Down
126 changes: 85 additions & 41 deletions docs/5.0/components/host.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Host implements ComponentInterface, Countable, IteratorAggregate
public function __construct(?string $content = null, Rules $resolver = null): void
public function append(string $host): self
public function getIp(void): string
public function getIpVersion(void): string|null
public function getLabel(int $offset, $default = null): mixed
public function getLabels(void): array
public function getPublicSuffix(void): string
Expand All @@ -35,6 +36,8 @@ class Host implements ComponentInterface, Countable, IteratorAggregate
public function isIp(void): bool
public function isIpv4(void): bool
public function isIpv6(void): bool
public function isIpFuture(void): bool
public function isDomain(void): bool
public function isPublicSuffixValid(void): bool
public function isAbsolute(void): bool
public function keys([string $label]): array
Expand Down Expand Up @@ -72,11 +75,13 @@ The `League\Uri\Components\Exception` extends PHP's SPL `InvalidArgumentExceptio
<?php

public static Host::createFromIp(string $ip, Rules $resolver = null): self
public Host::getIp(void): string
public Host::getIpVersion(void): string|null
public Host::isIp(void): bool
public Host::isIpv4(void): bool
public Host::isIpv6(void): bool
public Host::isIpFuture(void): bool
public Host::hasZoneIdentifier(void): bool
public Host::getIp(void): string
public Host::withoutZoneIdentifier(void): self
~~~

Expand All @@ -103,7 +108,7 @@ Host::createFromIp('uri.thephpleague.com');

### IPv4 or IPv6

There are two type of host:
There are two (2) types of host:

- Hosts represented by an IP;
- Hosts represented by a registered name;
Expand All @@ -121,22 +126,40 @@ $ip_host = $host->withContent('127.0.0.1');
$ip_host->isIp(); //return true;
~~~

Knowing that you are dealing with an IP is good, knowing that its an IPv4 or an IPv6 is better.
Knowing that you are dealing with an IP is good, knowing its version is better.

~~~php
<?php

use League\Uri\Components\Host;

$ipv6 = Host::createFromIp('::1');
$ipv6->isIp(); //return true
$ipv6->isIpv4(); //return false
$ipv6->isIpv6(); //return true
$ipv6->isIp(); //return true
$ipv6->isIpv4(); //return false
$ipv6->isIpv6(); //return true
$ipv6->isIpFuture(); //return false
$ipv6->getIpVersion(); //return '6'

$ipv4 = new Host('127.0.0.1');
$ipv4->isIp(); //return true
$ipv4->isIpv4(); //return true
$ipv4->isIpv6(); //return false
$ipv4->isIp(); //return true
$ipv4->isIpv4(); //return true
$ipv4->isIpv6(); //return false
$ipv4->isIpFuture(); //return false
$ipv4->getIpVersion(); //return '4'

$ipfuture = new Host('v32.1.2.3.4');
$ipfuture->isIp(); //return true
$ipfuture->isIpv4(); //return false
$ipfuture->isIpv6(); //return false
$ipfuture->isIpFuture(); //return true
$ipfuture->getIpVersion(); //return '32'

$domain = new Host('thephpleague.com'):
$domain->isIp(); //return false
$domain->isIpv4(); //return false
$domain->isIpv6(); //return false
$domain->isIpFuture(); //return false
$domain->getIpVersion(); //return null
~~~

### Zone Identifier
Expand Down Expand Up @@ -188,19 +211,60 @@ $host = new Host('[fe80::1%25eth0-1]');
$host->getIp(); //returns 'fe80::1%eth0-1'

$newHost = $host->withContent('uri.thephpleague.com');
$newHost->getIp(); //returns null
$newHost->getIp(); //returns null
$newHost->getIpVersion(); //returns null
~~~

## Host represented by a domain name

<p class="message-warning"><code>Host::getRegisterableDomain</code> and <code>Host::withRegisterableDomain</code> are deprecated and replaced by <code>Host::getRegistrableDomain</code> and <code>Host::withRegistrableDomain</code> starting with version <code>1.5.0</code>.</p>
## Host represented by a registered name

If you don't have a IP then you are dealing with a registered name. A registered name can be a [domain name](http://tools.ietf.org/html/rfc1034) subset if it follows [RFC1123](http://tools.ietf.org/html/rfc1123#section-2.1) but it is not a requirement as stated in [RFC3986](https://tools.ietf.org/html/rfc3986#section-3.2.2)

> (...) URI producers should use names that conform to the DNS syntax, even when use of DNS is not immediately apparent, and should limit these names to no more than 255 characters in length.
<p class="message-info"><code>Host::isDomain</code> is available since version <code>1.8.0</code>.</p>

~~~php
<?php
public Host::isDomain(void): bool
~~~

To determine if a host is a domain name or a general registered name you just need to use the newly added method `Host::isDomain`

~~~php
<?php

use League\Uri\Components\Host;

$domain = new Host('www.example.co.uk');
$domain->isDomain(); //return true

$reg_name = new Host('...test.com');
$reg_name->isDomain(); //return false
~~~

## Host represented by a domain name

<p class="message-warning"><code>Host::getRegisterableDomain</code> and <code>Host::withRegisterableDomain</code> are deprecated and replaced by <code>Host::getRegistrableDomain</code> and <code>Host::withRegistrableDomain</code> starting with version <code>1.5.0</code>.</p>

If you don't have an IP or a general registered name it means you are using a domain name. As such the following method can be used to further caracterize your host.

~~~php
<?php
const Host::IS_RELATIVE = 0;
const Host::IS_ABSOLUTE = 1;
public static Host::createFromLabels(iterable $data, int $type = self::IS_RELATIVE): self
public Host::isAbsolute(void): bool
public Host::getLabels(void): array
public Host::getLabel(int $offset, $default = null): mixed
public Host::keys([string $label]): array
public Host::count(void): int
public Host::getIterator(void): ArrayIterator
public Host::withRootLabel(void): self
public Host::withoutRootLabel(void): self
public Host::prepend(string $host): self
public Host::append(string $host): self
public Host::replaceLabel(int $offset, string $host): self
public Host::withoutLabels(array $offsets): self
public Host::getPublicSuffix(void): string
public Host::isPublicSuffixValid(void): bool
public Host::getRegistrableDomain(void): string
Expand All @@ -224,10 +288,10 @@ Using data from [the public suffix list](http://publicsuffix.org/) every `Host`
use League\Uri\Components\Host;

$host = new Host('www.example.co.uk');
echo $host->getPublicSuffix(); //display 'co.uk'
echo $host->getRegistrableDomain(); //display 'example.co.uk'
echo $host->getSubDomain(); //display 'www'
$host->isPublicSuffixValid(); //return a boolean 'true' in this example
echo $host->getPublicSuffix(); //display 'co.uk'
echo $host->getRegistrableDomain(); //display 'example.co.uk'
echo $host->getSubDomain(); //display 'www'
$host->isPublicSuffixValid(); //return a boolean 'true' in this example
~~~

If the data is not found the methods listed above will all return an **empty string** except for the `Host::isPublicSuffixValid` method which will return `false`.
Expand All @@ -238,10 +302,10 @@ If the data is not found the methods listed above will all return an **empty str
use League\Uri\Components\Host;

$host = new Host('192.158.26.30');
echo $host->getPublicSuffix(); //return ''
echo $host->getRegistrableDomain(); //return ''
echo $host->getSubDomain(); //return ''
$host->isPublicSuffixValid(); //return false
echo $host->getPublicSuffix(); //return ''
echo $host->getRegistrableDomain(); //return ''
echo $host->getSubDomain(); //return ''
$host->isPublicSuffixValid(); //return false
~~~

### Updating the Registrable domain part
Expand Down Expand Up @@ -276,26 +340,6 @@ echo $newHost; //displays 'shop.11.be'

<p class="message-warning">This method throws an <code>League\Uri\Components\Exception</code> if you submit a FQDN.</p>

## Host as a general registered name

~~~php
<?php
const Host::IS_RELATIVE = 0;
const Host::IS_ABSOLUTE = 1;
public static Host::createFromLabels(iterable $data, int $type = self::IS_RELATIVE): self
public Host::isAbsolute(void): bool
public Host::getLabels(void): array
public Host::getLabel(int $offset, $default = null): mixed
public Host::keys([string $label]): array
public Host::count(void): int
public Host::getIterator(void): ArrayIterator
public Host::withRootLabel(void): self
public Host::withoutRootLabel(void): self
public Host::prepend(string $host): self
public Host::append(string $host): self
public Host::replaceLabel(int $offset, string $host): self
public Host::withoutLabels(array $offsets): self
~~~

### Host::createFromLabels

Expand Down
1 change: 0 additions & 1 deletion docs/5.0/components/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ System Requirements
You need:

- **PHP >= 7.0** but the latest stable version of PHP is recommended
- the `mbstring` extension
- the `intl` extension

Installation
Expand Down
3 changes: 2 additions & 1 deletion docs/5.0/parser/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ System Requirements
You need:

- **PHP >= 7.0** but the latest stable version of PHP is recommended
- the `intl` extension

While the library no longer requires out of the box the `intl` extension starting with version `1.4.0` to work, you still require it if you are dealing with URIs containing non-ASCII host. Without it, the parser will throw an exception if such URI is parsed.

Installation
--------
Expand Down
4 changes: 2 additions & 2 deletions docs/5.0/uri/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ System Requirements
You need:

- **PHP >= 7.0.13** but the latest stable version of PHP is recommended
- the `mbstring` extension
- the `intl` extension

While the library no longer requires out of the box the `intl` extension starting with version `1.2.0`, you should still require it if you are dealing with URIs containing non-ASCII host. Without it, URI creation or manipulation action will throw an exception if such hosts are used.

Installation
--------
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ releases:
current:
version: '5.0'
requires: 'PHP >= 7.0.0'
latest: '5.2.0 - 2017-12-01'
latest: '5.3.0 - 2018-03-14'
supported_until: 'TBD'
documentation_link: '/5.0/'
legacy:
Expand Down

0 comments on commit f2bceb7

Please sign in to comment.