Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

343
Views
Why is the inline version not throwing an exception?

I am using the symfony2/finder component to access an Amazon S3 bucket via the stream wrapper of the aws/aws-sdk-php. I was upgrading the finder component from 2.7.4 to its latest 2.7.25 version (2.7.25) via:

composer require symfony/finder:2.7.25

In the process, I discovered that when a directory had a trailing slash in its path no files were found.

    $directory = "s3://{$bucket}/{$taskHandle}/transmissions-{$thread}/"; // valid for finder 2.7.4, yet not >=2.7.5 due to traling slash at the end

I was especially confused as to why there was no exception or error thrown. Yet when debugging I discovered this odder behavior:

This will execute just fine, yet produce empty output (false positive execution):

    $files = (new Finder())
        ->name('*')
        ->in($directory)
        ->filter(
            function (SplFileInfo $file) use ($lastRuntime) {
                return $file->isFile() && ($file->getMTime() < $lastRuntime);
            }
        )
        ->files();

Yet when I remove the inline of the callback and do this instead:

        ...
        ->filter(
            function (SplFileInfo $file) use ($lastRuntime) {
                $isFile = $file->isFile(); // will now trigger a fatal error
                $modifiedAt = $file->getMTime();

                return $isFile && ($modifiedAt < $lastRuntime);
            }
        )

Then I do see the fatal error:

Fatal error: Uncaught RuntimeException: File or directory not found: s3://somebucket/somekey/foo/bar.csv in vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php:738 Stack trace: #0 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(738): trigger_error('File or directo...', 512) #1 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(912): Aws\S3\StreamWrapper->triggerError('File or directo...', 0) #2 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(301): Aws\S3\StreamWrapper->boolCall(Object(Closure), 0) #3 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(246): Aws\S3\StreamWrapper->createStat('s3://...', 0) #4 [internal function]: Aws\S3\StreamWrapper->url_stat('s3://...', 0) #5 
... SplFileInfo->getMTime() #6 [internal function]: UserInterface\Con in vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php on line 738

This makes no sense to me. From where I am standing, the code should be equivalent. What I am not getting?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!