Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for non type-hinted attribute accessors with no backed property #1411

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

pindab0ter
Copy link
Contributor

Summary

This is a resubmission of #1338 as that got closed inadvertently.

Even though the documentation doesn't state this explicitly at the time of writing, it is possible to use the new Attribute accessor to create a calculated property where there is no backing property.

This solves #1315.

I added a check for if the Attribute accessor function has no specified type, and then add it without type.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Add a CHANGELOG.md entry
  • Code style has been fixed via composer fix-style

@pindab0ter
Copy link
Contributor Author

Because of how the branches are now rebased on top of each other, this PR also includes #1339.

@pindab0ter pindab0ter force-pushed the feature/typeless-accessor branch from 7be808a to 99e28aa Compare February 19, 2023 21:50
@pindab0ter pindab0ter force-pushed the feature/typeless-accessor branch from 99e28aa to 7bc77e3 Compare February 20, 2023 09:04
@jtomek
Copy link

jtomek commented Jun 9, 2023

Thank you for your work on this one. I'm not sure if I understand the status of this PR correctly. Is it still pending a final approval?

@pindab0ter
Copy link
Contributor Author

pindab0ter commented Jun 9, 2023

We're still waiting on @mfn to review this PR.

For context, this is a resubmission of a PR originally submitted april 2022. I have since moved on to using Laravel Idea, which also has Laravel IDE Helper like functionality.

@chescos
Copy link

chescos commented Aug 8, 2023

Hey @mfn - can we get this merged?

@ngmy
Copy link
Contributor

ngmy commented Nov 10, 2023

I too am eager for this pull request to be merged.
It worked as expected in my local environment.


(added)

I tried dev-master and attributes without back properties with type hints worked.
My use cases are satisfactory.
(Attributes without back properties without type hints did not work.)

I do not want to reference dev-master and would like a release 🙏

@pindab0ter
Copy link
Contributor Author

I have given up on waiting for this and have stopped using this package in favour of the Laravel IDEA plugin.

@barryvdh
Copy link
Owner

barryvdh commented Feb 8, 2024

Sorry for the delay here.

Not sure why Psalm thinks it's dead code. I think the type can also be ReflectionNamedType or ReflectionUnionType according to https://www.php.net/manual/en/class.reflectiontype.php

@barryvdh barryvdh merged commit f12d933 into barryvdh:master Feb 8, 2024
33 checks passed
d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this pull request Feb 16, 2024
…operty (barryvdh#1411)

* Read Attribute type from parameter

* Update CHANGELOG.md

* Update ModelsCommand.php

---------

Co-authored-by: Barry vd. Heuvel <barry@fruitcake.nl>
Co-authored-by: Barry vd. Heuvel <barryvdh@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants