Call to a member function count() on array code example
Example 1: Call to a member function count() on string
count($project->tasks)
Example 2: Call to a member function count() on string
h2>{{{ $project->name }}}</h2>
@if ( count($project->tasks)==0)
There are no tasks for this project.
@else
<ul>
@foreach( $project->tasks as $task)
<li><a href="{{ route('projects.tasks.show', [$project->slug, $task->slug]) }}">{{ $task->name }}</a></li>
@endforeach
</ul>
@endif
Example 3: double function call javascript
//It means that the first function ($filter) returns another
//function and then that returned function is called immediately.
//For Example:
function add(x){
return function(y){
return x + y;
};
}
var addTwo = add(2);
addTwo(4) === 6; // true
add(3)(4) === 7; // true
Example 4: call to a member function guessextension() on string
// I had to change this:
public function getImage(): ?string {}
public function setImage(string $image): self {}
// To this (both without 'string'):
public function getImage() {}
public function setImage( $image): self {}