Skip to content

Commit

Permalink
Merge pull request #79 from stephandesouza/master
Browse files Browse the repository at this point in the history
Updating Laravel 6 support
  • Loading branch information
specialtactics authored Oct 7, 2019
2 parents 32e611e + daf8cf3 commit 45bbc59
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 54 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"php": ">=5.5.9",
"illuminate/support": "^5.1 || ^6.0",
"illuminate/filesystem": "^5.1 || ^6.0",
"php": "^7.1",
"illuminate/support": "^5.5 || ^6.0",
"illuminate/filesystem": "^5.5 || ^6.0",
"doctrine/annotations": "~1.2",
"phpdocumentor/reflection-docblock": "^3.1|^4.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "~2.0",
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.5"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Dingo\Blueprint;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection;

abstract class Section
Expand All @@ -15,7 +16,7 @@ abstract class Section
*/
protected function getAnnotationByType($type)
{
return array_first($this->annotations, function ($key, $annotation) use ($type) {
return Arr::first($this->annotations, function ($key, $annotation) use ($type) {
$type = sprintf('Dingo\\Blueprint\\Annotation\\%s', $type);

return is_object($annotation) ? $annotation instanceof $type : $key instanceof $type;
Expand Down
4 changes: 2 additions & 2 deletions tests/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Dingo\Blueprint\Tests;

use Dingo\Blueprint\Blueprint;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Illuminate\Support\Collection;
use Illuminate\Filesystem\Filesystem;
use Doctrine\Common\Annotations\SimpleAnnotationReader;

class BlueprintTest extends PHPUnit_Framework_TestCase
class BlueprintTest extends TestCase
{
public function testGeneratingBlueprintForSingleResource()
{
Expand Down
49 changes: 2 additions & 47 deletions tests/LaravelIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,13 @@
<?php

namespace {
$arrayFirstVersion = '5.2';
}

namespace Dingo\Blueprint {

use PHPUnit_Framework_TestCase;
use Illuminate\Support\Collection;
use Illuminate\Filesystem\Filesystem;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
use PHPUnit\Framework\TestCase;

function array_first($array, callable $callback = null, $default = null)
{
global $arrayFirstVersion;
switch ($arrayFirstVersion) {
case '5.2':
if (is_null($callback)) {
return empty($array) ? value($default) : reset($array);
}
foreach ($array as $key => $value) {
if (call_user_func($callback, $key, $value)) {
return $value;
}
}
break;
case '5.3':
if (is_null($callback)) {
if (empty($array)) {
return value($default);
}

foreach ($array as $item) {
return $item;
}
}
foreach ($array as $key => $value) {
if (call_user_func($callback, $value, $key)) {
return $value;
}
}
break;
}

return value($default);
}

class LaravelIntegrationTest extends PHPUnit_Framework_TestCase
class LaravelIntegrationTest extends TestCase
{
protected $simpleExample = <<<'EOT'
FORMAT: 1A
Expand All @@ -60,9 +21,6 @@ class LaravelIntegrationTest extends PHPUnit_Framework_TestCase

public function testGetAnnotationByTypeInLaravel52x()
{
global $arrayFirstVersion;
$arrayFirstVersion = '5.2';

$resources = new Collection([new Tests\Stubs\ActivityController]);

$blueprint = new Blueprint(new SimpleAnnotationReader, new Filesystem);
Expand All @@ -72,9 +30,6 @@ public function testGetAnnotationByTypeInLaravel52x()

public function testGetAnnotationByTypeInLaravel53x()
{
global $arrayFirstVersion;
$arrayFirstVersion = '5.3';

$resources = new Collection([new Tests\Stubs\ActivityController]);

$blueprint = new Blueprint(new SimpleAnnotationReader, new Filesystem);
Expand Down

0 comments on commit 45bbc59

Please sign in to comment.