PHP Tricks: Lazy public readonly properties

PHP Tricks: Lazy public readonly properties

I am apparently late in coming to this trick, but PHP 8.1 is going to make it even nicer to use.

A clever trick

There's an interesting intersection of functionality in PHP:

  • Declared object properties are more efficient than dynamic ones, because the engine can make assumptions about what data type to expect.
  • The magic `__get()` and `__set()` methods trigger when there is no property with a given name that has been *set*.
  • Fun fact: A property that has been declared but not initialized with a value is still technically "set"... to `uninitialized`.
  • However, you can `unset()` an uninitialized property.

That means you can do clever tricks like this (and some systems do, internally):

Continue reading this post on PeakD

Larry 12 November 2021 - 10:50am

Weekly News for Designers № 618

Envato Elements

Showcode – Create beautifully-styled code snippets, then export them as an image with this handy tool.
Example from Showcode

Bootstrap Icons – A free, open-source library of 1,500+ icons to use in your projects (Bootstrap or otherwise).
Example from Bootstrap Icons

10 Free WordPress Plugins for Extending BuddyPress and bbPress – Turn your WordPress website into an online community with these free plugins.
Example from 10 Free WordPress Plugins for Extending BuddyPress and bbPress

React Aria – A library of React Hooks from Adobe that provides accessible UI primitives for your design system.
Example from React Aria

Developer Tools secrets that shouldn’t be secrets – Get the inside scoop on what your browser’s developer tools are capable of.
Example from Developer Tools secrets that shouldn’t be secrets

8 CSS & JavaScript Snippets for Creating Incredible Lighting & Shading Effects – It’s now possible to add lighting and shading effects that are nearly on par with what we see in video games.
Example from 8 CSS & JavaScript Snippets for Creating Incredible Lighting & Shading Effects

Spectrum – Add a base color and this tool will generate an entire palette for you.
Example from Spectrum

A 10-step approach to inclusive branding, using the BBC as an example – A look at how the BBC put together its accessible branding.
Example from A 10-step approach to inclusive branding, using the BBC as an example

GUI Challenges – A collection of solutions to common interface challenges.
Example from GUI Challenges

Those Things You Must Do When Ending a Freelance Design Project – There are some important things that most designers never do when ending a freelance project. Here’s why you should make the effort.
Example from Those Things You Must Do When Ending a Freelance Design Project

Getting out of the Freelance Pricing Trap – Learn how to start charging what you’re truly worth.
Example from Getting out of the Freelance Pricing Trap

Jam – This Chrome extension lets you give lightning-fast feedback on live websites without the frustration of screenshots.
Example from Jam

HTML Forms Library – This library contains ready-to-use code for forms and works with popular frameworks.
Example from HTML Forms Library

CSS Buttons – Check out this open-source collection of button styles for every use case.
Example from CSS Buttons

Despite Its Critics, jQuery Forges Ahead – The popular JavaScript library is still in active development and in use by three-quarters of the web.
Example from Despite Its Critics, jQuery Forges Ahead

FlowBite – This open-source library features 400+ web components built with Tailwind CSS.
Example from FlowBite

How I made Google’s data grid scroll 10x faster with one line of CSS – This case study demonstrates the troubleshooting process and how to implement a solution.
Example from How I made Google’s data grid scroll 10x faster with one line of CSS

The post Weekly News for Designers № 618 appeared first on Speckyboy Design Magazine.

The Dependency Injection Paradigm

Paradigm; a nice word that means "a theory or a group of ideas about how something should be done, made, or thought about" (Merriam-Webster). In software development we have them too. From the philosophy and history of science courses I've followed, I remember that scientists working with different paradigms have great difficulty understanding each other, and appreciating each other's work.

Paradigm Shifts

An example of a paradigm is the theory that the sun revolves around the earth. To a certain extent this is a fruitful theory, and it has been used for thousands of years. There's of course another paradigm: the theory that the earth revolves around the sun. This is also a fruitful theory, and it can be used to explain a lot of observations, more than the previous theory. Still, people got angry with each other for moving the earth out of the center of the universe. Paradigm changes, or shifts, occur when the old theory has been stretched too much. It becomes impossible to hold on to it. Then some people start to experiment with a completely different paradigm, one that sounds totally weird, but in the end proves to have more power.

Now back to software development: we have paradigms and paradigm shifts too. For example, PHP went from being a very dynamically typed language to being a more statically typed language. This is weird for some, but great for others since it unlocks new possibilities, like static analysis and automated refactoring.

The DI Paradigm

