Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ yarn.lock
docs/css/*.map
.deptrac.cache
.phpunit.result.cache
code_samples/_inline_php/
16 changes: 16 additions & 0 deletions .php-cs-fixer-factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;

$configFactory = new InternalConfigFactory();
$configFactory->withRules([
'header_comment' => false,
]);

return $configFactory;
30 changes: 30 additions & 0 deletions .php-cs-fixer-inline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

/**
* PHP-CS-Fixer configuration for auto-generated inline snippets in code_samples/_inline_php/.
*
* Builds on top of the main .php-cs-fixer.php configuration with additional
* rule overrides:
* - psr_autoloading is disabled: snippet files are named line_N.php and do not
* correspond to any class, so the filename≠class-name rule does not apply.
*/
$configFactory = require __DIR__ . '/.php-cs-fixer-factory.php';

$configFactory->withRules([
'psr_autoloading' => false,
'AdamWojs/phpdoc_force_fqcn_fixer' => false,
]);

return $configFactory
->buildConfig()
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/code_samples/_inline_php')
->files()->name('*.php')
);
8 changes: 2 additions & 6 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
*/
declare(strict_types=1);

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;

$configFactory = new InternalConfigFactory();
$configFactory->withRules([
'header_comment' => false,
]);
$configFactory = require __DIR__ . '/.php-cs-fixer-factory.php';

return $configFactory
->buildConfig()
Expand All @@ -23,5 +18,6 @@
__DIR__ . '/tests',
], 'is_dir')
)
->exclude('_inline_php') // handled separately by .php-cs-fixer-inline.php
->files()->name('*.php')
);
25 changes: 20 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,25 @@
"ibexa/fastly": "~5.0.x-dev"
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --dry-run",
"phpstan": "phpstan analyse",
"deptrac": "deptrac analyse",
"check-rector": "rector process --dry-run --ansi",
"fix-cs": [
"php tools/extract-inline-php.php",
"php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"php-cs-fixer fix --config=.php-cs-fixer-inline.php -v --show-progress=dots",
"php tools/sync-inline-php-to-markdown.php"
],
"check-cs": [
"php tools/extract-inline-php.php",
"php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots --dry-run",
"php-cs-fixer fix --config=.php-cs-fixer-inline.php -v --show-progress=dots --dry-run"
],
"phpstan": "php tools/extract-inline-php.php && phpstan analyse",
"deptrac": "php tools/extract-inline-php.php && deptrac analyse",
"fix-rector": [
"php tools/extract-inline-php.php",
"rector process --ansi",
"php tools/sync-inline-php-to-markdown.php"
],
"check-rector": "php tools/extract-inline-php.php && rector process --dry-run --ansi",
"check-yaml": "phpunit --group yaml",
"phpunit": "phpunit --exclude-group=yaml",
"yaml-update-baseline": "php tests/generate-yaml-baseline.php"
Expand All @@ -115,6 +129,7 @@
"check-cs": "Run code style checker for all files",
"phpstan": "Run static code analysis",
"deptrac": "Run Deptrac architecture testing",
"fix-rector": "Automatically applies Rector refactoring to code samples and syncs back to Markdown",
"check-rector": "Check for code refactoring opportunities",
"check-yaml": "Run PHPUnit tests (YAML validation)",
"yaml-update-baseline": "Regenerate tests/yaml-validation-baseline.yaml from current failures"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ It enables you to add a thumbnail URL in the text field.

Add `FieldValueUrl.php` in `src/Thumbnails`.

```php
```php {skip-validation}
<?php

declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can format date and time by using the following services:

To use them, create an `src/Service/MyService.php` file containing:

``` php
``` php {skip-validation}
<?php

namespace App\Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The following method adds a new menu section under **Content**, and under it, a

You can also pass parameters to templates used to render menu items with `template_parameters`:

