Skip to content

Commit fe91a0e

Browse files
committed
Revert changes
- remove functions/constant imports - remove self:: in tests - remove php-cs-fixer rules that removes redundant PHPDoc comments
1 parent fb2f224 commit fe91a0e

22 files changed

+490
-395
lines changed

.php_cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ return PhpCsFixer\Config::create()
3232
'no_empty_phpdoc' => true,
3333
'no_empty_comment' => true,
3434
'no_leading_import_slash' => true,
35-
'no_superfluous_phpdoc_tags' => true,
3635
'no_trailing_comma_in_singleline_array' => true,
3736
'no_unused_imports' => true,
3837
'ordered_imports' => ['imports_order' => null, 'sort_algorithm' => 'alpha'],

src/Cache.php

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,6 @@
2020
use Generator;
2121
use Psr\SimpleCache\CacheInterface;
2222
use Traversable;
23-
use const DIRECTORY_SEPARATOR;
24-
use function chmod;
25-
use function dirname;
26-
use function file_exists;
27-
use function file_get_contents;
28-
use function filemtime;
29-
use function get_class;
30-
use function gettype;
31-
use function is_array;
32-
use function is_dir;
33-
use function is_int;
34-
use function is_object;
35-
use function is_string;
36-
use function is_writable;
37-
use function mkdir;
38-
use function preg_match;
39-
use function realpath;
40-
use function rename;
41-
use function serialize;
42-
use function sprintf;
43-
use function time;
44-
use function touch;
45-
use function uniqid;
46-
use function unlink;
47-
use function unserialize;
4823

4924
/**
5025
* A simple file-based PSR-16 cache implementation.
@@ -166,6 +141,10 @@ public function set($key, $value, $ttl = null)
166141

167142
/**
168143
* Returns the expiration time expressed in the number of seconds since the Unix Epoch.
144+
*
145+
* @param mixed $ttl
146+
*
147+
* @return int
169148
*/
170149
private function getExpireAt($ttl): int
171150
{

src/Converter.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
use Pdp\Exception\CouldNotLoadRules;
1919
use SplTempFileObject;
20-
use function array_pop;
21-
use function explode;
22-
use function preg_match;
23-
use function strpos;
24-
use function substr;
2520

2621
/**
2722
* Public Suffix List Parser.
@@ -57,6 +52,10 @@ final class Converter implements PublicSuffixListSection
5752
/**
5853
* Convert the Public Suffix List into
5954
* an associative, multidimensional array.
55+
*
56+
* @param string $content
57+
*
58+
* @return array
6059
*/
6160
public function convert(string $content): array
6261
{
@@ -80,6 +79,8 @@ public function convert(string $content): array
8079
*
8180
* @param string $section the current status
8281
* @param string $line the current file line
82+
*
83+
* @return string
8384
*/
8485
private function getSection(string $section, string $line): string
8586
{
@@ -104,7 +105,9 @@ private function getSection(string $section, string $line): string
104105
* @param array $rule_parts One line (rule) from the Public Suffix List
105106
* exploded on '.', or the remaining portion of that array during recursion
106107
*
107-
* @throws Exception if The domain name is invalid
108+
* @throws CouldNotLoadRules if the domain name can not be converted using IDN to ASCII algorithm
109+
*
110+
* @return array
108111
*/
109112
private function addRule(array $list, array $rule_parts): array
110113
{

src/CurlHttpClient.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@
1515

1616
namespace Pdp;
1717

18-
use const CURLE_OK;
19-
use const CURLOPT_FAILONERROR;
20-
use const CURLOPT_FOLLOWLOCATION;
21-
use const CURLOPT_HTTPGET;
22-
use const CURLOPT_RETURNTRANSFER;
23-
use const CURLOPT_SSL_VERIFYHOST;
24-
use const CURLOPT_SSL_VERIFYPEER;
25-
use function curl_close;
26-
use function curl_errno;
27-
use function curl_error;
28-
use function curl_exec;
29-
use function curl_init;
30-
use function curl_setopt_array;
31-
3218
final class CurlHttpClient implements HttpClient
3319
{
3420
/**
@@ -47,8 +33,8 @@ public function __construct(array $options = [])
4733
CURLOPT_FAILONERROR => true,
4834
CURLOPT_FOLLOWLOCATION => true,
4935
CURLOPT_RETURNTRANSFER => true,
50-
CURLOPT_SSL_VERIFYHOST => 0,
51-
CURLOPT_SSL_VERIFYPEER => false,
36+
CURLOPT_SSL_VERIFYPEER => true,
37+
CURLOPT_SSL_VERIFYHOST => 2,
5238
CURLOPT_HTTPGET => true,
5339
];
5440

src/Domain.php

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,6 @@
2121
use Pdp\Exception\InvalidLabel;
2222
use Pdp\Exception\InvalidLabelKey;
2323
use TypeError;
24-
use function array_count_values;
25-
use function array_keys;
26-
use function array_reverse;
27-
use function array_slice;
28-
use function array_unshift;
29-
use function count;
30-
use function explode;
31-
use function gettype;
32-
use function implode;
33-
use function in_array;
34-
use function is_scalar;
35-
use function ksort;
36-
use function method_exists;
37-
use function preg_match;
38-
use function sprintf;
39-
use function strlen;
40-
use function strpos;
41-
use function substr;
4224

4325
/**
4426
* Domain Value Object.
@@ -96,8 +78,8 @@ public static function __set_state(array $properties): self
9678
/**
9779
* New instance.
9880
*
99-
* @param PublicSuffix $publicSuffix
100-
* @param null|mixed $domain
81+
* @param null|mixed $domain
82+
* @param null|PublicSuffix $publicSuffix
10183
*/
10284
public function __construct($domain = null, PublicSuffix $publicSuffix = null)
10385
{
@@ -113,7 +95,11 @@ public function __construct($domain = null, PublicSuffix $publicSuffix = null)
11395
/**
11496
* Sets the public suffix domain part.
11597
*
98+
* @param PublicSuffix $publicSuffix
99+
*
116100
* @throws CouldNotResolvePublicSuffix If the public suffic can not be attached to the domain
101+
*
102+
* @return PublicSuffix
117103
*/
118104
private function setPublicSuffix(PublicSuffix $publicSuffix): PublicSuffix
119105
{
@@ -140,6 +126,10 @@ private function setPublicSuffix(PublicSuffix $publicSuffix): PublicSuffix
140126

141127
/**
142128
* Normalize the domain name encoding content.
129+
*
130+
* @param PublicSuffix $subject
131+
*
132+
* @return PublicSuffix
143133
*/
144134
private function normalize(PublicSuffix $subject): PublicSuffix
145135
{
@@ -297,7 +287,7 @@ public function keys(string $label): array
297287
*
298288
* This method returns null if the registrable domain is equal to the public suffix.
299289
*
300-
* @return string|null
290+
* @return string|null registrable domain
301291
*/
302292
public function getRegistrableDomain()
303293
{
@@ -312,7 +302,7 @@ public function getRegistrableDomain()
312302
* This method returns null if the registrable domain is null
313303
* This method returns null if the registrable domain is equal to the public suffix
314304
*
315-
* @return string|null
305+
* @return string|null registrable domain
316306
*/
317307
public function getSubDomain()
318308
{
@@ -335,6 +325,8 @@ public function getPublicSuffix()
335325
* A domain is resolvable if:
336326
* - it contains at least 2 labels
337327
* - it is not a absolute domain (end with a '.' character)
328+
*
329+
* @return bool
338330
*/
339331
public function isResolvable(): bool
340332
{
@@ -343,6 +335,8 @@ public function isResolvable(): bool
343335

344336
/**
345337
* Tells whether the public suffix has a matching rule in a Public Suffix List.
338+
*
339+
* @return bool
346340
*/
347341
public function isKnown(): bool
348342
{
@@ -351,6 +345,8 @@ public function isKnown(): bool
351345

352346
/**
353347
* Tells whether the public suffix has a matching rule in a Public Suffix List ICANN Section.
348+
*
349+
* @return bool
354350
*/
355351
public function isICANN(): bool
356352
{
@@ -359,6 +355,8 @@ public function isICANN(): bool
359355

360356
/**
361357
* Tells whether the public suffix has a matching rule in a Public Suffix List Private Section.
358+
*
359+
* @return bool
362360
*/
363361
public function isPrivate(): bool
364362
{
@@ -404,6 +402,10 @@ public function toUnicode()
404402
*
405403
* This method MUST retain the state of the current instance, and return
406404
* an instance that contains the modified Public Suffix Information.
405+
*
406+
* @param mixed $publicSuffix
407+
*
408+
* @return self
407409
*/
408410
public function resolve($publicSuffix): self
409411
{
@@ -427,6 +429,10 @@ public function resolve($publicSuffix): self
427429
*
428430
* If the domain already has a public suffix it will be replaced by the new value
429431
* otherwise the public suffix content is added to or remove from the current domain.
432+
*
433+
* @param mixed $publicSuffix
434+
*
435+
* @return self
430436
*/
431437
public function withPublicSuffix($publicSuffix): self
432438
{
@@ -447,14 +453,18 @@ public function withPublicSuffix($publicSuffix): self
447453
return new self($domain.'.'.$publicSuffix->getContent(), $publicSuffix);
448454
}
449455

456+
450457
/**
451458
* Returns an instance with the specified sub domain added.
452459
*
453460
* This method MUST retain the state of the current instance, and return
454461
* an instance that contains the new sub domain
455462
*
463+
* @param mixed $subDomain the subdomain to add
456464
*
457465
* @throws CouldNotResolveSubDomain If the Sub domain can not be added to the current Domain
466+
*
467+
* @return self
458468
*/
459469
public function withSubDomain($subDomain): self
460470
{
@@ -477,6 +487,8 @@ public function withSubDomain($subDomain): self
477487
/**
478488
* Filter a subdomain to update the domain part.
479489
*
490+
* @param mixed $domain
491+
*
480492
* @throws TypeError if the domain can not be converted
481493
*
482494
* @return string|null
@@ -511,6 +523,10 @@ private function normalizeContent($domain)
511523
* Prepends a label to the domain.
512524
*
513525
* @see ::withLabel
526+
*
527+
* @param mixed $label
528+
*
529+
* @return self
514530
*/
515531
public function prepend($label): self
516532
{
@@ -521,6 +537,10 @@ public function prepend($label): self
521537
* Appends a label to the domain.
522538
*
523539
* @see ::withLabel
540+
*
541+
* @param mixed $label
542+
*
543+
* @return self
524544
*/
525545
public function append($label): self
526546
{
@@ -536,8 +556,13 @@ public function append($label): self
536556
* If $key is non-negative, the added label will be the label at $key position from the start.
537557
* If $key is negative, the added label will be the label at $key position from the end.
538558
*
559+
* @param int $key
560+
* @param mixed $label
561+
*
539562
* @throws InvalidLabelKey If the key is out of bounds
540563
* @throws InvalidLabel If the label is converted to the NULL value
564+
*
565+
* @return self
541566
*/
542567
public function withLabel(int $key, $label): self
543568
{
@@ -579,9 +604,12 @@ public function withLabel(int $key, $label): self
579604
* If $key is non-negative, the removed label will be the label at $key position from the start.
580605
* If $key is negative, the removed label will be the label at $key position from the end.
581606
*
607+
* @param int $key
582608
* @param int ...$keys remaining keys to remove
583609
*
584610
* @throws InvalidLabelKey If the key is out of bounds
611+
*
612+
* @return self
585613
*/
586614
public function withoutLabel(int $key, int ...$keys): self
587615
{

src/HttpClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface HttpClient
2929
/**
3030
* Returns the content fetched from a given URL.
3131
*
32+
* @param string $url
3233
*
3334
* @throws HttpClientException If an errors occurs while fetching the content from a given URL
3435
*

0 commit comments

Comments
 (0)