Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Resolving issues #61

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
name: Fix syling

on:
push:
branches:
- master
- "*.x"
paths:
- "**.php"
push:
branches:
- master
- "*.x"
paths:
- "**.php"

pull_request:
paths:
- "**.php"
pull_request:
paths:
- "**.php"

permissions:
contents: write
contents: write
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
run:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Install dependencies
run: composer install
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: none

- name: Execute php-cs-fixer
run: ./vendor/bin/php-cs-fixer fix
- name: Install dependencies
run: composer install

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
- name: Execute php-cs-fixer
run: ./vendor/bin/php-cs-fixer fix

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
52 changes: 26 additions & 26 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
name: static analysis

on:
push:
branches:
- master
- '*.x'
pull_request:
push:
branches:
- master
- '*.x'
pull_request:

jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: true
run:
runs-on: ubuntu-latest
strategy:
fail-fast: true

steps:
- name: Checkout code
uses: actions/checkout@v3
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
coverage: none
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute PHPStan
run: vendor/bin/phpstan --configuration="phpstan.neon.dist"
- name: Execute PHPStan
run: vendor/bin/phpstan --configuration="phpstan.neon.dist"
42 changes: 21 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: "Tests"

on:
push:
branches:
- master
- '*.x'
pull_request:
push:
branches:
- master
- '*.x'
pull_request:

jobs:
run:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["8.1", "8.2"]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
run:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["8.2", "8.3"]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Execute tests
run: ./vendor/bin/pest
- name: Execute tests
run: ./vendor/bin/pest
55 changes: 31 additions & 24 deletions .github/workflows/view-compiling.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
name: View Compiling

on:
push:
branches:
- master
- "*.x"
paths:
- "**.php"
push:
branches:
- master
- "*.x"
paths:
- "**.php"

pull_request:
paths:
- "**.php"
pull_request:
paths:
- "**.php"

permissions:
contents: write
contents: write
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
run:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Install dependencies
run: composer install
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: none

- name: Execute script
run: php .github/scripts/compile-templates.php
- name: Install dependencies
run: composer install

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Compiling Templates
- name: Execute script
run: php .github/scripts/compile-templates.php

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Compiling Templates
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'curly_braces_position' => ['allow_single_line_anonymous_functions'=>false, 'allow_single_line_empty_anonymous_classes'=>false, 'anonymous_classes_opening_brace'=>'next_line_unless_newline_at_signature_end', 'anonymous_functions_opening_brace'=>'same_line', 'control_structures_opening_brace'=>'next_line_unless_newline_at_signature_end', 'functions_opening_brace'=>'next_line_unless_newline_at_signature_end'],
'declare_equal_normalize' => ['space'=>'single'],
'declare_parentheses' => true,
'echo_tag_syntax' => ['format'=>'short'],
'echo_tag_syntax' => ['format'=>'long'],
'elseif' => true,
'encoding' => true,
'explicit_indirect_variable' => true,
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ You can access blocks through the blocks property.

```php
use BumpCore\EditorPhp\EditorPhp;
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;
use BumpCore\EditorPhp\Blocks\Paragraph;

$editor = EditorPhp::make($json);
Expand Down Expand Up @@ -350,13 +350,13 @@ Now the block performs the final upload and is saved as JSON.
It is impossible to support all blocks out there, so we can implement our own blocks in an easy way. A standard block looks like the following:

```php
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;

class MyCustomBlock extends Block
{
public function render(): string
{
return view('blocks.my-custom-block', ['data' => $this->data]);
return view('blocks.my-custom-block', ['block' => $this]);
}
}
```
Expand Down Expand Up @@ -401,7 +401,7 @@ $this->has('custom.data');
Validating data is not required, but it can make your data safer. Validating block data is quite easy. We just have to add a `rules` method to our block:

```php
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;

class MyCustomBlock extends Block
{
Expand All @@ -428,7 +428,7 @@ When validating the block's data fails, the data will be empty. Data validation
You can purify the HTML of your data if you wish. It's important to prevent injections. Purifying data looks much like validation:

```php
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;

class MyCustomBlock extends Block
{
Expand Down Expand Up @@ -461,7 +461,7 @@ Unlike validation, purifying will only strip unwanted tags and attributes.
As we mentioned earlier, we can generate fake data with `EditorPhp` . But it requires to generate each block's own fake data. To generate fake data we should add static method to our block:

```php
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;

class MyCustomBlock extends Block
{
Expand Down Expand Up @@ -521,7 +521,7 @@ echo $post->content->render();
Also if you are using cast, you may access your model within block instances:

```php
use BumpCore\EditorPhp\Block\Block;
use BumpCore\EditorPhp\Block;
use App\Models\Post;

class MyBlock extends Block
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
}
],
"require": {
"php": "^8.1",
"illuminate/support": "^10.0",
"illuminate/validation": "^10.0"
"php": "^8.2",
"illuminate/support": "^10.0|^11.0",
"illuminate/validation": "^10.0|^11.0",
"symfony/html-sanitizer": "^7.0"
},
"require-dev": {
"pestphp/pest": "^1.22.4",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"orchestra/testbench": "^9.0",
"friendsofphp/php-cs-fixer": "^3.14.4",
"phpstan/phpstan": "^1.10",
"fakerphp/faker": "^1.23"
Expand Down
5 changes: 3 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ parameters:
- resources
- src
- tests
level: 4
level: 5
ignoreErrors:
- "#Unsafe usage of new static#"
- "#Class BumpCore\\\\EditorPhp\\\\EditorPhp has an uninitialized readonly property \\$model. Assign it in the constructor.#"
- "#Readonly property BumpCore\\\\EditorPhp\\\\EditorPhp::\\$time is already assigned.#"
- "#Readonly property BumpCore\\\\EditorPhp\\\\EditorPhp::\\$model is assigned outside of the constructor.#"
- "#Undefined variable: \\$this#"
- "#Call to an undefined method BumpCore\\\\EditorPhp\\\\EditorPhp::getParagraphs\\(\\).#"
- "#Variable \\$data might not be defined.#"
- "#Unreachable statement - code above always terminates.#"
excludePaths:
- resources/php/*
reportUnmatchedIgnoredErrors: false
14 changes: 7 additions & 7 deletions resources/php/bootstrap-five/attaches.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="rounded d-flex gap-3 mb-3">
<div class="bg-light text-uppercase fs-5 fw-bold p-4 rounded"><?= $data('file.extension'); ?></div>
<div class="d-flex mb-3 gap-3 rounded">
<div class="bg-light text-uppercase fs-5 fw-bold rounded p-4"><?php echo $file['extension']; ?></div>
<div>
<p class="text-lg fw-bold mb-0">
<p class="fw-bold mb-0 text-lg">
<a
class="link-dark gap-1 d-inline-flex justify-content-center align-items-center"
href="<?= $data('file.url'); ?>"
class="link-dark d-inline-flex justify-content-center align-items-center gap-1"
href="<?php echo $file['url']; ?>"
target="_blank"
>
<span><?= $data('title') ?? $data('file.name'); ?></span>
<span><?php echo $title ?? $file['name']; ?></span>
<svg
class="inline"
fill="currentColor"
Expand All @@ -27,6 +27,6 @@ class="inline"
</svg>
</a>
</p>
<p class="fw-semibold text-secondary"><small><?= number_format($data('file.size') * 0.000001, 2); ?>MiB</small></p>
<p class="fw-semibold text-secondary"><small><?php echo number_format($file['size'] * 0.000001, 2); ?>MiB</small></p>
</div>
</div>
Loading