Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
82 views

I've done a lot of Googling and may have missed this, there's so many examples of using the new Attribute feature in PHP but none of them show if this is possible. What I would like to be able to do ...
ch1902's user avatar
  • 13
1 vote
1 answer
64 views

According to this page it is now possible and recommended to define entities without the use of getters and setters for the fields. But when I define my Entity like this in "shopware/core": &...
Tom M's user avatar
  • 2,917
0 votes
1 answer
277 views

I'm currently working on a Symfony-based CMS which uses attributes to declare callbacks. Because of that the function is not called directly anywhere in the code. This causes PhpStorm to show a "...
ahendwh2's user avatar
  • 404
4 votes
2 answers
312 views

I have a project that use attributes : #[OperationQueryParam('id', IntegerOperation::class, requirements: new Numeric(min: 1, max: 2_147_483_647))] Everything works fine but there are multiple ...
Floxblah's user avatar
  • 234
0 votes
1 answer
325 views

Let's say I have the following classes: class Bar{ public int $id; } class Boo{ public string $name; } class Foo{ #[ObjectAttr] public Bar $barObject; #[ObjectAttr] public ...
Pejman's user avatar
  • 2,666
3 votes
1 answer
1k views

I have a symfony serializer that i initialize this way : $this->serializer = new Serializer( [ new ArrayDenormalizer(), new UidNormalizer(), new BackedEnumNormalizer(), ...
Methraen's user avatar
2 votes
1 answer
420 views

I'm using symfony 5.4 with php 8.1 and I would like to factor a set of attributes used for Swagger documentation, before each controllers method, I have, at least, these 5 attributes: #[OA\Response( ...
Taine's user avatar
  • 35
0 votes
1 answer
2k views

Look at the following code: <?php enum Types:string { case A = 'a'; case B = 'b'; } #[Attribute(Attribute::TARGET_CLASS)] class MyAttribute { public function __construct(public ...
112Legion's user avatar
  • 1,269
0 votes
0 answers
334 views

I'm working with Bolt CMS on a project. It seems great so far, but it looks like the Bolt team has been a bit cautious about switching from annotation mappings to attribute mappings, as when I use ...
Mayor of the Plattenbaus's user avatar
0 votes
1 answer
247 views

I'm currently working on an integration with a third party API for an application, for which I'm using Spatie's data transfer object library. I'm currently looking to set up validation for some fields,...
Matthew Daly's user avatar
  • 9,515
1 vote
0 answers
207 views

What would be the best way to perform some modification on a method argument before the method is actually executed? I have tried achieving this with a combination of attributes and use of the ...
Cyclonecode's user avatar
  • 30.4k
1 vote
0 answers
20 views

Lets say i have an attribute class: #[Attribute(Attribute::TARGET_METHOD)] class MyEvent { /** * @phpstan-param null|Request::METHOD_* $method */ public function __construct( ...
Stackster's user avatar
4 votes
1 answer
2k views

I'm having trouble making sense of this PHPStan error. PHPStan is saying I need to provide the class string of an EntityRepository of an object. I am providing the class string of a ...
amacrobert's user avatar
  • 3,279
0 votes
1 answer
4k views

In Symfony controllers, route are defined as follow : class BlogController extends AbstractController { #[Route('/blog/{page}', name: 'blog_list', requirements: ['page' => '\d+'])] public ...
Mulot's user avatar
  • 331
4 votes
2 answers
5k views

I am using laravel. I need to know how phpdoc can be written in php 8 with attibutes. /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @...
Kasun Sampath Weligamage's user avatar
12 votes
3 answers
4k views

<?php declare(strict_types=1); namespace App\Controller\User; use App\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; ...
Denzel Brazhnikoff's user avatar
4 votes
1 answer
2k views

I'm trying to learn how attributes in PHP work. But when I wrote some code (I have XAMPP with PHP 8 support installed), it doesn't seem to work (no message on the screen). Does it need additonal ...
dominiq007's user avatar
1 vote
1 answer
1k views

I'm working on small PHP framework (for learning). It has a file with LoginController class containing a method with Route attribute (code below). Is there any way to get the name of the method in the ...
dominiq007's user avatar
3 votes
2 answers
6k views

Recently we upgraded our applications to PHP8. Since PHP8 introduced attributes and doctrine/orm supports them as of version 2.9 it seemed like a good idea to utilize this feature to incrementally (ie....
helvete's user avatar
  • 2,739
1 vote
1 answer
1k views

Playing a little bit with the new PHP 8 attributes (annotations) (https://stitcher.io/blog/attributes-in-php-8) I started to create my own ones. Simple example: namespace CisTools\Attribute; use ...
Blackbam's user avatar
  • 19.7k
10 votes
1 answer
3k views

Lately, the attributes RFC has passed the voting stage. How they are different from DocBlock annotations, and what benefits will they bring? Consider simple Doctrine entity, before: /** * @ORM\Entity ...
Mike Doe's user avatar
  • 17.7k