-
Notifications
You must be signed in to change notification settings - Fork 13
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
BUG Incorrect type inspection on many_many through #13
Comments
@silbinarywolf it'd be great if you could confirm that this is the issue so that we can close off silverstripe/silverstripe-versioned#155 as a misidentified error |
@tractorcow Ah yep. You're probably correct. |
…ugh' logic works - Github Issue #13 - Update documentation to include known limitations
…ugh' logic works - Github Issue #13 - Update documentation to include known limitations
…ugh' logic works - Github Issue #13 - Update documentation to include known limitations
@tractorcow You were correct. My steps to confirm this were:
<?php
use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
private static $db = [];
private static $has_one = [];
public function getCMSFields() {
$fields = parent::getCMSFields();
foreach (Page::get() as $r) {
$r->LinkTracking()->add($r);
foreach ($r->LinkTracking() as $record) {
var_dump(get_class($record)); exit;
}
}
return $fields;
}
}
This bug in my code has now been fixed, pushed up and tagged here: Sorry for the false positive guys! |
As per comment at silverstripe/recipe-cms#12 (comment)
https://github.com/silbinarywolf/silverstripe-phpstan/blob/7fadf204193dcfa313666509a3e5d20098ab970a/src/Reflection/MethodClassReflectionExtension.php#L129-L138
The type of the list is not the 'through' array value. That's the 'internal type' only; You'll need to use both 'through' and 'to' to get the actual list class type.
See DataObjectSchema for how we do this internally.
Where you have
$type = $type['through'];
you'll actually need to do deep inspection on the through class to pull the type of the has_one property specified by$type['to']
.Hope that helps. :)
The text was updated successfully, but these errors were encountered: