docs: emphasize strict types (#4657)
Some checks failed
Tests / phpunit8 (7.4) (push) Has been cancelled
Tests / phpunit8 (8.0) (push) Has been cancelled
Tests / phpunit8 (8.1) (push) Has been cancelled
Tests / phpunit8 (8.2) (push) Has been cancelled
Tests / phpunit8 (8.3) (push) Has been cancelled
Tests / phpunit8 (8.4) (push) Has been cancelled
Build Image on Commit and Release / bake (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
Lint / phpcs (7.4) (push) Has been cancelled
Lint / phpcompatibility (7.4) (push) Has been cancelled
Lint / executable_php_files_check (push) Has been cancelled

This commit is contained in:
Dag 2025-08-05 21:06:40 +02:00 committed by GitHub
parent 9caa043fe1
commit a128c05a97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 26 deletions

View file

@ -321,13 +321,23 @@ The sqlite files (db, wal and shm) are not writeable.
rm cache/*
### How to create a new bridge from scratch
### How to create a completely new bridge
New code files MUST have `declare(strict_types=1);` at the top of file:
```php
<?php
declare(strict_types=1);
```
Create the new bridge in e.g. `bridges/BearBlogBridge.php`:
```php
<?php
declare(strict_types=1);
class BearBlogBridge extends BridgeAbstract
{
const NAME = 'BearBlog (bearblog.dev)';

View file

@ -1,31 +1,36 @@
Create a new file in the `bridges/` folder (see [Folder structure](../04_For_Developers/03_Folder_structure.md)).
# How to create a completely new bridge
The file name must be named according to following specification:
* It starts with the full name of the site
* All white-space must be removed
* The first letter of a word is written in upper-case, unless the site name is specified otherwise (example: Freenews, not FreeNews, because the site is named 'Freenews')
* The first character must be upper-case
* The file name must end with 'Bridge'
* The file type must be PHP, written in **small** letters (seriously!) ".php"
**Examples:**
Site | Filename
-----|---------
Wikipedia | **Wikipedia**Bridge.php
Facebook | **Facebook**Bridge.php
GitHub | **GitHub**Bridge.php
Freenews | **Freenews**Bridge.php
The file must start with the PHP tags and end with an empty line. The closing tag `?>` is [omitted](http://php.net/basic-syntax.instruction-separation).
**Example:**
New code files MUST have `declare(strict_types=1);` at the top of file:
```php
<?php
// PHP code here
// This line is empty (just imagine it!)
declare(strict_types=1);
```
The next step is to extend one of the base classes.
Refer to one of an base classes listed on the [Bridge API](../05_Bridge_API/index.md) page.
Create the new bridge in e.g. `bridges/BearBlogBridge.php`:
```php
<?php
declare(strict_types=1);
class BearBlogBridge extends BridgeAbstract
{
const NAME = 'BearBlog (bearblog.dev)';
public function collectData()
{
$dom = getSimpleHTMLDOM('https://herman.bearblog.dev/blog/');
foreach ($dom->find('.blog-posts li') as $li) {
$a = $li->find('a', 0);
$this->items[] = [
'title' => $a->plaintext,
'uri' => 'https://herman.bearblog.dev' . $a->href,
];
}
}
}
```
Learn more in [bridge api](https://rss-bridge.github.io/rss-bridge/Bridge_API/index.html).