Skip to content

Commit 63cd550

Browse files
authored
Update repo (#3)
* Revert "migrate to github actions (#2)" This reverts commit f9ec3d0. * fix repo * fix * cleaning deps * exclude 8.1 low * bye travis
1 parent f9ec3d0 commit 63cd550

15 files changed

+464
-544
lines changed

.github/workflows/CI.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
operating-system: [ubuntu-20.04]
2121
php-versions: ['7.4', '8.0', '8.1']
2222
dependencies: ['no', 'low', 'beta']
23-
include:
23+
exclude:
2424
- operating-system: ubuntu-20.04
25-
php-versions: '8.0'
26-
continue-on-error: true
25+
php-versions: '8.1'
26+
dependencies: 'low'
2727

2828
name: PHP ${{ matrix.php-versions }} - ${{ matrix.dependencies }}
2929

@@ -58,6 +58,10 @@ jobs:
5858
path: ~/.composer/cache/files
5959
key: dependencies-composer-${{ hashFiles('composer.json') }}
6060

61+
- name: Fix beta
62+
if: ${{ matrix.dependencies == 'beta' }}
63+
run: perl -pi -e 's/^}$/,"minimum-stability":"beta"}/' composer.json
64+
6165
- name: Setup PHP Action
6266
uses: shivammathur/setup-php@2.8.0
6367
with:
@@ -91,8 +95,5 @@ jobs:
9195
- name: Validate files
9296
run: composer validate-files
9397

94-
- name: Check Style
95-
run: composer check-code-style
96-
97-
# - name: Run tests
98-
# run: composer run-tests
98+
- name: Run tests
99+
run: composer run-tests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ composer.phar
44
composer.lock
55
.DS_Store
66
.php-cs-fixer.cache
7-
.phpunit.result.cache
7+
.phpunit.result.cache

composer.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,10 @@
2626

2727
"require-dev": {
2828
"php-parallel-lint/php-parallel-lint": "^1.2",
29-
"phpmd/phpmd": "^2.9",
30-
"phpunit/phpunit": "^9.3",
31-
"sebastian/phpcpd": ">=4.1",
32-
"friendsofphp/php-cs-fixer": ">=2.17",
33-
"squizlabs/php_codesniffer": "^3.5"
29+
"phpunit/phpunit": "^9.3"
3430
},
3531

3632
"scripts": {
37-
"check-code-style": [
38-
"vendor/bin/phpcs --standard=PSR2 ./src/"
39-
],
4033
"run-tests": [
4134
"vendor/bin/phpunit -c phpunit.xml",
4235
"vendor/bin/phpunit --coverage-clover=coverage.xml"
@@ -59,4 +52,4 @@
5952
]
6053
}
6154
}
62-
}
55+
}

phpunit.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="phpunit.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory>./src</directory>
6-
</include>
7-
</coverage>
8-
<testsuites>
9-
<testsuite name="Package Test Suite">
10-
<directory suffix=".php">./tests/</directory>
11-
</testsuite>
12-
</testsuites>
13-
</phpunit>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="phpunit.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory>./src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Package Test Suite">
10+
<directory suffix=".php">./tests/</directory>
11+
</testsuite>
12+
</testsuites>
13+
</phpunit>