Another paradigm shift happened years ago when we went from symfony1 to Symfony 2, which introduced the Dependency Injection container. The idea of Dependency Injection was quite new to many developers back then, and we had to talk and read about it a lot before we were ready for this amazing yet weird concept. What got in the way of adoption, I think, was the Yaml or XML syntax for service definitions, an approach that was probably copied from Spring. If we'd start by writing our own service containers in plain PHP, that would've been much easier to learn and do.

What's interesting to me is that Symfony's first DI container was showing some influence from the old paradigm, e.g.

  • Singleton services: most services are instantiated only once, which allows for stateful services, mimicking the actual singletons from before.
  • The container had services that aren't services (e.g. the current HTTP request object).

Nevertheless, we got a taste of DI: expect your dependencies to be injected, instead of having to fetch them yourself. This changes everything!

  • Dependency injection is inversion of control: a service doesn't have to be worried about setting up a dependency, it can just declare it, and it will be taken care of.
  • Depending on an interface gives the developer the option to switch out implementations, for whatever reason.
  • Looking at the constructor signature, you can get some idea of what the service is going to do, and a complete overview of what it needs.
  • If a class is not a service, you can't give it service dependencies. This makes it absolutely clear what type of object a class represents: it's either a service, or some other object like an entity, or a value object.

I was totally convinced that the Dependency injection paradigm was a step forward, out of the land of unclear dependencies and tightly coupled classes. And I thought every other developer would like it too. Surprisingly, the introduction of a new framework - Laravel - revived the old paradigm, and with great success. It's surprising because a paradigm shift isn't often reverted. In science, the paradigm shift indicates a step forward, towards a theory that can explain more phenomena than the previous paradigm could. In programming, it turns out, you can have developers working with different paradigms, and even arguing that neither of those paradigms is a step forward compared to the other.

Crossing the Bridge

When I, as a developer from the DI paradigm, talk to someone who uses another paradigm, I find it really hard to come to some form of understanding. The assumptions, the goals, the theories that each of us uses, are very different. I find this very hard to deal with. We talk about a piece of code and I see lots of problems with it, but there is no common ground that can help us settle the debate. Personally I'm sad about this, because I don't really know how to improve the situation. You can keep fighting, and this happens a lot (e.g. on Twitter, Reddit), but since developers use completely different paradigms, I think that produces only negativity. In the case of "S

Truncated by Planet PHP, read more at the original (another 1699 bytes)

Take the 2021 WordPress Annual Survey (and view the 2020 results)!

Each year, members of the WordPress community (users, site builders, extenders, and contributors) provide their valuable feedback through an annual survey. Key takeaways and trends that emerge from this survey often find their way into the annual State of the Word address, are shared in the public project blogs, and can influence the direction and strategy for the WordPress Project.

Simply put: this survey helps those who build WordPress understand more about how the software is used, and by whom. The survey also helps leaders in the WordPress open source project learn more about our contributors’ experiences.  

To ensure that your WordPress experience is represented in the 2021 survey results, take the 2021 annual survey now.

You may also take the survey in French, German, Japanese, Russian, or Spanish. These are the top five languages (other than English) based on the number of WordPress locale downloads. For 2022, additional languages may be considered for translation.

The survey will be open through the end of 2021, and the results will be published in a future post on this blog for anyone to view. Next year, there will be a new format for this survey, including which segments and questions are included, so that your valuable time spent responding results in equally valuable information.

2020 Survey Results

For the 2020 survey, more than 17,000 responses were collected, representing the highest submission volume in four years, up three times from the prior year. In the inaugural year of the survey (2015), over 50,000 responses were collected. Given the reach and adoption of WordPress, there is significant significant number we have not reached. As you take the 2021 survey, consider sharing the link on social media and with other colleagues who use WordPress. Gathering feedback from more folks who benefit from WordPress will strengthen our project.

The 2020 survey results show that the pandemic has had a major impact on how we operate as a community. With few in-person events, many community members continue to find it challenging to balance community contributions with their own personal and professional obligations. 

Footnotes:

Data security and privacy are paramount to the WordPress project and community. With this in mind, all data will be anonymized: no email addresses nor IP addresses will be associated with published results. To learn more about WordPress.org’s privacy practices, view the privacy policy.

Like last year, the 2021 survey will be promoted via a banner on WordPress.org, and throughout the make blogs. However, taking a moment to amplify these posts through your own social media and Slack accounts will ensure broader participation. Each of the translated surveys will be promoted through banners on their associated localized-language WordPress.org sites.

Thanks to @dansoschin for the initial draft of this post, and to @annezazu & @zackkrida for review!

PHP 8.1.0 RC 6 available for testing

