vendor/overblog/graphql-bundle/src/Relay/Connection/Output/DeprecatedPropertyPublicAccessTrait.php line 25

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Overblog\GraphQLBundle\Relay\Connection\Output;
  4. use function array_keys;
  5. use function get_object_vars;
  6. use function in_array;
  7. use function sprintf;
  8. use function trigger_error;
  9. use function ucfirst;
  10. use const E_USER_DEPRECATED;
  11. /**
  12.  * @internal
  13.  */
  14. trait DeprecatedPropertyPublicAccessTrait
  15. {
  16.     /**
  17.      * @return mixed
  18.      */
  19.     public function __get(string $name)
  20.     {
  21.         return $this->accessProperty('get'$name);
  22.     }
  23.     /**
  24.      * @param mixed $value
  25.      *
  26.      * @return mixed
  27.      */
  28.     public function __set(string $name$value)
  29.     {
  30.         return $this->accessProperty('set'$name$value);
  31.     }
  32.     /**
  33.      * @param mixed|null $value
  34.      *
  35.      * @return array|null
  36.      */
  37.     private function accessProperty(string $typestring $name$value null)
  38.     {
  39.         if (in_array($namearray_keys(get_object_vars($this)))) {
  40.             $method $type.ucfirst($name);
  41.             @trigger_error(
  42.                 sprintf(
  43.                     '%sting directly property %s::$%s value is deprecated as of 0.12 and will be removed in 0.13. '.
  44.                     'You should now use method %s::%s.',
  45.                     ucfirst($type),
  46.                     __CLASS__,
  47.                     $name,
  48.                     __CLASS__,
  49.                     $method
  50.                 ),
  51.                 E_USER_DEPRECATED
  52.             );
  53.             return $this->$method($value);
  54.         }
  55.         if ('set' === $type) {
  56.             $this->$name $value;
  57.             return null;
  58.         } else {
  59.             return $this->$name;
  60.         }
  61.     }
  62. }