Comments (5)
We had the same error today. The problem was that we used anonymous classes in our code base. By replacing them with generic new stdClass()
we fixed the problem. This is quite an ugly solution, but it works.
I hope this helps anyone having the same error.
from laravel-scout-elasticsearch.
@Ecsodikas thanks for sharing yours findings. don't remember details but yes anonymous classes not supported to be able to search by multiple models as I remember.
from laravel-scout-elasticsearch.
Hey. Feel free to send a PR
from laravel-scout-elasticsearch.
The error occurs because for some class nodes, the namespacedName property is null, indicating that these class nodes do not have a fully qualified name. This could happen if the class does not have a namespace defined, or if there is an issue with the way the AST is generated or traversed.
Could you provide more info about file on which the error occured?
from laravel-scout-elasticsearch.
Issue: Error: Call to a member function toCodeString() on null
Description
I am encountering an issue with the matchish/laravel-scout-elasticsearch
package when running the php artisan scout:import
command. The error message I receive is:
Error: Call to a member function toCodeString() on null
This error occurs at the following line of code in the SearchableListFactory.php
file:
return $node->namespacedName->toCodeString();
From my understanding, it seems that namespacedName
is null
for some $node
objects, and therefore, calling toCodeString()
on it results in an error.
Steps to reproduce the issue
- Run the
php artisan scout:import
command.
Expected Result
The command should execute successfully, without any errors.
Actual Result
I get the error Error: Call to a member function toCodeString() on null
.
Additional Information
- Laravel version: 9.52
- PHP version: 8.1
matchish/laravel-scout-elasticsearch
package version: ^7.2
I have tried re-installing the package, moving non-class PHP files to a different location, and updating the composer.json file's autoload files array. Additionally, I have checked all models in the App
namespace, and all of them have the class defined and no files are missing the class definition. However, none of these steps have resolved the issue.
Screenshots
PS ...\logisticapi> php artisan scout:import
Error
Call to a member function toCodeString() on null
at ...\vendor\matchish\laravel-scout-elasticsearch\src\Searchable\SearchableListFactory.php:110
106▕ return $node instanceof Class_;
107▕ });
108▕
109▕ return Collection::make($nodes)->map(function ($node) {
➜ 110▕ return $node->namespacedName->toCodeString();
111▕ });
112▕ }
113▕
114▕ /**
1 [internal]:0
Matchish\ScoutElasticSearch\Searchable\SearchableListFactory::Matchish\ScoutElasticSearch\Searchable\{closure}(Object(PhpParser\Node\Stmt\Class_))
2 ...\vendor\laravel\framework\src\Illuminate\Collections\Arr.php:560
array_map(Object(Closure))
from laravel-scout-elasticsearch.
Related Issues (20)
- [Feature] Change app namespace call in commands HOT 2
- [BUG] Bulk update error when saving with boolean HOT 1
- [BUG] NoNodeAvailableException: No alive nodes. All the 1 nodes seem to be down HOT 3
- [BUG] The attribute [routing] either does not exist or was not retrieved for model [App\Models\Track]. HOT 5
- [BUG] Possibly unexpected behaviour, when using additional callback in `search` HOT 3
- [Feature] Utilize custom "options" of a builder HOT 2
- configure stopwords HOT 1
- "current.health":"RED","message":"Cluster health status changed from [YELLOW] to [RED] HOT 1
- [BUG] ProgressBar updates are posted to stderr HOT 1
- [BUG] Class Elasticsearch\Client not found HOT 3
- [Feature] Add possibility to use RangeQuery and other terms instances as value for $scoutQuery->where() HOT 2
- php artisan scout:import error? Cannot use Encore\Admin\Form as Form because the name is already in use on line 21 HOT 10
- [Feature] Use SearchableScope instead PageScope HOT 4
- PHP 8.3 support HOT 2
- is there any way to revert to the previous index state before reindexing ? HOT 3
- Elastic has prefix restrictions on reads HOT 1
- How to use the latest version of this package with Elasticsearch 7? HOT 3
- PHP-Parser not in direct dependencies, PHP-Parser > 5.0 is incompatible HOT 1
- Why Can't I update the mapping with Laravel Scout?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-scout-elasticsearch.