mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 14:36:23 +00:00
Compare commits
8
Commits
2.0.8
..
18bfe842f8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18bfe842f8 | ||
|
|
63a0db9109 | ||
|
|
63d6ef1a47 | ||
|
|
116b6c839a | ||
|
|
a35f00ebb3 | ||
|
|
0f9f971556 | ||
|
|
fd1eaf61a7 | ||
|
|
3e40d78a67 |
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "composer"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -30,6 +30,8 @@ return (new PhpCsFixer\Config())
|
||||
'modernize_strpos' => false,
|
||||
// Pulled in by @Symfony, we cannot add property types until we bump PHP to ≥ 7.4
|
||||
'no_null_property_initialization' => false,
|
||||
// @Symfony:risky started removing them but we will probably want to go the opposite direction.
|
||||
'declare_strict_types' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
||||
+7
-4
@@ -30,12 +30,12 @@
|
||||
"masterminds/html5": "^2.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.0",
|
||||
"friendsofphp/php-cs-fixer": "3.95.8",
|
||||
"monolog/monolog": "^1.24|^2.1",
|
||||
"symfony/phpunit-bridge": "^4.4|^5.3|^6.0|^7.0",
|
||||
"phpstan/phpstan": "^2.0",
|
||||
"phpstan/phpstan-phpunit": "^2.0",
|
||||
"rector/rector": "^2.0.0"
|
||||
"phpstan/phpstan": "2.2.2",
|
||||
"phpstan/phpstan-phpunit": "2.0.16",
|
||||
"rector/rector": "2.4.6"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-tidy": "Used to clean up given HTML and to avoid problems with bad HTML structure."
|
||||
@@ -46,6 +46,9 @@
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Tests\\Readability\\": "tests/" }
|
||||
},
|
||||
"config": {
|
||||
"lock": false
|
||||
},
|
||||
"scripts": {
|
||||
"fix": "php-cs-fixer fix --verbose --diff",
|
||||
"phpstan": "phpstan analyze --memory-limit 512M",
|
||||
|
||||
@@ -43,7 +43,7 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
* $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>';
|
||||
* ```
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
public function __set(string $name, string $value): void
|
||||
{
|
||||
if ('innerHTML' !== $name) {
|
||||
$trace = debug_backtrace();
|
||||
@@ -108,7 +108,7 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
* $string = $div->innerHTML;
|
||||
* ```
|
||||
*/
|
||||
public function __get($name)
|
||||
public function __get(string $name): string
|
||||
{
|
||||
if ('innerHTML' === $name) {
|
||||
$inner = '';
|
||||
@@ -124,20 +124,22 @@ class JSLikeHTMLElement extends \DOMElement
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], \E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return '[' . $this->tagName . ']';
|
||||
}
|
||||
|
||||
public function getInnerHtml()
|
||||
public function getInnerHtml(): string
|
||||
{
|
||||
return $this->__get('innerHTML');
|
||||
}
|
||||
|
||||
public function setInnerHtml($value)
|
||||
public function setInnerHtml(string $value): void
|
||||
{
|
||||
return $this->__set('innerHTML', $value);
|
||||
$this->__set('innerHTML', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,8 +538,8 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase
|
||||
$res = $readability->init();
|
||||
|
||||
$this->assertTrue($res);
|
||||
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
|
||||
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
|
||||
$this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent());
|
||||
$this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle());
|
||||
$this->assertSame('Tõde ja õigus I', $readability->getTitle()->getInnerHtml());
|
||||
$this->assertStringContainsString('Päike lähenes', $readability->getContent()->getInnerHtml());
|
||||
}
|
||||
@@ -584,7 +584,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertTrue($res);
|
||||
$this->assertInstanceOf(\DOMDocument::class, $readability->dom);
|
||||
$this->assertSame($lang, $readability->dom->documentElement->getAttribute('lang'));
|
||||
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
|
||||
$this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent());
|
||||
$this->assertStringContainsString('êtres', $readability->getContent()->getInnerHtml());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user