The PHP team is pleased to announce the release of PHP 8.1.0, RC 6. This is the sixth and final release candidate, continuing the PHP 8.1 release cycle, the rough outline of which is specified in the PHP Wiki. For source downloads of PHP 8.1.0, RC 6 please visit the download page. Please carefully test this version and report any issues found in the bug reporting system. Please DO NOT use this version in production, it is an early test version. For more information on the new features and other changes, you can read the NEWS file or the UPGRADING file for a complete list of upgrading notes. These files can also be found in the release archive. The next release will be the production-ready, general availability release, planned for 25 November 2021. The signatures for the release can be found in the manifest or on the QA site. Thank you for helping us make PHP better.

Winners of the 3rd Annual Public Interest Registry .ORG Impact Awards

.ORG Impact Awards

Public Interest Registry (PIR), the organization behind the .ORG TLD (Top Level Domain), has announced the winners of the 3rd annual .ORG Impact Awards. The .ORG Impact Awards honor and celebrate mission-driven organizations and individuals working to make the world a better place. The award winners were announced as part of an online global event to celebrate and honor “Champions for Change.”

Categories and Entries

633 organizations and individuals submitted entries from more than 40 countries across eight categories:

  • .ORG of the Year
  • Building Better Communities
  • Health and Healing in a Time of Pandemic
  • Championing Diversity, Equity, and Inclusion
  • Overcoming Climate Change
  • Providing Quality Education for All
  • Fighting Hunger and Poverty
  • Rising Stars (leaders 25 years or younger making a difference in their communities)

And the Winners Are…

There are a total of 8 winners this year. The .ORG of the Year receives a donation of $35,000 USD for an eligible charitable entity of its choice, while the other award winners will receive donations of $10,000 USD.

.ORG of the Year – ADES

Donation Amount: $35,000 USD

The 2021 .ORG of the Year winner is ADES, a mission-driven organization that manufactures energy-efficient stoves in Madagascar and promotes the use of renewable energy. ADES’ work protects the climate, biodiversity, and health while facilitating a path out of poverty in Madagascar.

ADES has been promoting energy-efficient cooking in Madagascar since 2001. Now, the organization manufactures and distributes solar and fuel-efficient stoves that do not require the use of significant amounts of wood and charcoal. In honoring the ADES’ work, the .ORG of the Year judges were impressed by ADES’ holistic approach, which educates future generations, develops sustainable manufacturing, empowers women, leads to reforestation, and reduces carbon dioxide emissions.

ADES is also the winner of the 2021 .ORG Impact Award for Overcoming Climate Change. Watch to learn more: https://youtu.be/xt6oYXwT2Ac

Building Better Communities – Litro de Luz Colombia

Donation Amount: $10,000 USD

Litro de Luz Colombia is a decentralized solar energy company that operates in rural areas and post-conflict zones in Colombia and Latin America. More than thirty million people live without electricity in Latin America, including more than two million in Colombia. To address this challenge, Litro de Luz brings public lighting with Wi-Fi Internet to communities in need. Since 2013, Litro de Luz has installed more than 3,100 solar street lights in more than 200 communities, helping more than 270,000 people. Their work helps alleviate digital poverty while improving public safety and providing access to the Internet in marginalized communities. Watch to learn more about Litro de Luz Colombia: https://youtu.be/7fvQPiqISIU

Health and Healing in a Time of Pandemic – Good Sports

Donation Amount: $10,000 USD

Good Sports, which is headquartered in Boston, works to give kids in need the benefits of sport and physical activity by providing new equipment, apparel, and footwear to youth organizations in high-need communities. While some families have the ability to afford sports gear, league fees, and travel costs, many do not. As a result, kids are left on the sidelines. Since 2003, Good Sports has given more than eight million kids across the United States and Puerto Rico greater access to sport and fitness opportunities. In response to the COVID-19 pandemic, Good Sports launched the Restore Play initiative which provided $15 million in equipment and over 27,000 at-home Play Packs (including 541,000 pieces of sports equipment, apparel, and footwear) to children in need. Good Sports creates opportunities to play in each state and is determined to continue to help communities most impacted by the COVID-19 pandemic. Watch to learn more about Good Sports: https://youtu.be/6Dc98Q8rkDo

Championing Diversity, Equity, and Inclusion – MAIA

Donation Amount: $10,000 USD

MAIA educates and prepares indigenous girls in rural Guatemala to become the next generation of empowered female leaders in the country. MAIA focuses on the question: “What would happen if these young women had the opportunity to go as far as their talent could take them?” That’s why the organization established The MAIA Impact School in 2017. The school is the first female, indigenous-led secondary school in Central America. MAIA’s pillars of academics, community, and culture work together to create a support system for young women and their families to ensure they can break the cycles of exclusion and poverty. Currently, 239 girls are enrolled in grades seven through eleven. The school helps to prepare students to enter university and the modern workforce. Watch to learn more about MAIA: https://youtu.be/6Dc98Q8rkDo

