Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PropertyInfo] @Internal directive on class prevents custom read/write extractor implementation #58988

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

Closed
Guarrakesh opened this issue Nov 25, 2024 · 1 comment

Comments

@Guarrakesh
Copy link

Guarrakesh commented Nov 25, 2024

Symfony IsVersions(s) Affected

All

Description

I'm trying to use a custom Read/Write Info Extractor within the PropertyAccessor.

// CustomReadExtractor.php
class CustomReadExtractor implements PropertyReadInfoExtractorInterface {
        public function getReadInfo(string $class, string $property, array $context = []): ?PropertyReadInfo;
        {
               //custom logic
        }
}

// example usage
$extractor = new CustomReadExtractor();
(new PropertyAccessorBuilder)->setReadInfoExtractor($extractor);

Howevery, the class PropertyReadInfo is marked as @internal in it's docblock, causing the IDE and PHPStan to complain about usage of internal members.

I assume that creating a custom extractor is something that should be supported, as the documentation states [...] While you can create your own extractors, the following are already available to cover most use-cases

The same problem is with PropertyWriteInfo while implementing a custom class for PropertyWriteExtractorInterface.

Is it a wanted limitation or something we can fix?

Example

The new PropertyReadInfo and PropertyWriteInfo should not be marked as @internal

Before:

/**
 * The property read info tells how a property can be read.
 *
 * @author Joel Wurtz <[email protected]>
 *
 * @internal
 */
final class PropertyReadInfo
{
}

After

/**
 * The property read info tells how a property can be read.
 *
 * @author Joel Wurtz <[email protected]>
 *
 */
final class PropertyReadInfo
{
@mtarld
Copy link
Contributor

mtarld commented Dec 20, 2024

Hey @Guarrakesh, indeed, I think something's going wrong here.

PropertyReadInfoExtractorInterface is not internal, but PropertyReadInfo is. Which makes implementing PropertyReadInfoExtractorInterface impossible to implement without going against the internal usage rule.

I think that your fix is the good approach. Up to create a PR? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants