With so many parameter modes in PHP, I wanted to know exactly what ReflectionParameter
is going to return.
<?php
class Database {}
$fns = [
function ($str) {},
function ($str ="hello") {},
With so many parameter modes in PHP, I wanted to know exactly what ReflectionParameter
is going to return.
<?php
class Database {}
$fns = [
function ($str) {},
function ($str ="hello") {},
A list of query-builders and other SQL query and/or schema abstractions.
Libraries with no activity for 2+ years will be considered "dead", as these are not keeping up with the language or ecosystem - but they may be added and may remain on the list, if they contain different or interesting ideas.
from(books).where(books.author.lower().like('%bob')
and similar.
<?php | |
use Psr\Http\Message\ResponseFactoryInterface; | |
use Psr\Http\Message\ServerRequestInterface; | |
use Psr\Http\Message\ResponseInterface; | |
use Psr\Http\Server\MiddlewareInterface; | |
use Psr\Http\Server\RequestHandlerInterface; | |
// There are essentially 3 handler/middlerware patterns: | |
// |
I was curious if we could use ChatGPT to generate a new and better manual for PHP.
This example was interesting enough that I figured it was worth posting.
It looks like ChatGPT does not know PHP 8.1 - the latest version it seems to know is PHP 8.
When asked to explain the first class Callable(...)
syntax (introduced in PHP 8.1) it does explain how to generate something that is functionally similar, using e.g. fn($car) => $car->drive()
rather than $car->drive(...)
. So it understands the concept, it just doesn't know about the new syntax.
But here's the wild part: I then proceded to explain the new syntax to it, and asked it to explain again using the new syntax - and it did it. 😮
In response to this answer:
The built-in dependency injection container does not support named dependency registrations, and there are no plans to add this at the moment.
One reason for this is that with dependency injection, there is no type-safe way to specify which kind of named instance you would want. You could surely use something like parameter attributes for constructors (or attributes on properties for property injection) but that would be a different kind of complexity that likely wouldn’t be worth it; and it certainly wouldn’t be backed by the type system, which is an important part of how dependency injection works.
I'm not sure what is meant by "type-safe" here?
The way service providers are provisioned in .NET today (via service providers and descriptors) is only "type-safe" in the sense that e.g. constructors specify the required types of dependencies that should be injected - th
Guidelines for upgrading the minimum PHP version requirements of packages and projects.
This isn't meant to be an exhaustive guide to upgrading, but as a checklist for the most important upgrades.
The first version to support namespaces - any relevant PHP packages/projects usually have this version as the minimum requirement, so this document won't concern itself with upgrades prior to that.
This script tries to detect monkey-patching, polyfills and other hacks/overrides in the browser.
Paste it into the Chrome (or Edge) console and press ENTER.
Note that this may give false positives for window.location
, window.fetch
and window.length
- this appears to be because these properties aren't correctly reflected by the native browser implementations, but if you know how to fix that, please post a comment.
function findVar(varName) { | |
let seen = new Map(); | |
function search(obj, prefix = "") { | |
if (seen.has(obj)) { | |
return; | |
} | |
seen.set(obj, true); |
// Based on: https://stackoverflow.com/a/46814952/283851 | |
/** | |
* Create a Base64 Image URL, with rotation applied to compensate for EXIF orientation, if needed. | |
* | |
* Optionally resize to a smaller maximum width - to improve performance for larger image thumbnails. | |
*/ | |
export async function getImageUrl(file: File, maxWidth: number|undefined) { | |
return readOrientation(file).then(orientation => applyRotation(file, orientation || 1, maxWidth || 999999)); | |
} |