Overcoming Climate Change – ADES

Donation Amount: $10,000 USD

In addition to being named the 2021 .ORG of the Year, ADES is also the winner of the Overcoming Climate Change category. Over the last two decades, ADES has saved over two million tons of wood and reduced carbon dioxide emissions by three and a half million tons. Four percent of all households in Madagascar use an ADES cooker, and ADES’ reforestation program has planted over 430,000 trees with another 100,000 to be planted by the end of this year. Watch to learn more about ADES: https://youtu.be/T6WrsY5ngBk

Providing Quality Education for All – Skateistan

Donation Amount: $10,000 USD

Skateistan, based in Berlin with programs in South Africa, Jordan, and Cambodia, is the first international development organization dedicated to empowering children through education and the power of skateboarding. A 2019 .ORG Impact Award winner, Skateistan provides opportunities to children aged five to seventeen, with a goal of having fifty percent of its students be girls. The organization runs five programs within its Skate Schools: Outreach, Dropping In, Skate and Create, Back to School, and Youth Leadership. These programs combine life skills with fun, freedom, and creativity to help create leaders for a better world. In total, Skateistan reaches 2,700 children in the countries in which it operates, making an enormous difference in their lives and communities. Watch to learn more about Skateistan: https://youtu.be/sdNcHKb1j7c

Fighting Hunger and Poverty – Zoe Empowers

Donation Amount: $10,000 USD

Zoe Empowers, which is based in Raleigh, N.C., and works in Kenya, Zimbabwe, Malawi, Rwanda, Liberia, Tanzania, and India, equips orphaned children and vulnerable youth with tools and training to help them overcome life-threatening poverty. Zoe Empowers started as a relief mission responding to the 2004 HIV/AIDS pandemic in Africa. Then, in 2007, after seeing a positive response to its empowerment model in Rwanda, the organization adopted this approach in all countries in which it works. Since then, Zoe Empowers has helped more than 124,000 vulnerable children overcome extreme poverty to achieve self-sufficiency across eight areas of life: https://youtu.be/ekxDbxHzAdQ

Rising Star – Esther Ejiroghene Ajari, The TriHealthon

Donation Amount: $10,000 USD

Esther Ejiroghene Ajari became involved in community development at age sixteen, working as a serial volunteer with twenty five national and international organizations. Esther, determined that she could do more to help people, founded The TriHealthon in 2018, to lead the effort to achieve health equity in Africa. As part of this work, Esther identified and is addressing five prevalent public health problems affecting young people in Nigeria: period poverty, teenage pregnancy, sexually transmitted diseases, childhood diarrhea, and childhood malnutrition. Through their programs, Esther and The TriHealthon are helping tens of thousands of young people in Nigeria escape the cycle of poverty, improve access to quality education, and live healthier lives. Watch to learn more about Esther and The TriHealthon: https://youtu.be/jyGf6rwJoJE

The 2021 .ORG Impact Awards recognize .ORGs that make an enormous difference in their communities and the world. Submissions for the awards were reviewed and scored by a panel of judges who are leaders in the Internet, non-profit, health, education, and marketing sectors. The .ORG of the Year was chosen by PIR from the winners in the other categories. All nominations were required to be tied to an active website with a .ORG domain. Please visit www.orgimpactawards.org for complete rules and information.

WordPress 5.8.2 Security and Maintenance Release

WordPress 5.8.2 is now available!

This security and maintenance release features 2 bug fixes in addition to 1 security fix. Because this is a security release, it is recommended that you update your sites immediately. All versions since WordPress 5.2 have also been updated.

WordPress 5.8.2 is a small focus security and maintenance release. The next major release will be version 5.9.

You can download WordPress 5.8.2 by downloading from WordPress.org, or visit your Dashboard → Updates and click Update Now. If you have sites that support automatic background updates, they’ve already started the update process.

For more information, browse the full list of changes on Trac, or check out the version 5.8.2 HelpHub documentation page.

Thanks and props!

The 5.8.2 release was led by Jonathan Desrosiers and Evan Mullins.

In addition to the release squad members mentioned above, thank you to everyone who helped make WordPress 5.8.2 happen:

Ari Stathopoulos, Bradley Taylor, davidwebca, Evan Mullins, Greg Ziółkowski, Jonathan Desrosiers, Juliette Reinders Folmer, Mukesh Panchal, Sergey Biryukov, shimon246, and Yui.

Props @circlecube and @pbiron for peer review.

Powered by Gewgley