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

TEST GitHub Actions #25

Closed
wants to merge 6 commits into from
Closed
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
19 changes: 10 additions & 9 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
name: 'Unit Tests'

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: push

jobs:
build-test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
composer: [lowest, highest]

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP 8
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
tools: none
coverage: none
- name: Composer Install
run: composer update --no-interaction --no-progress --ansi
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.composer }}
- name: Unit Tests
run: ./vendor/bin/pest --colors=always
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
.phpunit.cache
.phpunit.result.cache
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ use function Cspray\AnnotatedTarget\parseAttributes;
foreach (parseAttributes(__DIR__ . '/src') as $annotatedTarget) {
// $annotatedTarget is an instanceof AnnotatedTarget
// This will be a ReflectionClass, ReflectionProperty, or ReflectionMethod depending on which iteration
$target = $annotatedTarget->getTargetReflection();
$target = $annotatedTarget->targetReflection();
// This will be a ReflectionAttribute
$attributeReflection = $annotatedTarget->getAttributeReflection();
// This will be an instance of the Attribute returned from $this->getAttributeReflection()->newInstance()
$attributeInstance = $annotatedTarget->getAttributeInstance();
$attributeReflection = $annotatedTarget->attributeReflection();
// This will be an instance of the Attribute returned from $this->attributeReflection()->newInstance()
$attributeInstance = $annotatedTarget->attributeInstance();

// All the methods above are shared
$isShared = $annotatedTarget->getTargetReflection() === $annotatedTarget->getTargetReflection(); // true
$isShared = $annotatedTarget->targetReflection() === $annotatedTarget->targetReflection(); // true
}
```

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
],
"require": {
"php": "^8.1",
"nikic/php-parser": "^v4.14",
"cspray/typiphy": "^0.3"
"nikic/php-parser": "^v4.18 || ^5.0"
},
"require-dev": {
"pestphp/pest": "^v1.21"
"pestphp/pest": "^v2"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 10 additions & 0 deletions fixture_src/AliasedAttribute/FooClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);

namespace Cspray\AnnotatedTargetFixture\AliasedAttribute;

use Cspray\AnnotatedTargetFixture\ClassOnly as MyAttributeName;

#[MyAttributeName('my aliased value')]
class FooClass {

}
14 changes: 14 additions & 0 deletions fixture_src/AliasedAttributeFixture.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);

namespace Cspray\AnnotatedTargetFixture;

final class AliasedAttributeFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/AliasedAttribute';
}

public function fooClass() : string {
return AliasedAttribute\FooClass::class;
}
}
7 changes: 2 additions & 5 deletions fixture_src/ClassOnlyAttributeGroupSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class ClassOnlyAttributeGroupSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/ClassOnlyAttributeGroupSingleClass';
}

public function fooClass() : ObjectType {
return objectType(ClassOnlyAttributeGroupSingleClass\FooClass::class);
public function fooClass() : string {
return ClassOnlyAttributeGroupSingleClass\FooClass::class;
}
}
4 changes: 2 additions & 2 deletions fixture_src/ClassOnlyAttributeSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function getPath() : string {
return __DIR__ . '/ClassOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(ClassOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return ClassOnlyAttributeSingleClass\FooClass::class;
}
}
4 changes: 2 additions & 2 deletions fixture_src/ClassOnlyAttributeSingleInterfaceFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function getPath() : string {
return __DIR__ .'/ClassOnlyAttributeSingleInterface';
}

public function fooInterface() : ObjectType {
return objectType(ClassOnlyAttributeSingleInterface\FooInterface::class);
public function fooInterface() : string {
return ClassOnlyAttributeSingleInterface\FooInterface::class;
}
}
4 changes: 2 additions & 2 deletions fixture_src/ConstantOnlyAttributeGroupSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public function getPath() : string {
return __DIR__ . '/ConstantOnlyAttributeGroupSingleClass';
}

public function fooClass() : ObjectType {
return objectType(ConstantOnlyAttributeGroupSingleClass\FooClass::class);
public function fooClass() : string {
return ConstantOnlyAttributeGroupSingleClass\FooClass::class;
}

}
4 changes: 4 additions & 0 deletions fixture_src/Fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ public static function targetAttributeInterface() : TargetAttributeInterfaceFixt
public static function invalidSyntax() : BadPhpFileFixture {
return new BadPhpFileFixture();
}

public static function aliasedAttribute() : AliasedAttributeFixture {
return new AliasedAttributeFixture();
}
}
7 changes: 2 additions & 5 deletions fixture_src/MethodOnlyAttributeSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

final class MethodOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/MethodOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(MethodOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return MethodOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

final class MultipleDifferentClassOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/MultipleDifferentClassOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(MultipleDifferentClassOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return MultipleDifferentClassOnlyAttributeSingleClass\FooClass::class;
}
}
9 changes: 3 additions & 6 deletions fixture_src/NonPhpFileFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class NonPhpFileFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/NonPhpFile';
}

public function fooClass() : ObjectType {
return objectType(NonPhpFile\FooClass::class);
public function fooClass() : string {
return NonPhpFile\FooClass::class;
}
}
}
7 changes: 2 additions & 5 deletions fixture_src/ParameterOnlyAttributeSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class ParameterOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/ParameterOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(ParameterOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return ParameterOnlyAttributeSingleClass\FooClass::class;
}
}
7 changes: 2 additions & 5 deletions fixture_src/PropertyOnlyAttributeSingleClassFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

final class PropertyOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/PropertyOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(PropertyOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return PropertyOnlyAttributeSingleClass\FooClass::class;
}
}
7 changes: 2 additions & 5 deletions fixture_src/RepeatableClassOnlyAttributeSingleFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

final class RepeatableClassOnlyAttributeSingleFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/RepeatableClassOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(RepeatableClassOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return RepeatableClassOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class RepeatableConstantOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/RepeatableConstantOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(RepeatableConstantOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return RepeatableConstantOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class RepeatableMethodOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ .'/RepeatableMethodOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(RepeatableMethodOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return RepeatableMethodOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

final class RepeatableParameterOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/RepeatableParameterOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(RepeatableParameterOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return RepeatableParameterOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class RepeatablePropertyOnlyAttributeSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/RepeatablePropertyOnlyAttributeSingleClass';
}

public function fooClass() : ObjectType {
return objectType(RepeatablePropertyOnlyAttributeSingleClass\FooClass::class);
public function fooClass() : string {
return RepeatablePropertyOnlyAttributeSingleClass\FooClass::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Cspray\AnnotatedTargetFixture;

use Cspray\Typiphy\ObjectType;
use function Cspray\Typiphy\objectType;

class SingleAttributeMultipleConstantsSingleClassFixture implements Fixture {

public function getPath() : string {
return __DIR__ . '/SingleAttributeMultipleConstantsSingleClass';
}

public function fooClass() : ObjectType {
return objectType(SingleAttributeMultipleConstantsSingleClass\FooClass::class);
public function fooClass() : string {
return SingleAttributeMultipleConstantsSingleClass\FooClass::class;
}
}
Loading
Loading