``` php
``` php {skip-validation}
$menu->addChild(
'all_content_list',
[
Expand All @@ -105,7 +105,7 @@ You can then use the variable `custom_parameter` in `templates/themes/admin/list

To have translatable labels, use `translation.key` from the `messages` domain:

``` php
``` php {skip-validation}
$menu->addChild(
'all_content_list',
[
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/back_office/browser/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ If an event listener catches additional parameters passed with context, it uses

In the example below, the `johndoe` parameter enables the user to choose multiple items from a **Browser window** by changing `multiple: false` from `my_custom_udw` configuration to `multiple: true`.

```php hl_lines="29 30 31"
```php {skip-validation} hl_lines="29 30 31"
class JohnDoeCanSelectMore implements EventSubscriberInterface
{
private const CONFIGURATION_NAME = 'my_custom_udw';
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/back_office/customize_calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ To add an in-memory collection as an event source, create `src/Calendar/Holidays

For example:

``` php
``` php {skip-validation}
$collection = new EventCollection([
$this->createEvent("Event 1", new DateTime("2024-01-01")),
$this->createEvent("Event 2", new DateTime("2024-01-02")),
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/back_office/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ There are four types of notifications: `info`, `success`, `warning` and `error`.

To send a notification from PHP, inject the `TranslatableNotificationHandlerInterface` into your class.

``` php
``` php {skip-validation}
$this->notificationHandler->info(
/** @Desc("Notification text") */
'example.notification.text',
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parameters:
an_array: [apple, banana, pear]
```

``` php
``` php {skip-validation}
// Usage inside a controller
$myParameter = $this->container->getParameter( 'myapp.parameter.name' );
```
Expand Down
4 changes: 2 additions & 2 deletions docs/administration/configuration/dynamic_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ parameters:

Inside a controller, in `site_group` SiteAccess, you can use the parameters in the following way (the same applies for `hasParameter()`):

``` php
``` php {skip-validation}
$configResolver = $this->getConfigResolver();

// ibexa.site_access.config is the default namespace, so no need to specify it
Expand Down Expand Up @@ -77,7 +77,7 @@ For more information about dependency injection, see [Service container](php_api
Don't store the retrieved config value unless you know what you're doing.
SiteAccess can change during code execution, which means you might work on the wrong value.

``` php
``` php {skip-validation}
namespace App;

use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
Expand Down
6 changes: 3 additions & 3 deletions docs/administration/configuration/repository_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ This enables you to use different settings for different repositories.

To do this, create a parser that implements `Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface`:

``` php
``` php {skip-validation}
use Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

Expand All @@ -326,7 +326,7 @@ final class CustomRepositoryConfigParser implements RepositoryConfigParserInterf

You need to register this configuration extension in the following way:

``` php
``` php {skip-validation}
final class AcmeFeatureBundle extends Bundle
{
public function build(ContainerBuilder $container): void
Expand All @@ -342,6 +342,6 @@ final class AcmeFeatureBundle extends Bundle

To access the configuration settings, use the `Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider::getRepositoryConfig` method:

``` php
``` php {skip-validation}
$acmeConfig = $repositoryConfigProvider->getRepositoryConfig()['acme'];
```
2 changes: 1 addition & 1 deletion docs/ai_actions/configure_ai_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ composer require ibexa/connector-gemini

Then, if not using Symfony Flex, enable the bundle in `config/bundles.php`:

``` php
``` php {skip-validation}
Ibexa\Bundle\ConnectorGemini\IbexaConnectorGeminiBundle::class => ['all' => true],
```

Expand Down
4 changes: 2 additions & 2 deletions docs/api/php_api/php_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ You can use this method to perform an action that the current user doesn't have

For example, to [hide a Location](managing_content.md#hiding-and-revealing-locations), use:

``` php
``` php {skip-validation}
use Ibexa\Contracts\Core\Repository\Repository;

//...
Expand Down Expand Up @@ -147,7 +147,7 @@ For example if you're using a command which takes the content ID as a parameter,

Both cases should be covered with error messages:

``` php
``` php {skip-validation}
try {
// ...
} catch (\Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If the returned value was depending on a location, it could have been wrapped in

`CachedValue` is used in the following way:

```php
```php {skip-validation}
return new CachedValue(
new MyValue($args…),
['locationId'=> $locationId]
Expand Down
6 changes: 3 additions & 3 deletions docs/commerce/cart/cart_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ To update cart metadata, use the `CartServiceInterface::updateCartMetadata` meth

You can also use this method to change cart ownership:

``` php
``` php {skip-validation}
use Ibexa\Contracts\Cart\Value\CartMetadataUpdateStruct;

// ...
Expand Down Expand Up @@ -150,7 +150,7 @@ It can include any relevant information that you want to associate with a partic

To add context data to a cart, follow this example:

```php
```php {skip-validation}
$createStruct = new CartCreateStruct(...);
$createStruct->setContext(new ArrayMap([
'coupon_code' => 'X1MF7699',
Expand All @@ -166,7 +166,7 @@ You also add "X1MF7699" coupon code as context data to the cart.

To attach context data to a cart entry, proceed as follows:

```php
```php {skip-validation}
$entryAddStruct = new EntryAddStruct(...);
$entryAddStruct->setContext(new ArrayMap([
'tshirt_text' => 'EqEqEqEq',
Expand Down
2 changes: 1 addition & 1 deletion docs/commerce/shopping_list/install_shopping_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ composer require ibexa/shopping-list
The associated Symfony Flex recipe configures the bundle and its routes.

Check that the following line has been added by the recipe to `config/bundles.php` file's array:
```php
```php {skip-validation}
Ibexa\Bundle\ShoppingList\IbexaShoppingListBundle::class => ['all' => true],
```

Expand Down
4 changes: 2 additions & 2 deletions docs/commerce/shopping_list/shopping_list_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ and with sort clauses from the [`SortClause` namespace](/api/php_api/php_api_ref

To get all shopping lists (of the current user or of the whole repository depending on the current user limitation), use the search method without criterion:

```php
```php {skip-validation}
$lists = $this->shoppingListService->findShoppingLists(new ShoppingListQuery());
```

Expand All @@ -56,7 +56,7 @@ If you forgot to retrieve this result in your variable, the local object isn't s
In the following example, if some assignments (`$list =`) are removed, the dumped `$list` object doesn't contain the stored shopping list at that time.
If only the middle assignment is removed, the last dumped variable contains the up-to-date shopping list.

```php
```php {skip-validation}
$list = $this->shoppingListService->getOrCreateDefaultShoppingList();
dump($list);
$list = $this->shoppingListService->clearShoppingList($list);
Expand Down
2 changes: 1 addition & 1 deletion docs/commerce/storefront/configure_storefront.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The basic configuration of the Storefront can look as follows:

The `\Ibexa\Contracts\Storefront\Repository\CatalogResolverInterface` interface allows retrieving the product catalog available for a specific user.

```php
```php {skip-validation}
namespace Ibexa\Contracts\Storefront\Repository;

use Ibexa\Contracts\Core\Repository\Values\User\User;
Expand Down
2 changes: 1 addition & 1 deletion docs/commerce/storefront/extend_storefront.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ After you modify the controller, it can also pass the following parameters:
Define your own logic in a custom controller.
Refer to the code snippet below and create your own file, for example, `CustomProductRenderController.php`:

``` php
``` php {skip-validation}
public function renderAction(ProductInterface $product): Response
{
return $this->render('@ibexadesign/storefront/product_card.html.twig', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ framework:
[[= product_name =]] comes with a predefined [set of variables](transactional_emails_parameters.md) that you can use when building a template for your transactional email campaign at Actito.
If this list isn't sufficient, you can use Events to include additional variables:

```php
```php {skip-validation}
<?php

namespace App\EventSubscriber;
Expand Down Expand Up @@ -79,7 +79,7 @@ You do it by means of events that are triggered during profile building.

For example, the `Ibexa\Contracts\ConnectorActito\Event\TransactionalMailRequest\ProfileFactoryEvent` event is triggered for every transactional notification, and it lets you set required data that is passed to Actito API:

```php
```php {skip-validation}
<?php

namespace App\EventSubscriber;
Expand Down Expand Up @@ -134,7 +134,7 @@ You could do it by adding a language suffix to a campaign name.

On [[= product_name =]] side, to support this scenario, you must use an Event Subscriber on `Ibexa\Contracts\ConnectorActito\Event\ResolveCampaignEvent`:

```php
```php {skip-validation}
<?php

namespace App\EventSubscriber;
Expand Down Expand Up @@ -164,4 +164,4 @@ final class ResolveCampaginEventSubscriber implements EventSubscriberInterface
$event->setCampaign($campaign);
}
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It also modifies the permission system to account for the new functionality.

Then, if not using Symfony Flex, add the following code to the `config/bundles.php` file:

``` php
``` php {skip-validation}
<?php

return [
Expand Down
Loading
Loading