src/AncestorsRelation.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class AncestorsRelation extends BaseRelation
1313
*/
1414
public function addConstraints()
1515
{
16-
if (! static::$constraints) {
17-
return;
18-
}
16+
if ( ! static::$constraints) return;
1917

2018
$this->query->whereAncestorOf($this->parent)
2119
->applyNestedSetScope();

src/BaseRelation.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class BaseRelation extends Relation
3636
*/
3737
public function __construct(QueryBuilder $builder, Model $model)
3838
{
39-
if (! NestedSet::isNode($model)) {
39+
if ( ! NestedSet::isNode($model)) {
4040
throw new InvalidArgumentException('Model must be node.');
4141
}
4242

@@ -76,10 +76,8 @@ abstract protected function relationExistenceCondition($hash, $table, $lft, $rgt
7676
*
7777
* @return mixed
7878
*/
79-
public function getRelationExistenceQuery(
80-
EloquentBuilder $query,
81-
EloquentBuilder $parent,
82-
$columns = [ '*' ]
79+
public function getRelationExistenceQuery(EloquentBuilder $query, EloquentBuilder $parent,
80+
$columns = [ '*' ]
8381
) {
8482
$query = $this->getParent()->replicate()->newScopedQuery()->select($columns);
8583

@@ -95,8 +93,7 @@ public function getRelationExistenceQuery(
9593
$grammar->wrapTable($hash),
9694
$grammar->wrapTable($table),
9795
$grammar->wrap($this->parent->getLftName()),
98-
$grammar->wrap($this->parent->getRgtName())
99-
);
96+
$grammar->wrap($this->parent->getRgtName()));
10097

10198
return $query->whereRaw($condition);
10299
}
@@ -122,8 +119,7 @@ public function initRelation(array $models, $relation)
122119
* @return mixed
123120
*/
124121
public function getRelationQuery(
125-
EloquentBuilder $query,
126-
EloquentBuilder $parent,
122+
EloquentBuilder $query, EloquentBuilder $parent,
127123
$columns = [ '*' ]
128124
) {
129125
return $this->getRelationExistenceQuery($query, $parent, $columns);

src/Collection.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ class Collection extends BaseCollection
1616
*/
1717
public function linkNodes()
1818
{
19-
if ($this->isEmpty()) {
20-
return $this;
21-
}
19+
if ($this->isEmpty()) return $this;
2220

2321
$groupedNodes = $this->groupBy($this->first()->getParentIdName());
2422

2523
/** @var NodeTrait|Model $node */
2624
foreach ($this->items as $node) {
27-
if (! $node->getParentId()) {
25+
if ( ! $node->getParentId()) {
2826
$node->setRelation('parent', null);
2927
}
3028

@@ -55,7 +53,7 @@ public function linkNodes()
5553
public function toTree($root = false)
5654
{
5755
if ($this->isEmpty()) {
58-
return new static();
56+
return new static;
5957
}
6058

6159
$this->linkNodes();
@@ -114,11 +112,9 @@ protected function getRootNodeId($root = false)
114112
*/
115113
public function toFlatTree($root = false)
116114
{
117-
$result = new static();
115+
$result = new static;
118116

119-
if ($this->isEmpty()) {
120-
return $result;
121-
}
117+
if ($this->isEmpty()) return $result;
122118

123119
$groupedNodes = $this->groupBy($this->first()->getParentIdName());
124120

@@ -143,4 +139,5 @@ protected function flattenTree(self $groupedNodes, $parentId)
143139

144140
return $this;
145141
}
146-
}
142+
143+
}

src/DescendantsRelation.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77

88
class DescendantsRelation extends BaseRelation
99
{
10+
1011
/**
1112
* Set the base constraints on the relation query.
1213
*
1314
* @return void
1415
*/
1516
public function addConstraints()
1617
{
17-
if (! static::$constraints) {
18-
return;
19-
}
18+
if ( ! static::$constraints) return;
2019

2120
$this->query->whereDescendantOf($this->parent)
2221
->applyNestedSetScope();
@@ -54,4 +53,4 @@ protected function relationExistenceCondition($hash, $table, $lft, $rgt)
5453
{
5554
return "{$hash}.{$lft} between {$table}.{$lft} + 1 and {$table}.{$rgt}";
5655
}
57-
}
56+
}

src/NestedSet.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ class NestedSet
99
/**
1010
* The name of default lft column.
1111
*/
12-
public const LFT = '_lft';
12+
const LFT = '_lft';
1313

1414
/**
1515
* The name of default rgt column.
1616
*/
17-
public const RGT = '_rgt';
17+
const RGT = '_rgt';
1818

1919
/**
2020
* The name of default parent id column.
2121
*/
22-
public const PARENT_ID = 'parent_id';
22+
const PARENT_ID = 'parent_id';
2323

2424
/**
2525
* Insert direction.
2626
*/
27-
public const BEFORE = 1;
27+
const BEFORE = 1;
2828

2929
/**
3030
* Insert direction.
3131
*/
32-
public const AFTER = 2;
32+
const AFTER = 2;
3333

3434
/**
3535
* Add default nested set columns to the table. Also create an index.
@@ -79,4 +79,5 @@ public static function isNode($node)
7979
{
8080
return $node instanceof Node;
8181
}
82-
}
82+
83+
}

src/NestedSetServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public function register()
1717
NestedSet::dropColumns($this);
1818
});
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)