-
Notifications
You must be signed in to change notification settings - Fork 222
Annotations refactoring #710
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
Conversation
- Annotations Refactoring (with a GraphClass) - Add missing `isTypeOf` on `@GQL\Type` - Add `targetType` on `@GQL\Mutation` to handle multiple schema #526 - Autodiscover Interfaces for '@gql\Type' based on PHP interfaces or parent classes #701 - Autodiscover Union types for '@gql\Union` based on PHP interfaces or children classes #701
- Annotations Refactoring (with a GraphClass) - Add missing `isTypeOf` on `@GQL\Type` - Add `targetType` on `@GQL\Mutation` to handle multiple schema #526 - Autodiscover Interfaces for '@gql\Type' based on PHP interfaces or parent classes #701 - Autodiscover Union types for '@gql\Union` based on PHP interfaces or children classes #701
Fix my bad english. Thanks @murtukov Co-authored-by: Timur Murtukov <[email protected]>
@Vincz LGTM, just only one general thing: try to always specify the types in docblocks (param and return) and inline. If you look at the badges from branch 0.11 to master, you will see, that the Scrutinizer reduces with every new version, which means the code quality drops. For example, if the method returns
When you specify multiple types like And try to fix the errors reported from Scrutinizer. Right now Scrutinizer says, that the 2 worst classes in the whole project are: |
Thanks for the great review @murtukov ! |
For example, with something like this :
I know that because |
Example: /**
* @param FirstClass|SecondClass $myObject
*/
public function myMethod(object $myObject)
{
if($this->type === 'test') {
$result = $myObject->doSomething();
return $result;
}
$result = $myObject->doAnotherThing();
return $result;
} Here we say, that In this case static analyzer will raise an error, saying, that /**
* @param FirstClass|SecondClass $myObject
*/
public function myMethod(object $myObject)
{
if($this->type === 'test') {
/** @var FirstClass $result */
$result = $myObject->doSomething();
return $result;
}
/** @var SecondClass $result */
$result = $myObject->doAnotherThing();
return $result;
} With that, static analyzers know for sure, what class is used in what line. |
@Vincz But this errors maybe wouldn't happend, if we defined param types and return types on all methods we use in the project. Static analyzer can then calculate all possible calls and determine itself, which types are where used. Here is a useful link: https://phpstan.org/writing-php-code/phpdoc-types |
Ok, thanks for the explanation ! Is there a way to let it know the other way around. Like "It is not a ". if (null !== $gqlType) {
if (!$gqlName) {
$gqlName = $classAnnotation->name ?: $graphClass->getShortName();
} And need to let him know that it is not a |
@Vincz you can create an interface Update: |
# Conflicts: # src/Config/Parser/AnnotationParser.php
…xists Simplify FQCN when using class_exists
- Annotations Refactoring (with a GraphClass) - Add missing `isTypeOf` on `@GQL\Type` - Add `targetType` on `@GQL\Mutation` to handle multiple schema #526 - Autodiscover Interfaces for '@gql\Type' based on PHP interfaces or parent classes #701 - Autodiscover Union types for '@gql\Union` based on PHP interfaces or children classes #701
Fix my bad english. Thanks @murtukov Co-authored-by: Timur Murtukov <[email protected]>
isTypeOf
on@GQL\Type
targetType
on@GQL\Mutation
to handle multiple schema [Annotation] Add option to @Provider to attach to different types #526@GQL\Type
based on PHP interfaces or parent classes Annotations & Interfaces / Unions auto-discovery #701@GQL\Union
based on PHP interfaces or children classes Annotations & Interfaces / Unions auto-discovery #701